From af6684f5113439ca6168551fb6389f0877cc8a9b Mon Sep 17 00:00:00 2001 From: Barry Warsaw <barry@python.org> Date: Fri, 16 Aug 2002 18:18:33 +0000 Subject: [PATCH] setUp(): Fix the calculation of the base path for the Environment constructor. It should use the start file, not the sys.executable. testLogRestart(): Fix a race condition; the child process may not have gotten around to creating the log file by the time the parent tried to open it. Use a dumb for/sleep loop. --- src/ZEO/tests/testStart.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/ZEO/tests/testStart.py b/src/ZEO/tests/testStart.py index 145a64ec..55f113f5 100644 --- a/src/ZEO/tests/testStart.py +++ b/src/ZEO/tests/testStart.py @@ -18,6 +18,7 @@ import sys import tempfile import time import unittest +import errno import ZEO.start from ZEO.ClientStorage import ClientStorage @@ -42,13 +43,13 @@ except ImportError: class StartTests(unittest.TestCase): - cmd = "%s %s" % (sys.executable, ZEO.start.__file__) - if cmd[-1] == "c": - cmd = cmd[:-1] - def setUp(self): + startfile = ZEO.start.__file__ + if startfile[-1] == 'c': + startfile = startfile[:-1] + self.env = Environment(startfile) + self.cmd = '%s %s' % (sys.executable, startfile) self.pids = {} - self.env = Environment(self.cmd) def tearDown(self): try: @@ -158,7 +159,14 @@ class StartTests(unittest.TestCase): try: outp = self.fork("-s", "-p", str(port)) self.connect(port=port) - buf1 = open(logfile1).read() + for i in range(10): + try: + buf1 = open(logfile1).read() + except IOError, e: + if e.errno != errno.ENOENT: raise + time.sleep(1) + else: + break self.assert_(buf1) os.rename(logfile1, logfile2) ppid, pid = self.getpids() -- 2.30.9