import unittest from ebermergen.models.auto_id import AutoID class TestAutoID(unittest.TestCase): def setUp(self): AutoID.reset_id() def test_first_instance(self): a = AutoID() self.assertEqual(a.id, 1) def test_increment(self): a, b = AutoID(), AutoID() self.assertEqual(a.id, 1) self.assertEqual(b.id, 2) def test_inheritance(self): class ClassA(AutoID): pass class ClassB(AutoID): pass a = ClassA() b = ClassB() self.assertEqual(a.id, 1) self.assertEqual(b.id, 1) a2 = ClassA() b2 = ClassB() self.assertEqual(a.id, 1) self.assertEqual(b.id, 1) self.assertEqual(a2.id, 2) self.assertEqual(b2.id, 2)