]> granicus.if.org Git - python/commitdiff
Fix the @test_NNNN_tmp file terds being left in whatever your $PWD was
authorGregory P. Smith <greg@krypto.org>
Tue, 15 Mar 2011 06:04:11 +0000 (02:04 -0400)
committerGregory P. Smith <greg@krypto.org>
Tue, 15 Mar 2011 06:04:11 +0000 (02:04 -0400)
when test_subprocess was run.

Lib/test/test_subprocess.py

index d7db802576c351467f0abc0b96f1857e5ee1fc58..c2a808c004b86bb5121a14f443946d53661179d8 100644 (file)
@@ -8,6 +8,7 @@ import errno
 import tempfile
 import time
 import re
+import shutil
 
 mswindows = (sys.platform == "win32")
 
@@ -450,11 +451,12 @@ class ProcessTestCase(BaseTestCase):
         else:
             max_handles = 2050 # too much for (at least some) Windows setups
         handles = []
+        tmpdir = tempfile.mkdtemp()
         try:
             for i in range(max_handles):
                 try:
-                    handles.append(os.open(support.TESTFN,
-                                           os.O_WRONLY | os.O_CREAT))
+                    tmpfile = os.path.join(tmpdir, support.TESTFN)
+                    handles.append(os.open(tmpfile, os.O_WRONLY|os.O_CREAT))
                 except OSError as e:
                     if e.errno != errno.EMFILE:
                         raise
@@ -479,6 +481,7 @@ class ProcessTestCase(BaseTestCase):
         finally:
             for h in handles:
                 os.close(h)
+            shutil.rmtree(tmpdir)
 
     def test_list2cmdline(self):
         self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']),