<commit_before>import unittest

from compiler import ast, smartdict


class TestSmartdict(unittest.TestCase):

    def test_smartdict(self):
        sd = smartdict.Smartdict()
        t = ast.User("foo")
        t.lineno, t.lexpos = 1, 1
        sd[t] = "foo"
        sd[t].should.be.equal("foo")

        tt = ast.User("foo")
        tt.lineno, tt.lexpos = 0, 0
        ttt = sd.getKey(tt)
        ttt.lineno.should.be.equal(1)
        ttt.lexpos.should.be.equal(1)

        del sd[t]
        sd.get(t).should.be(None)
        sd.getKey(t).should.be(None)<commit_msg>Smartdict test: [TDD] Smartdicts should not share state.<commit_after>import unittest

from compiler import ast, smartdict


class TestSmartdict(unittest.TestCase):

    def test_smartdict(self):
        sd = smartdict.Smartdict()
        t = ast.User("foo")
        t.lineno, t.lexpos = 1, 1
        sd[t] = "foo"
        sd[t].should.equal("foo")

        tt = ast.User("foo")
        tt.lineno, tt.lexpos = 0, 0
        ttt = sd.getKey(tt)
        ttt.lineno.should.equal(1)
        ttt.lexpos.should.equal(1)

        sd2 = smartdict.Smartdict()
        sd2.getKey(t).should.be(None)

        del sd[t]
        sd.get(t).should.be(None)
        sd.getKey(t).should.be(None)
{'fraction_non_alphanumeric': 0.1429718875502008, 'fraction_numerical': 0.011244979919678716, 'mean_word_length': 2.1544303797468354, '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': '3793289', 'n_tokens_mistral': 466, 'n_tokens_neox': 446, 'n_words': 81}