1 # Ridiculously simple test of the os.startfile function for Windows.
3 # empty.vbs is an empty file (except for a comment), which does
4 # nothing when run with cscript or wscript.
6 # A possible improvement would be to have empty.vbs do something that
7 # we can detect here, to make sure that not only the os.startfile()
8 # call succeeded, but also the the script actually has run.
11 from test import test_support
14 from time import sleep
16 startfile = test_support.get_attribute(os, 'startfile')
19 class TestCase(unittest.TestCase):
20 def test_nonexisting(self):
21 self.assertRaises(OSError, startfile, "nonexisting.vbs")
23 def test_nonexisting_u(self):
24 self.assertRaises(OSError, startfile, u"nonexisting.vbs")
27 empty = path.join(path.dirname(__file__), "empty.vbs")
29 startfile(empty, "open")
30 # Give the child process some time to exit before we finish.
31 # Otherwise the cleanup code will not be able to delete the cwd,
32 # because it is still in use.
35 def test_empty_u(self):
36 empty = path.join(path.dirname(__file__), "empty.vbs")
37 startfile(unicode(empty, "mbcs"))
38 startfile(unicode(empty, "mbcs"), "open")
42 test_support.run_unittest(TestCase)
44 if __name__=="__main__":