[Zope-Checkins] CVS: ZODB3/zLOG/tests - testzLog.py:1.12.32.1

Tim Peters tim.one at comcast.net
Mon Sep 15 11:45:29 EDT 2003


Update of /cvs-repository/ZODB3/zLOG/tests
In directory cvs.zope.org:/tmp/cvs-serv21236/zLOG/tests

Modified Files:
      Tag: ZODB3-3_2-branch
	testzLog.py 
Log Message:
All the tests in this file leave their logs behind on Windows, because
you can't delete an open file on Windows.  Changed the tests so at
least they close their own handles on these files.  The files still don't
get deleted, though, presumably because the logging module also still
has them open.  I don't know how to tell it to close its file(s).


=== ZODB3/zLOG/tests/testzLog.py 1.12 => 1.12.32.1 ===
--- ZODB3/zLOG/tests/testzLog.py:1.12	Sun Nov 24 00:24:43 2002
+++ ZODB3/zLOG/tests/testzLog.py	Mon Sep 15 11:45:29 2003
@@ -54,7 +54,11 @@
     def tearDown(self):
         try:
             os.remove(self.path)
-        except os.error:
+        except:
+            # XXX We shouldn't hide the error.  On Windows this in fact
+            # XXX leaves the log file behind, because the logging module
+            # XXX still has it open, and you can't delete an open file
+            # XXX on Windows.
             pass
         self.wipeEnvironment()
 
@@ -111,14 +115,20 @@
         self.setLog()
         zLOG.LOG("basic", zLOG.INFO, "summary")
         f = self.getLogFile()
-        self.verifyEntry(f, subsys="basic", summary="summary")
+        try:
+            self.verifyEntry(f, subsys="basic", summary="summary")
+        finally:
+            f.close()
 
     def checkDetail(self):
         self.setLog()
         zLOG.LOG("basic", zLOG.INFO, "xxx", "this is a detail")
 
         f = self.getLogFile()
-        self.verifyEntry(f, subsys="basic", detail="detail")
+        try:
+            self.verifyEntry(f, subsys="basic", detail="detail")
+        finally:
+            f.close()
 
     def checkError(self):
         self.setLog()
@@ -131,9 +141,13 @@
         zLOG.LOG("basic", zLOG.ERROR, "raised exception", error=err)
 
         f = self.getLogFile()
-        self.verifyEntry(f, subsys="basic", summary="summary")
-        self.verifyEntry(f, subsys="basic", severity=zLOG.ERROR,
-                         error=err)
+        try:
+            self.verifyEntry(f, subsys="basic", summary="summary")
+            self.verifyEntry(f, subsys="basic", severity=zLOG.ERROR,
+                             error=err)
+        finally:
+            f.close()
+
 
 class EventLogTest(StupidLogTest):
     """ Test alternate envvars EVENT_LOG_FILE and EVENT_LOG_SEVERITY """




More information about the Zope-Checkins mailing list