[Zodb-checkins] CVS: Zope3/src/zodb/code/tests - test_class.py:1.1.4.3

Jeremy Hylton jeremy@zope.com
Tue, 21 Jan 2003 18:11:25 -0500


Update of /cvs-repository/Zope3/src/zodb/code/tests
In directory cvs.zope.org:/tmp/cvs-serv7572/tests

Modified Files:
      Tag: new-pickle-branch
	test_class.py 
Log Message:
Add test of inheritance across persistent modules.

It seems that this provokes super() into failing, so comment out the
last line.


=== Zope3/src/zodb/code/tests/test_class.py 1.1.4.2 => 1.1.4.3 ===
--- Zope3/src/zodb/code/tests/test_class.py:1.1.4.2	Tue Jan 21 17:49:54 2003
+++ Zope3/src/zodb/code/tests/test_class.py	Tue Jan 21 18:11:22 2003
@@ -126,5 +126,36 @@
         self.assertEqual(inst2.meth(4), 7)
         self.assertEqual(Foo2().meth(4), 7)
 
+    parent1 = """class Foo:
+    def meth(self, arg):
+        return arg * 2""" "\n"
+
+    parent2 = """class Foo:
+    def meth(self, arg):
+        return arg // 2""" "\n"
+
+    child = """import parent
+    
+class Bar(parent.Foo):
+    def meth(self, arg):
+        return super(Bar, self).meth(arg) + 5""" "\n"
+
+    def testInheritanceAcrossModules(self):
+        self.registry.newModule("parent", self.parent1)
+        self.registry.newModule("child", self.child)
+        get_transaction().commit()
+        import child
+        self.assertEqual(child.Bar().meth(3), 3*2+5)
+        self.registry.updateModule("parent", self.parent2)
+        get_transaction().commit()
+        self.assertEqual(child.Bar().meth(3), 3//2+5)
+
+        # XXX somehow we get the meth() defined on parent
+        # instead of the one on child.  it looks like super
+        # isn't doing what I expect.
+        Bar = self._load_name("child.Bar")
+##        self.assertEqual(Bar().meth(3), 3//2+5)
+        
+
 def test_suite():
     return unittest.makeSuite(TestClass)