[Checkins] SVN: gocept.selenium/trunk/src/gocept/selenium/zope2/__init__.py Refactor server startup for zope2 flavour
Wolfgang Schnerring
wosc at wosc.de
Sun Dec 12 05:21:22 EST 2010
Log message for revision 118815:
Refactor server startup for zope2 flavour
Although the startup code originates from Testing.ZopeTestCase.utils.startZServer(), it now doesn't have that much in common anymore that keeping its copy&paste'd form would be very helpful, so I opted to make it read more naturally instead.
Changed:
U gocept.selenium/trunk/src/gocept/selenium/zope2/__init__.py
-=-
Modified: gocept.selenium/trunk/src/gocept/selenium/zope2/__init__.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/zope2/__init__.py 2010-12-12 10:18:49 UTC (rev 118814)
+++ gocept.selenium/trunk/src/gocept/selenium/zope2/__init__.py 2010-12-12 10:21:22 UTC (rev 118815)
@@ -14,9 +14,9 @@
import Lifetime
import Testing.ZopeTestCase
+import Testing.ZopeTestCase.threadutils
import Testing.ZopeTestCase.utils
import gocept.selenium.base
-import time
try:
@@ -31,22 +31,22 @@
class Layer(gocept.selenium.base.Layer):
def setUp(self):
- self.startZServer()
- super(Layer, self).setUp()
+ # adapted from Testing.ZopeTestCase.utils.startZServer() to make
+ # host/port configurable
+ Testing.ZopeTestCase.threadutils.setNumberOfThreads(5)
+ log = None
+ thread = Testing.ZopeTestCase.threadutils.QuietThread(
+ target=Testing.ZopeTestCase.threadutils.zserverRunner,
+ args=(self.host, self.port, log))
+ thread.setDaemon(True)
+ thread.start()
- def startZServer(self):
- from Testing.ZopeTestCase.threadutils import setNumberOfThreads
- setNumberOfThreads(5)
- from Testing.ZopeTestCase.threadutils import QuietThread, zserverRunner
- t = QuietThread(
- target=zserverRunner, args=(self.host, self.port, None))
- t.setDaemon(1)
- t.start()
- time.sleep(0.1) # Sandor Palfy
-
+ # notify ZopeTestCase infrastructure that a ZServer has been started
Testing.ZopeTestCase.utils._Z2HOST = self.host
Testing.ZopeTestCase.utils._Z2PORT = self.port
+ super(Layer, self).setUp()
+
def tearDown(self):
Lifetime.shutdown(0, fast=1)
super(Layer, self).tearDown()
More information about the checkins
mailing list