blob: 8eeae72eab47dd52113e30d28d707ede11a5b18e [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
R. David Murray59beec32009-03-30 19:04:00 +000012import os
13from os import path
Thomas Heller19fd8572006-04-04 18:31:35 +000014
R. David Murray3db8a342009-03-30 23:05:48 +000015startfile = test_support.get_attribute(os, 'startfile')
R. David Murray59beec32009-03-30 19:04:00 +000016
Thomas Heller19fd8572006-04-04 18:31:35 +000017
18class TestCase(unittest.TestCase):
19 def test_nonexisting(self):
Thomas Hellerb882f472006-04-04 18:52:27 +000020 self.assertRaises(OSError, startfile, "nonexisting.vbs")
Thomas Heller19fd8572006-04-04 18:31:35 +000021
22 def test_nonexisting_u(self):
Thomas Hellerb882f472006-04-04 18:52:27 +000023 self.assertRaises(OSError, startfile, u"nonexisting.vbs")
Thomas Heller19fd8572006-04-04 18:31:35 +000024
25 def test_empty(self):
Neal Norwitz9ad18bb2006-04-04 19:29:29 +000026 empty = path.join(path.dirname(__file__), "empty.vbs")
Thomas Hellerb882f472006-04-04 18:52:27 +000027 startfile(empty)
28 startfile(empty, "open")
Thomas Heller19fd8572006-04-04 18:31:35 +000029
30 def test_empty_u(self):
Neal Norwitz9ad18bb2006-04-04 19:29:29 +000031 empty = path.join(path.dirname(__file__), "empty.vbs")
Thomas Hellerb882f472006-04-04 18:52:27 +000032 startfile(unicode(empty, "mbcs"))
33 startfile(unicode(empty, "mbcs"), "open")
Thomas Heller19fd8572006-04-04 18:31:35 +000034
35def test_main():
36 test_support.run_unittest(TestCase)
37
38if __name__=="__main__":
39 test_main()