def test_011_add_none(self): r = SubclassRegistry() r.add('jsoner.tests.test_registry.DummyObject', None) self.assertEqual(r.get('jsoner.tests.test_registry.DummyObject2'), None)
def test_000_get_subclass_of_class(self): class A: pass class B(A): pass r = SubclassRegistry() r.add(A, 42) self.assertEqual(r.get(A), 42) self.assertEqual(r.get(B), 42)
def test_001_get_subclass_of_object(self): class A: pass class B(A): pass r = SubclassRegistry() r.add(A, 42) a = A() b = B() self.assertEqual(r.get(a), 42) self.assertEqual(r.get(b), 42)
def test_015_contains(self): r = SubclassRegistry() self.assertNotIn(DummyObject2, r)
def test_014_contains(self): r = SubclassRegistry() r.add(DummyObject, 42) self.assertIn(DummyObject2, r)
def test_012_contains(self): r = SubclassRegistry() r.add('jsoner.tests.test_registry.DummyObject', None) self.assertIn('jsoner.tests.test_registry.DummyObject', r)
def test_009_load_from_str(self): r = SubclassRegistry() r.add('jsoner.tests.test_registry.DummyObject', 42) self.assertEqual(r.get('jsoner.tests.test_registry.DummyObject2'), 42)
def test_010_add_none(self): r = SubclassRegistry() r.add('foo', None) self.assertEqual(r.get('foo'), None)
def test_007_add_integer_as_key(self): r = SubclassRegistry() r.add(42, 'foo') self.assertEqual(r.get(42), 'foo') self.assertIsNone(r.get(DummyObject))
def test_008_pass_list(self): r = SubclassRegistry() self.assertEqual(r.get((1, 2, 3)), None) self.assertIsNone(r.get(DummyObject))
def test_006_not_existing_module(self): r = SubclassRegistry() r.add('foo.bar', 42) self.assertEqual(r.get('foo.bar'), 42) self.assertIsNone(r.get(DummyObject))
def test_005_register_normal_string(self): r = SubclassRegistry() self.assertEqual(r.get('abc'), None)
def test_004_register_normal_string(self): r = SubclassRegistry() r.add('abc', 42) self.assertEqual(r.get('abc'), 42)
def test_003_register_as_type_and_get_as_string(self): r = SubclassRegistry() r.add(DummyObject, 42) self.assertEqual(r.get('jsoner.tests.test_registry.DummyObject'), 42)
def test_002_register_as_string(self): r = SubclassRegistry() r.add('jsoner.tests.test_registry.DummyObject', 42) self.assertEqual(r.get(DummyObject), 42)