Thomas Heller | 19fd857 | 2006-04-04 18:31:35 +0000 | [diff] [blame^] | 1 | # 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 | |
| 10 | import unittest |
| 11 | from test import test_support |
| 12 | import os |
| 13 | |
| 14 | |
| 15 | class 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 | |
| 32 | def test_main(): |
| 33 | test_support.run_unittest(TestCase) |
| 34 | |
| 35 | if __name__=="__main__": |
| 36 | test_main() |