File size: 791 Bytes
065fee7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import sys
from unittest import mock
import pytest
from keyring import errors
class DeletionDetector:
def __init__(self, state):
self.state = state
self.state.deleted = False
def __del__(self):
self.state.deleted = True
class TestExceptionInfo:
@pytest.mark.skipif(
'__pypy__' in sys.builtin_module_names,
reason="pypy garbage collection defers deletion",
)
def test_traceback_not_referenced(self):
"""
Ensure that an ExceptionInfo does not keep a reference
to the traceback, as doing so can create unintended
side effects. See #386 for more info.
"""
state = mock.MagicMock()
_ = errors.ExceptionInfo(None, None, DeletionDetector(state))
assert state.deleted
|