blob: 5c3d17d705b698f2c37136fd94b560d398ea0adb [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
Thomas Heller19fd8572006-04-04 18:31:35 +000012
Thomas Hellerb882f472006-04-04 18:52:27 +000013# use this form so that the test is skipped when startfile is not available:
14from os import startfile
Thomas Heller19fd8572006-04-04 18:31:35 +000015
16class TestCase(unittest.TestCase):
17 def test_nonexisting(self):
Thomas Hellerb882f472006-04-04 18:52:27 +000018 self.assertRaises(OSError, startfile, "nonexisting.vbs")
Thomas Heller19fd8572006-04-04 18:31:35 +000019
20 def test_nonexisting_u(self):
Thomas Hellerb882f472006-04-04 18:52:27 +000021 self.assertRaises(OSError, startfile, u"nonexisting.vbs")
Thomas Heller19fd8572006-04-04 18:31:35 +000022
23 def test_empty(self):
24 empty = os.path.join(os.path.dirname(__file__), "empty.vbs")
Thomas Hellerb882f472006-04-04 18:52:27 +000025 startfile(empty)
26 startfile(empty, "open")
Thomas Heller19fd8572006-04-04 18:31:35 +000027
28 def test_empty_u(self):
29 empty = os.path.join(os.path.dirname(__file__), "empty.vbs")
Thomas Hellerb882f472006-04-04 18:52:27 +000030 startfile(unicode(empty, "mbcs"))
31 startfile(unicode(empty, "mbcs"), "open")
Thomas Heller19fd8572006-04-04 18:31:35 +000032
33def test_main():
34 test_support.run_unittest(TestCase)
35
36if __name__=="__main__":
37 test_main()