]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Restore the global state of the log vars, so that test_cgi can be run twice without...
authorEzio Melotti <ezio.melotti@gmail.com>
Thu, 14 Jul 2011 12:18:57 +0000 (15:18 +0300)
committerEzio Melotti <ezio.melotti@gmail.com>
Thu, 14 Jul 2011 12:18:57 +0000 (15:18 +0300)
Lib/test/test_cgi.py

index d745199464ab68871387f84d8e9ac025dc49b18b..c42db4e70d989004e3be636e3133f2099a8f194f 100644 (file)
@@ -155,7 +155,13 @@ class CgiTests(unittest.TestCase):
             cgi.logfp = None
             cgi.logfile = "/dev/null"
             cgi.initlog("%s", "Testing log 3")
-            self.addCleanup(cgi.logfp.close)
+            def log_cleanup():
+                """Restore the global state of the log vars."""
+                cgi.logfile = ''
+                cgi.logfp.close()
+                cgi.logfp = None
+                cgi.log = cgi.initlog
+            self.addCleanup(log_cleanup)
             cgi.log("Testing log 4")
 
     def test_fieldstorage_readline(self):