Commit af6684f5 authored by Barry Warsaw's avatar Barry Warsaw

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.
parent 450a34ee
...@@ -18,6 +18,7 @@ import sys ...@@ -18,6 +18,7 @@ import sys
import tempfile import tempfile
import time import time
import unittest import unittest
import errno
import ZEO.start import ZEO.start
from ZEO.ClientStorage import ClientStorage from ZEO.ClientStorage import ClientStorage
...@@ -42,13 +43,13 @@ except ImportError: ...@@ -42,13 +43,13 @@ except ImportError:
class StartTests(unittest.TestCase): class StartTests(unittest.TestCase):
cmd = "%s %s" % (sys.executable, ZEO.start.__file__)
if cmd[-1] == "c":
cmd = cmd[:-1]
def setUp(self): 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.pids = {}
self.env = Environment(self.cmd)
def tearDown(self): def tearDown(self):
try: try:
...@@ -158,7 +159,14 @@ class StartTests(unittest.TestCase): ...@@ -158,7 +159,14 @@ class StartTests(unittest.TestCase):
try: try:
outp = self.fork("-s", "-p", str(port)) outp = self.fork("-s", "-p", str(port))
self.connect(port=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) self.assert_(buf1)
os.rename(logfile1, logfile2) os.rename(logfile1, logfile2)
ppid, pid = self.getpids() ppid, pid = self.getpids()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment