<commit_before><commit_msg>Add test capturing expectation around the ExceptionInfo object. Ref #386.<commit_after>from unittest import mock

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:
    def test_traceback_not_referenced(self):
        """
        Ensure that an ExceptionInfo doesn't keep a reference
        to the traceback, as doing so can create unintended
        side effects. See #386 for more info.
        """
        state = mock.MagicMock()
        exc = errors.ExceptionInfo(None, None, DeletionDetector(state))  # noqa
        assert state.deleted

{'fraction_non_alphanumeric': 0.07190412782956059, 'fraction_numerical': 0.007989347536617843, 'mean_word_length': 2.8564102564102565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3716955', 'n_tokens_mistral': 210, 'n_tokens_neox': 200, 'n_words': 67}