blob: 2b198e4a441951b869fc733bc1b116df0ca1f8c1 [file] [log] [blame]
Thomas Heller19fd8572006-04-04 18:31:35 +00001# Ridiculously simple test of the os.startfile function for Windows.
2#
3# empty.vbs is an empty file (except for a comment), which does
4# nothing when run with cscript or wscript.
5#
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.
9
10import unittest
11from test import test_support
12import os
13
14
15class TestCase(unittest.TestCase):
16 def test_nonexisting(self):
17 self.assertRaises(OSError, os.startfile, "nonexisting.vbs")
18
19 def test_nonexisting_u(self):
20 self.assertRaises(OSError, os.startfile, u"nonexisting.vbs")
21
22 def test_empty(self):
23 empty = os.path.join(os.path.dirname(__file__), "empty.vbs")
24 os.startfile(empty)
25 os.startfile(empty, "open")
26
27 def test_empty_u(self):
28 empty = os.path.join(os.path.dirname(__file__), "empty.vbs")
29 os.startfile(unicode(empty, "mbcs"))
30 os.startfile(unicode(empty, "mbcs"), "open")
31
32def test_main():
33 test_support.run_unittest(TestCase)
34
35if __name__=="__main__":
36 test_main()