close files properly
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index fc84214..4347668 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -182,10 +182,12 @@
                 return a
 
         f = TestReadlineFile(tempfile.TemporaryFile("w+"))
+        self.addCleanup(f.close)
         f.write('x' * 256 * 1024)
         f.seek(0)
         env = {'REQUEST_METHOD':'PUT'}
         fs = cgi.FieldStorage(fp=f, environ=env)
+        self.addCleanup(fs.file.close)
         # if we're not chunking properly, readline is only called twice
         # (by read_binary); if we are chunking properly, it will be called 5 times
         # as long as the chunksize is 1 << 16.