<commit_before>import jsonsempai

import os
import shutil
import sys
import tempfile

TEST_FILE = '''{
    "three": 3,
    "one": {
        "two": {
            "three": 3
        }
    }
}'''


class TestSempai(object):

    def setup(self):
        self.direc = tempfile.mkdtemp(prefix='jsonsempai')
        sys.path.append(self.direc)

        with open(os.path.join(self.direc, 'sempai.json'), 'w') as f:
            f.write(TEST_FILE)

    def teardown(self):
        sys.path.remove(self.direc)
        shutil.rmtree(self.direc)

    def test_import(self):
        import sempai
        assert sempai

    def test_access(self):
        import sempai
        assert sempai.three == 3

    def test_access_nested(self):
        import sempai
        assert sempai.one.two.three == 3

    def test_acts_like_dict(self):
        import sempai
        assert sempai.one.two == {"three": 3}

    def test_set(self):
        import sempai
        sempai.one.two.three = 4
        assert sempai.one.two.three == 4

    def test_location(self):
        import sempai
        assert sempai.__file__ == os.path.join(self.direc, 'sempai.json')<commit_msg>Add test for removing item<commit_after>import jsonsempai

import os
import shutil
import sys
import tempfile

TEST_FILE = '''{
    "three": 3,
    "one": {
        "two": {
            "three": 3
        }
    }
}'''


class TestSempai(object):

    def setup(self):
        self.direc = tempfile.mkdtemp(prefix='jsonsempai')
        sys.path.append(self.direc)

        with open(os.path.join(self.direc, 'sempai.json'), 'w') as f:
            f.write(TEST_FILE)

    def teardown(self):
        sys.path.remove(self.direc)
        shutil.rmtree(self.direc)

    def test_import(self):
        import sempai
        assert sempai

    def test_access(self):
        import sempai
        assert sempai.three == 3

    def test_access_nested(self):
        import sempai
        assert sempai.one.two.three == 3

    def test_acts_like_dict(self):
        import sempai
        assert sempai.one.two == {"three": 3}

    def test_set(self):
        import sempai
        sempai.one.two.three = 4
        assert sempai.one.two.three == 4

    def test_del(self):
        import sempai
        del sempai.one.two.three
        assert sempai.one.two.get('three', 'not at home') == 'not at home'

    def test_location(self):
        import sempai
        assert sempai.__file__ == os.path.join(self.direc, 'sempai.json')
{'fraction_non_alphanumeric': 0.1166936790923825, 'fraction_numerical': 0.005672609400324149, 'mean_word_length': 2.13722998729352, 'pattern_counts': {'":': 10, '<': 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': '1624395', 'n_tokens_mistral': 877, 'n_tokens_neox': 853, 'n_words': 177}