[Python-checkins] cpython (3.2): Issue #15526: try to fix test_startfile's inability to clean up after itself in

antoine.pitrou python-checkins at python.org
Sun Sep 16 00:13:42 CEST 2012


http://hg.python.org/cpython/rev/bc5c5b79b7e1
changeset:   79035:bc5c5b79b7e1
branch:      3.2
parent:      79033:9794f69c1d09
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sun Sep 16 00:12:50 2012 +0200
summary:
  Issue #15526: try to fix test_startfile's inability to clean up after itself in time.
Patch by Jeremy Kloth.

files:
  Lib/test/test_startfile.py |  15 +++++++--------
  1 files changed, 7 insertions(+), 8 deletions(-)


diff --git a/Lib/test/test_startfile.py b/Lib/test/test_startfile.py
--- a/Lib/test/test_startfile.py
+++ b/Lib/test/test_startfile.py
@@ -10,8 +10,8 @@
 import unittest
 from test import support
 import os
+import sys
 from os import path
-from time import sleep
 
 startfile = support.get_attribute(os, 'startfile')
 
@@ -21,13 +21,12 @@
         self.assertRaises(OSError, startfile, "nonexisting.vbs")
 
     def test_empty(self):
-        empty = path.join(path.dirname(__file__), "empty.vbs")
-        startfile(empty)
-        startfile(empty, "open")
-        # Give the child process some time to exit before we finish.
-        # Otherwise the cleanup code will not be able to delete the cwd,
-        # because it is still in use.
-        sleep(0.1)
+        # Switch to an existing, but safe, working directory to let the
+        # cleanup code do its thing without permission errors.
+        with support.temp_cwd(path=path.dirname(sys.executable)):
+            empty = path.join(path.dirname(__file__), "empty.vbs")
+            startfile(empty)
+            startfile(empty, "open")
 
 def test_main():
     support.run_unittest(TestCase)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list