diff Lib/test/test_subprocess.py @ 68491:141bbcb19c06 3.1

Fix the @test_NNNN_tmp file terds being left in whatever your $PWD was when test_subprocess was run.
author Gregory P. Smith <greg@krypto.org>
date Tue, 15 Mar 2011 02:04:11 -0400
parents 2b75ac7c9c12
children de5638f399a2 1579808ef25b
line wrap: on
line diff
--- a/Lib/test/test_subprocess.py	Tue Mar 15 05:18:48 2011 +0200
+++ b/Lib/test/test_subprocess.py	Tue Mar 15 02:04:11 2011 -0400
@@ -8,6 +8,7 @@
 import tempfile
 import time
 import re
+import shutil
 
 mswindows = (sys.platform == "win32")
 
@@ -450,11 +451,12 @@
         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 @@
         finally:
             for h in handles:
                 os.close(h)
+            shutil.rmtree(tmpdir)
 
     def test_list2cmdline(self):
         self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']),