Issue #15526: try to fix test_startfile's inability to clean up after itself in time.

Patch by Jeremy Kloth.
This commit is contained in:
Antoine Pitrou 2012-09-16 00:13:10 +02:00
commit 07085332cf
1 changed files with 7 additions and 8 deletions

View File

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