diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -155,6 +155,7 @@ cgi.logfp = None cgi.logfile = "/dev/null" cgi.initlog("%s", "Testing log 3") + self.addCleanup(cgi.logfp.close) cgi.log("Testing log 4") def test_fieldstorage_readline(self):