[Zodb-checkins] CVS: StandaloneZODB/ZEO/tests - testStart.py:1.8

Barry Warsaw barry@wooz.org
Fri, 16 Aug 2002 14:18:33 -0400


Update of /cvs-repository/StandaloneZODB/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv9892

Modified Files:
	testStart.py 
Log Message:
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.


=== StandaloneZODB/ZEO/tests/testStart.py 1.7 => 1.8 ===
--- StandaloneZODB/ZEO/tests/testStart.py:1.7	Wed Aug 14 13:00:36 2002
+++ StandaloneZODB/ZEO/tests/testStart.py	Fri Aug 16 14:18:33 2002
@@ -18,6 +18,7 @@
 import tempfile
 import time
 import unittest
+import errno
 
 import ZEO.start
 from ZEO.ClientStorage import ClientStorage
@@ -42,13 +43,13 @@
 
 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 @@
         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()