[Zope3-checkins] SVN: Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/ - work-around problem with closing ZODB connections from a different thread

Benji York benji at zope.com
Sun Jul 30 15:06:58 EDT 2006


Log message for revision 69303:
   - work-around problem with closing ZODB connections from a different thread 
   - fix problem with functional test being seen as a unit test (strange)
  

Changed:
  U   Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/proxy.py
  U   Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/tests.py

-=-
Modified: Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/proxy.py
===================================================================
--- Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/proxy.py	2006-07-30 18:18:05 UTC (rev 69302)
+++ Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/proxy.py	2006-07-30 19:06:57 UTC (rev 69303)
@@ -1,3 +1,6 @@
+from StringIO import StringIO
+from zope.app.testing import functional
+from zope.app.testing.functional import FunctionalTestSetup
 import BaseHTTPServer
 import Queue
 import SocketServer
@@ -9,8 +12,6 @@
 import socket
 import threading
 import urlparse
-from zope.app.testing import functional
-from StringIO import StringIO
 
 base_dir = os.path.dirname(__file__)
 allowed_resources = ['MochiKit', 'shim.js', 'commands.js', 'start.html']
@@ -144,7 +145,17 @@
         self.result_queue = Queue.Queue()
         self.threads = []
         BaseHTTPServer.HTTPServer.__init__(self, *args, **kws)
+        self.setUp()
 
+    def setUp(test):
+        # FunctionalTestSetup is a borg and creates a ZODB connection lazily
+        # (when getRootFolder is called), but that happens in another thread.
+        # That's only a problem because the functional test cleanup happens
+        # in _this_ thread.  Closing a connection from a different thread
+        # makes ZODB unhappy, so we force the connection to be created now,
+        # in the thread that will eventually clean it up.
+        FunctionalTestSetup().getRootFolder()
+
     def serve_forever(self):
         """Handle one request at a time until stopped."""
         while not self.stop:

Modified: Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/tests.py
===================================================================
--- Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/tests.py	2006-07-30 18:18:05 UTC (rev 69302)
+++ Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/tests.py	2006-07-30 19:06:57 UTC (rev 69303)
@@ -23,7 +23,7 @@
     flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
     real = FunctionalDocFileSuite('real.txt', optionflags=flags)
     real.level = 2
-    return unittest.TestSuite((real))
+    return unittest.TestSuite((real,))
 
 if __name__ == '__main__':
     unittest.main(defaultTest='test_suite')



More information about the Zope3-Checkins mailing list