aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_startfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_startfile.py')
-rw-r--r--Lib/test/test_startfile.py30
1 files changed, 10 insertions, 20 deletions
diff --git a/Lib/test/test_startfile.py b/Lib/test/test_startfile.py
index 9dce8fd6acb..ae9aeb9b6ce 100644
--- a/Lib/test/test_startfile.py
+++ b/Lib/test/test_startfile.py
@@ -8,38 +8,28 @@
# call succeeded, but also the the script actually has run.
import unittest
-from test import test_support
+from test import support
import os
+import sys
from os import path
-from time import sleep
-startfile = test_support.get_attribute(os, 'startfile')
+startfile = support.get_attribute(os, 'startfile')
class TestCase(unittest.TestCase):
def test_nonexisting(self):
self.assertRaises(OSError, startfile, "nonexisting.vbs")
- def test_nonexisting_u(self):
- self.assertRaises(OSError, startfile, u"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)
-
- def test_empty_u(self):
- empty = path.join(path.dirname(__file__), "empty.vbs")
- startfile(unicode(empty, "mbcs"))
- startfile(unicode(empty, "mbcs"), "open")
- 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():
- test_support.run_unittest(TestCase)
+ support.run_unittest(TestCase)
if __name__=="__main__":
test_main()