[Zope3-checkins] CVS: Zope3/src/zodb/storage/tests - test_file.py:1.2.4.1

Jeremy Hylton jeremy@zope.com
Thu, 23 Jan 2003 13:06:03 -0500


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

Modified Files:
      Tag: new-pickle-branch
	test_file.py 
Log Message:
When each file storage test finishes, check _read_index().
Also, reformat the big import statement.


=== Zope3/src/zodb/storage/tests/test_file.py 1.2 => 1.2.4.1 ===
--- Zope3/src/zodb/storage/tests/test_file.py:1.2	Wed Dec 25 09:12:20 2002
+++ Zope3/src/zodb/storage/tests/test_file.py	Thu Jan 23 13:06:00 2003
@@ -17,12 +17,10 @@
 from zodb.ztransaction import Transaction
 from zodb import interfaces
 
-from zodb.storage.tests import base, basic, \
-     undo, version, \
-     undoversion, packable, \
-     synchronization, conflict, history, \
-     iterator, corruption, revision, persistent, \
-     mt, readonly, recovery
+from zodb.storage.tests import base, basic, conflict, corruption, history, \
+     iterator, mt, packable, persistent, readonly, recovery, revision, \
+     synchronization, undo, undoversion, version
+
 from zodb.storage.tests.base import MinPO, zodb_unpickle
 
 class FileStorageTests(
@@ -53,9 +51,27 @@
         self.open(create=1)
 
     def tearDown(self):
+        self._test_read_index()
         self._storage.close()
         base.removefs("FileStorageTests.fs")
 
+    def _test_read_index(self):
+        # For each test, open a read-only copy and make sure that
+        # reading the index file results in the same storage-internal
+        # state.
+        try:
+            copy = zodb.storage.file.FileStorage('FileStorageTests.fs',
+                                                 read_only=True)
+        except:
+            from zodb.storage.fsdump import Dumper
+            Dumper("FileStorageTests.fs").dump()
+            raise
+        
+        L1 = copy._index.items()
+        L2 = self._storage._index.items()
+        L1.sort(); L2.sort()
+        self.assertEqual(L1, L2)
+
     def checkLongMetadata(self):
         s = "X" * 75000
         try:
@@ -71,10 +87,7 @@
         else:
             self.fail("expect long user field to raise error")
 
-class FileStorageRecoveryTest(
-    base.StorageTestBase,
-    recovery.RecoveryStorage,
-    ):
+class FileStorageRecoveryTest(base.StorageTestBase, recovery.RecoveryStorage):
 
     def setUp(self):
         base.removefs("Source.fs")