[Checkins] SVN: gocept.selenium/trunk/src/gocept/selenium/static/ straightened out tests for the StaticFilesLayer
Thomas Lotze
tl at gocept.com
Tue Sep 21 03:55:21 EDT 2010
Log message for revision 116696:
straightened out tests for the StaticFilesLayer
Changed:
U gocept.selenium/trunk/src/gocept/selenium/static/__init__.py
U gocept.selenium/trunk/src/gocept/selenium/static/tests/test_static.py
-=-
Modified: gocept.selenium/trunk/src/gocept/selenium/static/__init__.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/static/__init__.py 2010-09-21 06:58:50 UTC (rev 116695)
+++ gocept.selenium/trunk/src/gocept/selenium/static/__init__.py 2010-09-21 07:55:20 UTC (rev 116696)
@@ -57,7 +57,24 @@
path = os.path.join(path, word)
return path
+ def log_request(self, *args):
+ pass
+
+class HTTPServer(BaseHTTPServer.HTTPServer):
+
+ _continue = True
+
+ def serve_until_shutdown(self):
+ while self._continue:
+ self.handle_request()
+
+ def shutdown(self):
+ self._continue = False
+ urllib.urlopen('http://%s:%s/' % (self.server_name, self.server_port))
+ self.server_close()
+
+
class StaticFilesLayer(gocept.selenium.base.Layer):
host = 'localhost'
@@ -71,9 +88,11 @@
def start_server(self):
StaticFileRequestHandler.documentroot = self.documentroot
- self.server = BaseHTTPServer.HTTPServer(
+ self.server = HTTPServer(
(self.host, self.port), StaticFileRequestHandler)
- self._server_thread = threading.Thread(target=server.serve_forever)
+ self.server_thread = threading.Thread(
+ target=self.server.serve_until_shutdown)
+ self.server_thread.start()
# Wait a little as it sometimes takes a while to get the server
# started.
time.sleep(0.25)
@@ -82,7 +101,7 @@
if self.server is None:
return
self.server.shutdown()
- self._server_thread.join()
+ self.server_thread.join()
self.server = None
def tearDown(self):
Modified: gocept.selenium/trunk/src/gocept/selenium/static/tests/test_static.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/static/tests/test_static.py 2010-09-21 06:58:50 UTC (rev 116695)
+++ gocept.selenium/trunk/src/gocept/selenium/static/tests/test_static.py 2010-09-21 07:55:20 UTC (rev 116696)
@@ -47,6 +47,6 @@
self.assert_(not os.listdir(self.testlayer.documentroot))
def test_server_startup_shutdown(self):
- self.assert_(self.testlayer.server.pid)
+ self.assert_(self.testlayer.server_thread.isAlive())
self.testlayer.stop_server()
self.assert_(not self.testlayer.server)
More information about the checkins
mailing list