<commit_before>import unittest

from src import zdb

class zdbHouseholdTests(unittest.TestCase):

    lastZ = None # Todo: clean this up

    def setup_zdb(self):
        """Set up ZDB object."""
        self.lastZ = zdb.Zdb('secret/tests.db')
        return self.lastZ

    def teardown_zdb(self, zdb):
        """Teardown ZDB object."""
        if not zdb is None:
            zdb.teardown()
        if not self.lastZ is None:
            self.lastZ.teardown()

    def test_getInvalidHouseholdIsNone(self):
        """Test getHousehold."""
        self.teardown_zdb(None)
        z = self.setup_zdb()
        self.assertTrue(z.getHousehold(None) is None, "An invalid value passed to getHousehold returns None.")
        self.assertTrue(z.getHousehold('invalid val') is None, "An invalid value passed to getHousehold returns None.")
        self.teardown_zdb(z)

    def test_addDuplicateHousehold(self):
        pass

    def test_HouseholdCreatedIsHouseholdRetrieved(self):
        """A household created in the database must be able to be looked up with the returned object handle."""
        self.teardown_zdb(None)
        z = self.setup_zdb()

        # householdID not important, pick whatever constants you like.
        house1 = z.createHousehold(42)
        house2 = z.createHousehold(41)
        self.assertTrue(house1 is z.getHousehold(42))
        self.assertTrue(house2 is z.getHousehold(41))
        self.assertTrue(False)
        self.teardown_zdb(z)


if __name__ == '__main__':
    unittest.main()<commit_msg>proper text fixture setup and teardown<commit_after>import unittest

from src import zdb

class zdbHouseholdTests(unittest.TestCase):

    def setUp(self):
        self.z = zdb.Zdb('secret/tests.zdb')

    def tearDown(self):
        self.z.teardown()

    def test_getInvalidHouseholdIsNone(self):
        """Test getHousehold."""
        self.assertTrue(self.z.getHousehold(None) is None, "An invalid value passed to getHousehold returns None.")
        self.assertTrue(self.z.getHousehold('invalid val') is None, "An invalid value passed to getHousehold returns None.")

    def test_addDuplicateHousehold(self):
        pass

    def test_HouseholdCreatedIsHouseholdRetrieved(self):
        """A household created in the database must be able to be looked up with the returned object handle."""

        # householdID not important, pick whatever constants you like.
        house1 = self.z.createHousehold(42)
        house2 = self.z.createHousehold(41)
        self.assertTrue(house1 is not None, "Household returned from createHousehold was None.")
        self.assertTrue(house2 is not None, "Household returned from createHousehold was None.")
        self.assertTrue(house1 is self.z.getHousehold(42))
        self.assertTrue(house2 is self.z.getHousehold(41))


if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.09550561797752809, 'fraction_numerical': 0.009129213483146067, 'mean_word_length': 3.0183356840620594, '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': '5539049', 'n_tokens_mistral': 894, 'n_tokens_neox': 846, 'n_words': 234}