[Zodb-checkins] CVS: Zope3/src/zodb/code/tests - atestmodule.py:1.2.4.1 test_patch.py:1.2.4.1

Jeremy Hylton jeremy@zope.com
Fri, 24 Jan 2003 13:21:32 -0500


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

Modified Files:
      Tag: new-pickle-branch
	atestmodule.py test_patch.py 
Log Message:
Make sure patch preserves object identity by using the pickle memo.


=== Zope3/src/zodb/code/tests/atestmodule.py 1.2 => 1.2.4.1 ===
--- Zope3/src/zodb/code/tests/atestmodule.py:1.2	Wed Dec 25 09:12:18 2002
+++ Zope3/src/zodb/code/tests/atestmodule.py	Fri Jan 24 13:21:29 2003
@@ -13,6 +13,9 @@
         def bar(self):
             return 1
 
+# put aFunc inside a function to be sure it is found
+foo = (aFunc,)
+
 class Bar:
     def bar(self, x):
         return 2 * x
@@ -21,6 +24,9 @@
     alias = aFunc
 
     classbar = classmethod(bar)
+
+class Sub(Bar):
+    pass
 
 def anotherFunc():
     class NotFound:


=== Zope3/src/zodb/code/tests/test_patch.py 1.2 => 1.2.4.1 ===
--- Zope3/src/zodb/code/tests/test_patch.py:1.2	Wed Dec 25 09:12:18 2002
+++ Zope3/src/zodb/code/tests/test_patch.py	Fri Jan 24 13:21:29 2003
@@ -18,6 +18,10 @@
 class TestPatch(unittest.TestCase):
 
     def testPatch(self):
+        # verify obvious facts of object identity
+        self.assert_(atestmodule.Bar is atestmodule.Sub.__bases__[0])
+        self.assert_(atestmodule.aFunc is atestmodule.foo[0])
+        
         moddict = atestmodule.__dict__
         convert(atestmodule, {})
         newdict = atestmodule.__dict__
@@ -29,6 +33,14 @@
         self.assertEqual(L1, L2)
 
         self.assertEqual(atestmodule.__dict__, atestmodule.aFunc.func_globals)
+
+        # make sure object identity is maintained by patch
+        Bar = newdict["Bar"]
+        Bar_as_base = newdict["Sub"].__bases__[0]
+        self.assert_(Bar is Bar_as_base)
+
+        self.assert_(newdict["aFunc"] is newdict["foo"][0])
+
 
 def test_suite():
     s = unittest.TestSuite()