[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup/tests - testStarter.py:1.1.2.4

Tim Peters tim.one at comcast.net
Fri Oct 3 17:39:23 EDT 2003


Update of /cvs-repository/Zope/lib/python/Zope/Startup/tests
In directory cvs.zope.org:/tmp/cvs-serv17757/lib/python/Zope/Startup/tests

Modified Files:
      Tag: Zope-2_7-branch
	testStarter.py 
Log Message:
testMakeLockFile():  Windows lock files are more restrictive than this
test allowed for, so that the test always died with a permission error
on Win98SE.  Repaired via skipping over the first byte of the lock file
before trying to read it (lock_file(f) locks only f's first byte on
Windows).


=== Zope/lib/python/Zope/Startup/tests/testStarter.py 1.1.2.3 => 1.1.2.4 ===
--- Zope/lib/python/Zope/Startup/tests/testStarter.py:1.1.2.3	Sat Aug  2 19:19:32 2003
+++ Zope/lib/python/Zope/Startup/tests/testStarter.py	Fri Oct  3 17:39:23 2003
@@ -43,7 +43,7 @@
                            'propagate':logger.propagate,
                            'handlers':logger.handlers,
                            'filters':logger.filters}
-    
+
 class ZopeStarterTestCase(unittest.TestCase):
 
     def setUp(self):
@@ -284,13 +284,23 @@
             instancehome <<INSTANCE_HOME>>
             lock-filename %s""" % name
                                      )
-        f = open(name, 'a')
-        f.write('hello')
+        f = open(name, 'ab')
+        # On Windows, the first byte of the file is locked solid, and even
+        # we (this process) can't read from it via a file object other
+        # than the one passed to lock_file.  So we put a blank
+        # in the test value first, so we can skip over it later.  Also,
+        # because .seek(1) isn't well-defined for files opened in text
+        # mode, we open the file in binary mode (above and below).
+        f.write(' hello')
         f.close()
         try:
             starter = ZopeStarter(conf)
             starter.makeLockFile()
-            self.failIf(open(name).read().find('hello') > -1)
+            f = open(name, 'rb')
+            f.seek(1)   # skip over the locked byte
+            guts = f.read()
+            f.close()
+            self.failIf(guts.find('hello') > -1)
         finally:
             starter.unlinkLockFile()
             self.failIf(os.path.exists(name))
@@ -318,4 +328,4 @@
 
 if __name__ == "__main__":
     unittest.main(defaultTest="test_suite")
-        
+




More information about the Zope-Checkins mailing list