[Zope3-checkins] CVS: Zope3/lib/python/Interface/Registry/tests - TestIAdapterRegistry.py:1.2 TestIImplementorRegistry.py:1.2 testTypeRegistry.py:1.2

Jim Fulton jim@zope.com
Thu, 1 Aug 2002 12:07:12 -0400


Update of /cvs-repository/Zope3/lib/python/Interface/Registry/tests
In directory cvs.zope.org:/tmp/cvs-serv10436/lib/python/Interface/Registry/tests

Modified Files:
	TestIAdapterRegistry.py TestIImplementorRegistry.py 
	testTypeRegistry.py 
Log Message:
Added type checks to registration functions to make sure interfaces
are passed where expected. A common annoying error is to pass the
module containing an interface, rather than the interface.

Interestingly, this change revealed 4 such errors in the check-in
sources. 



=== Zope3/lib/python/Interface/Registry/tests/TestIAdapterRegistry.py 1.1 => 1.2 ===
         registry.register(R2, P3, 'R2 P3')
 
         return registry
+
+    def testBadRequire(self):
+        registry = self._TestIAdapterRegistry__new()
+        self.assertRaises(TypeError, registry.register, 42, P3, '')
+
+    def testBadProvide(self):
+        registry = self._TestIAdapterRegistry__new()
+        self.assertRaises(TypeError, registry.register, R2, None, '')
         
 
     def test_get(self):


=== Zope3/lib/python/Interface/Registry/tests/TestIImplementorRegistry.py 1.1 => 1.2 ===
         registry.register(P1, 'C1')
         registry.register(P2, 'C3')
         
-        
-        
+    def testBadProvide(self):
+        registry = self.__registery()
+        self.assertRaises(TypeError, registry.register, None, '')
 


=== Zope3/lib/python/Interface/Registry/tests/testTypeRegistry.py 1.1 => 1.2 ===
         self.assertEqual(getAllForObject(reg, C5()), [1, 2, 3])
         self.assertEqual(getAllForObject(reg,  C()), [])
 
+    def testBadRequire(self):
+        registry = TypeRegistry()
+        self.assertRaises(TypeError, registry.register, 42, '')
+
 def test_suite():
     loader=unittest.TestLoader()
     return loader.loadTestsFromTestCase(Test)