[Zodb-checkins] CVS: Zope3/src/zope/interface/tests - test_type.py:1.3
Jim Fulton
jim@zope.com
Wed, 29 Jan 2003 13:48:58 -0500
Update of /cvs-repository/Zope3/src/zope/interface/tests
In directory cvs.zope.org:/tmp/cvs-serv7142/tests
Modified Files:
test_type.py
Log Message:
Added an unregister method to type registries.
Also change __init__ to allow a mapping object to be passed. This
is to make it things like a persistent subclass possible.
=== Zope3/src/zope/interface/tests/test_type.py 1.2 => 1.3 ===
--- Zope3/src/zope/interface/tests/test_type.py:1.2 Wed Dec 25 09:15:12 2002
+++ Zope3/src/zope/interface/tests/test_type.py Wed Jan 29 13:48:54 2003
@@ -26,14 +26,17 @@
all.sort()
return all
-class Test(unittest.TestCase):
+class TestTypeRegistry(unittest.TestCase):
+
+ def new_instance(self):
+ return TypeRegistry()
def test(self):
class I1(Interface): pass
class I2(I1): pass
class I3(I2): pass
- reg = TypeRegistry()
+ reg = self.new_instance()
reg.register(I2, 2)
class C1: __implements__ = I1
@@ -72,6 +75,17 @@
self.assertEqual(reg.get(I2), 2)
self.assertEqual(reg.get(I3), 3)
+ reg.unregister(I3)
+
+ self.assertEqual(getAllForObject(reg, C1()), [1])
+ self.assertEqual(getAllForObject(reg, C2()), [1, 2])
+ self.assertEqual(getAllForObject(reg, C3()), [1, 2])
+ self.assertEqual(getAllForObject(reg, C()), [])
+
+ self.assertEqual(reg.get(I1), 1)
+ self.assertEqual(reg.get(I2), 2)
+ self.assertEqual(reg.get(I3), None)
+
def testSetdefault(self):
class I(Interface):
pass
@@ -111,7 +125,7 @@
def test_suite():
loader=unittest.TestLoader()
- return loader.loadTestsFromTestCase(Test)
+ return loader.loadTestsFromTestCase(TestTypeRegistry)
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())