[Checkins] SVN: gocept.selenium/trunk/ - The name of the factored test layer contains the module of the bases now. The

Christian Zagrodnick cz at gocept.com
Thu Aug 5 12:08:58 EDT 2010


Log message for revision 115503:
  - The name of the factored test layer contains the module of the bases now. The
  name is used by zope.testrunner distinguish layers. Before this fix selenium
  layers factored from base layers with the same names but in different modules
  would be considered equal by zope.testrunner.
  
  - The factored ZTK layer cleanly shuts down the http server in tearDown now.
  This allows to run different selenium layers in one go.
          
  

Changed:
  U   gocept.selenium/trunk/CHANGES.txt
  U   gocept.selenium/trunk/src/gocept/selenium/base.py
  U   gocept.selenium/trunk/src/gocept/selenium/ztk/__init__.py

-=-
Modified: gocept.selenium/trunk/CHANGES.txt
===================================================================
--- gocept.selenium/trunk/CHANGES.txt	2010-08-05 16:08:27 UTC (rev 115502)
+++ gocept.selenium/trunk/CHANGES.txt	2010-08-05 16:08:58 UTC (rev 115503)
@@ -15,7 +15,15 @@
 
 - API expansion: add ``clickAt``.
 
+- The name of the factored test layer contains the module of the bases now. The
+  name is used by zope.testrunner distinguish layers. Before this fix selenium
+  layers factored from base layers with the same names but in different modules
+  would be considered equal by zope.testrunner.
 
+- The factored ZTK layer cleanly shuts down the http server in tearDown now.
+  This allows to run different selenium layers in one go.
+
+
 0.5 (2010-08-03)
 ----------------
 

Modified: gocept.selenium/trunk/src/gocept/selenium/base.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/base.py	2010-08-05 16:08:27 UTC (rev 115502)
+++ gocept.selenium/trunk/src/gocept/selenium/base.py	2010-08-05 16:08:58 UTC (rev 115503)
@@ -33,7 +33,8 @@
 
     def __init__(self, *bases):
         self.__bases__ = bases
-        self.__name__ = '.'.join(x.__name__ for x in bases) + '.selenium'
+        self.__name__ = '[%s].selenium' % (
+            '/'.join(x.__module__ + x.__name__ for x in bases))
 
     def setUp(self):
         self.selenium = selenium.selenium(

Modified: gocept.selenium/trunk/src/gocept/selenium/ztk/__init__.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/ztk/__init__.py	2010-08-05 16:08:27 UTC (rev 115502)
+++ gocept.selenium/trunk/src/gocept/selenium/ztk/__init__.py	2010-08-05 16:08:58 UTC (rev 115503)
@@ -15,8 +15,8 @@
 from zope.server.taskthreads import ThreadedTaskDispatcher
 import gocept.selenium.base
 import gocept.selenium.selenese
+import asyncore
 import threading
-import zope.app.server.main
 import zope.app.server.wsgi
 import zope.app.testing.functional
 import zope.app.wsgi
@@ -34,12 +34,22 @@
         db = zope.app.testing.functional.FunctionalTestSetup().db
         self.http = SwitchableDBServerType.create(
             'WSGI-HTTP', task_dispatcher, db, port=self.port)
-        thread = threading.Thread(target=zope.app.server.main.run)
-        thread.setDaemon(True)
-        thread.start()
-
+        self.thread = threading.Thread(target=self.run_server)
+        self.thread.setDaemon(True)
+        self.thread.start()
         super(Layer, self).setUp()
 
+    def tearDown(self):
+        self.running = False
+        self.thread.join()
+        super(Layer, self).tearDown()
+
+    def run_server(self):
+        self.running = True
+        while self.running:
+            asyncore.poll(0.1)
+        self.http.close()
+
     def switch_db(self):
         """switches the HTTP-server's database to the currently active
         DemoStorage"""



More information about the checkins mailing list