[Zope3-checkins] CVS: Zope3/src/zope/fssync/tests - test_network.py:1.6
Guido van Rossum
guido@python.org
Wed, 28 May 2003 18:22:38 -0400
Update of /cvs-repository/Zope3/src/zope/fssync/tests
In directory cvs.zope.org:/tmp/cvs-serv7740
Modified Files:
test_network.py
Log Message:
Use an event variable to hold up the test_httpreq()'s main thread
until the server thread is listening.
=== Zope3/src/zope/fssync/tests/test_network.py 1.5 => 1.6 ===
--- Zope3/src/zope/fssync/tests/test_network.py:1.5 Wed May 28 13:52:44 2003
+++ Zope3/src/zope/fssync/tests/test_network.py Wed May 28 18:22:37 2003
@@ -43,13 +43,17 @@
"""A server that can handle one HTTP request (returning a 404 error)."""
- stopping = False
+ def __init__(self, ready):
+ self.ready = ready # Event signaling we're listening
+ self.stopping = False
+ threading.Thread.__init__(self)
def run(self):
svr = socket.socket()
svr.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
svr.bind((HOST, PORT))
svr.listen(1)
+ self.ready.set()
conn = None
sent_response = False
while not self.stopping:
@@ -153,8 +157,10 @@
self.assertEqual(new.rooturl, sample_rooturl)
def test_httpreq(self):
- svr = DummyServer()
+ ready = threading.Event()
+ svr = DummyServer(ready)
svr.start()
+ ready.wait()
try:
self.network.setrooturl("http://%s:%s" % (HOST, PORT))
self.assertRaises(Error, self.network.httpreq, "/xyzzy", "@@view")