summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_startfile.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-09-15 22:12:50 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-09-15 22:12:50 (GMT)
commit8a53dbeb7a9d0ae3e446f36e56cf9acfabe443c1 (patch)
tree6ae13d21a35656945f6ae95ae0ab8fe4eebc1939 /Lib/test/test_startfile.py
parent186d5238eaa2edfa97b1a160ee218400ebe6ff47 (diff)
downloadcpython-8a53dbeb7a9d0ae3e446f36e56cf9acfabe443c1.zip
cpython-8a53dbeb7a9d0ae3e446f36e56cf9acfabe443c1.tar.gz
cpython-8a53dbeb7a9d0ae3e446f36e56cf9acfabe443c1.tar.bz2
Issue #15526: try to fix test_startfile's inability to clean up after itself in time.
Patch by Jeremy Kloth.
Diffstat (limited to 'Lib/test/test_startfile.py')
-rw-r--r--Lib/test/test_startfile.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/test/test_startfile.py b/Lib/test/test_startfile.py
index dd505bf..ae9aeb9 100644
--- 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 @@ class TestCase(unittest.TestCase):
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)