[Zodb-checkins] CVS: Zope3/lib/python/ZODB/tests - testZODB.py:1.1.86.3

Jeremy Hylton jeremy@zope.com
Sun, 10 Mar 2002 16:25:28 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	testZODB.py 
Log Message:
A little housekeeping.

Replace assert stmt w/ assert_() method.
Make long method into three shorter ones.



=== Zope3/lib/python/ZODB/tests/testZODB.py 1.1.86.2 => 1.1.86.3 ===
 
 class ExportImportTests:
-    def checkDuplicate(self, abort_it=0, dup_name='test_duplicate'):
-        get_transaction().begin()
-        get_transaction().note('duplication')
-        # Duplicate the 'test' object.
+
+    def duplicate(self, abort_it, dup_name):
         conn = self._db.open()
         try:
             root = conn.root()
             ob = root['test']
-            assert len(ob) > 10, 'Insufficient test data'
+            self.assert_(len(ob) > 10, 'Insufficient test data')
             try:
                 import tempfile
                 f = tempfile.TemporaryFile()
                 ob._p_jar.exportFile(ob._p_oid, f)
-                assert f.tell() > 0, 'Did not export correctly'
+                self.assert_(f.tell() > 0, 'Did not export correctly')
                 f.seek(0)
                 new_ob = ob._p_jar.importFile(f)
                 root[dup_name] = new_ob
@@ -33,6 +31,8 @@
                 raise
         finally:
             conn.close()
+
+    def verify(self, abort_it, dup_name):
         get_transaction().begin()
         # Verify the duplicate.
         conn = self._db.open()
@@ -68,16 +68,23 @@
             get_transaction().commit()
         finally:
             conn.close()
+    
+    def checkDuplicate(self, abort_it=0, dup_name='test_duplicate'):
+        get_transaction().begin()
+        get_transaction().note('duplication')
+        self.duplicate(abort_it, dup_name)
+        self.verify(abort_it, dup_name)
 
     def checkDuplicateAborted(self):
         self.checkDuplicate(abort_it=1, dup_name='test_duplicate_aborted')
-    
 
 class ZODBTests(unittest.TestCase, ExportImportTests):
 
     def setUp(self):
-        try: os.remove('ZODBTests.fs')
-        except: pass
+        try:
+            os.remove('ZODBTests.fs')
+        except:
+            pass
         self._storage = ZODB.FileStorage.FileStorage(
             'ZODBTests.fs', create=1)
         self._db = ZODB.DB(self._storage)
@@ -93,7 +100,10 @@
 
     def tearDown(self):
         self._storage.close()
-        os.remove('ZODBTests.fs')
+        for ext in '', '.old', '.tmp', '.lock', '.index':
+            path = 'ZODBTests.fs' + ext
+            if os.path.exists(path):
+                os.remove(path)
 
 def test_suite():
     return unittest.makeSuite(ZODBTests, 'check')
@@ -102,13 +112,6 @@
     alltests=test_suite()
     runner = unittest.TextTestRunner()
     runner.run(alltests)
-
-def debug():
-   test_suite().debug()
-
-def pdebug():
-    import pdb
-    pdb.run('debug()')
 
 if __name__=='__main__':
    if len(sys.argv) > 1: