[Zodb-checkins] CVS: ZODB4/Interface/Registry/tests - testImplementorRegistry.py:1.2 testAdapterRegistry.py:1.2 TestIImplementorRegistry.py:1.3 TestIAdapterRegistry.py:1.4

Jeremy Hylton jeremy@zope.com
Fri, 13 Dec 2002 17:11:17 -0500


Update of /cvs-repository/ZODB4/Interface/Registry/tests
In directory cvs.zope.org:/tmp/cvs-serv27770/Interface/Registry/tests

Modified Files:
	testImplementorRegistry.py testAdapterRegistry.py 
	TestIImplementorRegistry.py TestIAdapterRegistry.py 
Log Message:
Remove explicitly mangled names from test suite.

The test suite was using the explicitly mangled form of __new in two
different classes.  IOW, the name looked like a private variable but
wasn't being used as a private variable.  Change the name to plain old
_new.

Remove import with "as" since there is no name clash.

Explicitly inherit from unittest in order to silence many pychecker
warnings.  (pychecker doesn't understand mixins very well.)








=== ZODB4/Interface/Registry/tests/testImplementorRegistry.py 1.1 => 1.2 ===
--- ZODB4/Interface/Registry/tests/testImplementorRegistry.py:1.1	Thu Aug  1 11:33:43 2002
+++ ZODB4/Interface/Registry/tests/testImplementorRegistry.py	Fri Dec 13 17:11:17 2002
@@ -17,20 +17,17 @@
 $Id$
 """
 
-from unittest import TestCase, TestSuite, main, makeSuite
+from unittest import TestCase, main, makeSuite
 from TestIImplementorRegistry import TestIImplementorRegistry
 
 class Test(TestIImplementorRegistry, TestCase):
 
-    def _TestIImplementorRegistry__new(self):
-        from Interface.Registry.ImplementorRegistry \
-             import ImplementorRegistry as Registry
-        return Registry()
+    def _new(self):
+        from Interface.Registry.ImplementorRegistry import ImplementorRegistry
+        return ImplementorRegistry()
 
 def test_suite():
-    return TestSuite((
-        makeSuite(Test),
-        ))
+    return makeSuite(Test)
 
 if __name__=='__main__':
     main(defaultTest='test_suite')


=== ZODB4/Interface/Registry/tests/testAdapterRegistry.py 1.1 => 1.2 ===
--- ZODB4/Interface/Registry/tests/testAdapterRegistry.py:1.1	Thu Aug  1 11:33:43 2002
+++ ZODB4/Interface/Registry/tests/testAdapterRegistry.py	Fri Dec 13 17:11:17 2002
@@ -17,20 +17,17 @@
 $Id$
 """
 
-from unittest import TestCase, TestSuite, main, makeSuite
+from unittest import TestCase, main, makeSuite
 from TestIAdapterRegistry import TestIAdapterRegistry
 
 class Test(TestIAdapterRegistry, TestCase):
 
-    def _TestIAdapterRegistry__new(self):
-        from Interface.Registry.AdapterRegistry \
-             import AdapterRegistry as Registry
-        return Registry()
+    def _new(self):
+        from Interface.Registry.AdapterRegistry import AdapterRegistry
+        return AdapterRegistry()
 
 def test_suite():
-    return TestSuite((
-        makeSuite(Test),
-        ))
+    return makeSuite(Test)
 
 if __name__=='__main__':
     main(defaultTest='test_suite')


=== ZODB4/Interface/Registry/tests/TestIImplementorRegistry.py 1.2 => 1.3 ===
--- ZODB4/Interface/Registry/tests/TestIImplementorRegistry.py:1.2	Thu Aug  1 12:06:41 2002
+++ ZODB4/Interface/Registry/tests/TestIImplementorRegistry.py	Fri Dec 13 17:11:17 2002
@@ -17,6 +17,7 @@
 $Id$
 """
 
+import unittest
 from Interface import Interface
 
 class R1(Interface): pass
@@ -30,27 +31,27 @@
 class P3(P2): pass
 class P4(P3): pass
 
-class TestIImplementorRegistry:
+class TestIImplementorRegistry(unittest.TestCase):
+
+    def _new(self):
+        # subclass must define method to return registry
+        raise NotImplementedError
 
     def testImplementsIImplementorRegistry(self):
         from Interface.Verify import verifyObject
         from Interface.Registry.IImplementorRegistry \
              import IImplementorRegistry
         
-        registry = self._TestIImplementorRegistry__new()
-
+        registry = self._new()
         verifyObject(IImplementorRegistry, registry)
 
-    def __registery(self):        
-        registry = self._TestIImplementorRegistry__new()
-
+    def __registry(self):        
+        registry = self._new()
         registry.register(P3, 'C3')
-
         return registry
-        
 
     def test_get(self):
-        registry = self.__registery()
+        registry = self.__registry()
 
         for P in [P1, P2, P3]:
             self.assertEqual(registry.get(P), 'C3')
@@ -61,6 +62,5 @@
         registry.register(P2, 'C3')
         
     def testBadProvide(self):
-        registry = self.__registery()
+        registry = self.__registry()
         self.assertRaises(TypeError, registry.register, None, '')
-


=== ZODB4/Interface/Registry/tests/TestIAdapterRegistry.py 1.3 => 1.4 ===
--- ZODB4/Interface/Registry/tests/TestIAdapterRegistry.py:1.3	Mon Nov 18 15:40:17 2002
+++ ZODB4/Interface/Registry/tests/TestIAdapterRegistry.py	Fri Dec 13 17:11:17 2002
@@ -17,6 +17,8 @@
 $Id$
 """
 
+import unittest
+
 from Interface import Interface
 
 class R1(Interface): pass
@@ -30,18 +32,22 @@
 class P3(P2): pass
 class P4(P3): pass
 
-class TestIAdapterRegistry:
+class TestIAdapterRegistry(unittest.TestCase):
+
+    def _new(self):
+        # subclass should override to return registry to test
+        pass
 
     def testImplementsIAdapterRegistry(self):
         from Interface.Verify import verifyObject
         from Interface.Registry.IAdapterRegistry import IAdapterRegistry
         
-        registry = self._TestIAdapterRegistry__new()
+        registry = self._new()
 
         verifyObject(IAdapterRegistry, registry)
 
     def __registery(self):        
-        registry = self._TestIAdapterRegistry__new()
+        registry = self._new()
 
         registry.register(None, P3, 'default P3')
         registry.register(Interface, P3, 'any P3')
@@ -50,11 +56,11 @@
         return registry
 
     def testBadRequire(self):
-        registry = self._TestIAdapterRegistry__new()
+        registry = self._new()
         self.assertRaises(TypeError, registry.register, 42, P3, '')
 
     def testBadProvide(self):
-        registry = self._TestIAdapterRegistry__new()
+        registry = self._new()
         self.assertRaises(TypeError, registry.register, R2, None, '')