<commit_before># Test the base class enhancements over AttrDict
# Since the base class should not really contain any properties, we create a
# dummy subclass here and use it for testing.

# Standard imports
import unittest

# Our imports
import emission.core.wrapper.wrapperbase as ecwb

class TestWrapper(ecwb.WrapperBase):
    props = {"a": ecwb.WrapperBase.Access.RO,
             "b": ecwb.WrapperBase.Access.RO,
             "c": ecwb.WrapperBase.Access.RO,
             "WrapperBase": ecwb.WrapperBase.Access.RO,
             "invalid": ecwb.WrapperBase.Access.RO,
             "valid": ecwb.WrapperBase.Access.RW}

    def __init__(self, *args, **kwargs):
        super(TestWrapper, self).__init__(*args, **kwargs)
        # Add new properties called "invalid" and "valid" 
        # with values from the input
        # here, valid depends upon a and invalid depends upon b. Unfortunately, we cannot just do
        # self.valid = True because that call the current setattr, and that will
        # fail because dependent values are read-only. We can't even use the
        # set_attr method of super, since that is WrapperBase and WrapperBase
        # checks the "props" of the current class.  Instead, we call the
        # set_attr method of WrapperBase's parent, which has no checks.
        if "a" in self and self.a == 1:
            super(ecwb.WrapperBase, self).__setattr__("valid", self.a)
        if "b" in self and self.b == 2:
            super(ecwb.WrapperBase, self).__setattr__("invalid", self.b)

class TestBase(unittest.TestCase):
    def testCreationABC(self):
        test_tw = TestWrapper({'a': 1, 'b': 2, 'c': 3})
        self.assertEquals(test_tw.valid, 1)
        self.assertEquals(test_tw.invalid, 2)
        self.assertTrue(str(test_tw).startswith("TestWrapper"))

    def testCreationAB(self):
        test_tw = TestWrapper({'a': 1, 'c': 3})
        self.assertEquals(test_tw.valid, 1)
        with self.assertRaises(AttributeError):<commit_msg>Change the test wrapper class to match the new convention<commit_after># Test the base class enhancements over AttrDict
# Since the base class should not really contain any properties, we create a
# dummy subclass here and use it for testing.

# Standard imports
import unittest

# Our imports
import emission.core.wrapper.wrapperbase as ecwb

class TestWrapper(ecwb.WrapperBase):
    props = {"a": ecwb.WrapperBase.Access.RO,
             "b": ecwb.WrapperBase.Access.RO,
             "c": ecwb.WrapperBase.Access.RO,
             "WrapperBase": ecwb.WrapperBase.Access.RO,
             "invalid": ecwb.WrapperBase.Access.RO,
             "valid": ecwb.WrapperBase.Access.RW}

    def _populateDependencies(self):
        # Add new properties called "invalid" and "valid" 
        # with values from the input
        # here, valid depends upon a and invalid depends upon b. Unfortunately, we cannot just do
        # self.valid = True because that call the current setattr, and that will
        # fail because dependent values are read-only. We can't even use the
        # set_attr method of super, since that is WrapperBase and WrapperBase
        # checks the "props" of the current class.  Instead, we call the
        # set_attr method of WrapperBase's parent, which has no checks.
        if "a" in self and self.a == 1:
            super(ecwb.WrapperBase, self).__setattr__("valid", self.a)
        if "b" in self and self.b == 2:
            super(ecwb.WrapperBase, self).__setattr__("invalid", self.b)

class TestBase(unittest.TestCase):
    def testCreationABC(self):
        test_tw = TestWrapper({'a': 1, 'b': 2, 'c': 3})
        self.assertEquals(test_tw.valid, 1)
        self.assertEquals(test_tw.invalid, 2)
        self.assertTrue(str(test_tw).startswith("TestWrapper"))

    def testCreationAB(self):
        test_tw = TestWrapper({'a': 1, 'c': 3})
        self.assertEquals(test_tw.valid, 1)
        with self.assertRaises(AttributeError):
{'fraction_non_alphanumeric': 0.10225831007358538, 'fraction_numerical': 0.005074854097944684, 'mean_word_length': 2.8875739644970415, 'pattern_counts': {'":': 12, '<': 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': '4921512', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1125, 'n_words': 379}