[Checkins] SVN: z3c.testing/trunk/src/z3c/testing/ now really fix the file closed bug, by replacing the close method of storage instance used

Bernd Dorn bernd.dorn at lovelysystems.com
Wed May 30 06:00:51 EDT 2007


Log message for revision 75993:
  now really fix the file closed bug, by replacing the close method of storage instance used

Changed:
  U   z3c.testing/trunk/src/z3c/testing/ftests.py
  U   z3c.testing/trunk/src/z3c/testing/layer.py

-=-
Modified: z3c.testing/trunk/src/z3c/testing/ftests.py
===================================================================
--- z3c.testing/trunk/src/z3c/testing/ftests.py	2007-05-30 07:17:46 UTC (rev 75992)
+++ z3c.testing/trunk/src/z3c/testing/ftests.py	2007-05-30 10:00:50 UTC (rev 75993)
@@ -15,11 +15,13 @@
     suite = unittest.TestSuite()
     suites = (
         functional.FunctionalDocFileSuite('BROWSER.txt'),
+        # test setup/teardown by calling it twice
+        functional.FunctionalDocFileSuite('BROWSER.txt'),
         )
     for s in suites:
         s.layer=MyLayer
         suite.addTest(s)
-        return suite
+    return suite
 
 if __name__ == '__main__':
     unittest.main(defaultTest='test_suite')

Modified: z3c.testing/trunk/src/z3c/testing/layer.py
===================================================================
--- z3c.testing/trunk/src/z3c/testing/layer.py	2007-05-30 07:17:46 UTC (rev 75992)
+++ z3c.testing/trunk/src/z3c/testing/layer.py	2007-05-30 10:00:50 UTC (rev 75993)
@@ -75,18 +75,26 @@
             connection.close()
             db.close()
 
+        # sets up the db stuff normal
+        fsetup.setUp()
+        # replace the storage with our filestorage
         fsetup.base_storage = FileStorage(filename)
-        #hm, somehow the setup closes the database, but we dont want
-        #this.
-        #fsetup.setUp()
+        # override close on this instance, so files dont get closed on
+        # setup/teardown of functionsetup
+        fsetup.base_storage.close = lambda : None
 
     def tearDown(self):
         fsetup = functional.FunctionalTestSetup(self.config_file)
-        fsetup.base_storage.close()
+        # close the filestorage files now by calling the original
+        # close on our storage instance
+        FileStorage.close(fsetup.base_storage)
+        # replace the storage with the original, so functionalsetup
+        # can do what it wants with it
         fsetup.base_storage = self.original
         fsetup.tearDown()
         fsetup.tearDownCompletely()
 
+
 def defineLayer(name, zcml=None, appSetUp=None, clean=False):
     """Helper function for defining layers.
 



More information about the Checkins mailing list