[Zodb-checkins] CVS: Zope3/lib/python/Persistence/tests - testPersistence.py:1.1.2.8

Jeremy Hylton jeremy@zope.com
Tue, 4 Jun 2002 14:24:44 -0400


Update of /cvs-repository/Zope3/lib/python/Persistence/tests
In directory cvs.zope.org:/tmp/cvs-serv20190

Modified Files:
      Tag: Zope-3x-branch
	testPersistence.py 
Log Message:
Special case the two tests that can't work for BasePersistent using
the has_dict attribute of the concrete test case class.


=== Zope3/lib/python/Persistence/tests/testPersistence.py 1.1.2.7 => 1.1.2.8 ===
     klass = None # override in subclass
 
-    def testUnsaved(self):
-        p = self.klass()
-        
-        self.assertEqual(p.x, 0)
-        self.assertEqual(p._p_changed, 0)
-        self.assertEqual(p._p_jar, None)
-        self.assertEqual(p._p_oid, None)
-        self.assertEqual(p._p_serial, None)
-        p.inc()
-        p.inc()
-        self.assertEqual(p.x, 2)
-        self.assertEqual(p._p_changed, 0)
-
-        p._p_deactivate()
-        self.assertEqual(p._p_changed, 0)
-        p._p_changed = 1
-        self.assertEqual(p._p_changed, 0)
-        p._p_changed = None
-        self.assertEqual(p._p_changed, 0)
-        del p._p_changed
-        self.assertEqual(p._p_changed, 0)
-        self.failUnless(p.__dict__)
-        self.assertEqual(p.x, 2)
-
     def testSaved(self):
         p = self.klass()
         p._p_oid = '\0\0\0\0\0\0hi'
@@ -79,13 +55,39 @@
         self.assertEqual(p._p_changed, 1)
         self.assertEqual(dm.called, 3)
 
+    def testUnsaved(self):
+        p = self.klass()
+        
+        self.assertEqual(p.x, 0)
+        self.assertEqual(p._p_changed, 0)
+        self.assertEqual(p._p_jar, None)
+        self.assertEqual(p._p_oid, None)
+        self.assertEqual(p._p_serial, None)
+        p.inc()
+        p.inc()
+        self.assertEqual(p.x, 2)
+        self.assertEqual(p._p_changed, 0)
+
+        p._p_deactivate()
+        self.assertEqual(p._p_changed, 0)
+        p._p_changed = 1
+        self.assertEqual(p._p_changed, 0)
+        p._p_changed = None
+        self.assertEqual(p._p_changed, 0)
+        del p._p_changed
+        self.assertEqual(p._p_changed, 0)
+        if self.has_dict:
+            self.failUnless(p.__dict__)
+        self.assertEqual(p.x, 2)
+
     def testState(self):
         p = self.klass()
         self.assertEqual(p.__getstate__(), {'x': 0})
         self.assertEqual(p._p_changed, 0)
         p.__setstate__({'x':5})
         self.assertEqual(p._p_changed, 0)
-        p._v_foo = 2
+        if self.has_dict:
+            p._v_foo = 2
         self.assertEqual(p.__getstate__(), {'x': 5})
         self.assertEqual(p._p_changed, 0)
 
@@ -146,9 +148,11 @@
 
 class PersistentTest(Test):
     klass = P
+    has_dict = 1
 
 class BasePersistentTest(Test):
     klass = B
+    has_dict = 0
 
 # XXX should test BasePersistent, too