1 | n/a | # Ridiculously simple test of the os.startfile function for Windows. |
---|
2 | n/a | # |
---|
3 | n/a | # empty.vbs is an empty file (except for a comment), which does |
---|
4 | n/a | # nothing when run with cscript or wscript. |
---|
5 | n/a | # |
---|
6 | n/a | # A possible improvement would be to have empty.vbs do something that |
---|
7 | n/a | # we can detect here, to make sure that not only the os.startfile() |
---|
8 | n/a | # call succeeded, but also the script actually has run. |
---|
9 | n/a | |
---|
10 | n/a | import unittest |
---|
11 | n/a | from test import support |
---|
12 | n/a | import os |
---|
13 | n/a | import sys |
---|
14 | n/a | from os import path |
---|
15 | n/a | |
---|
16 | n/a | startfile = support.get_attribute(os, 'startfile') |
---|
17 | n/a | |
---|
18 | n/a | |
---|
19 | n/a | class TestCase(unittest.TestCase): |
---|
20 | n/a | def test_nonexisting(self): |
---|
21 | n/a | self.assertRaises(OSError, startfile, "nonexisting.vbs") |
---|
22 | n/a | |
---|
23 | n/a | def test_empty(self): |
---|
24 | n/a | # We need to make sure the child process starts in a directory |
---|
25 | n/a | # we're not about to delete. If we're running under -j, that |
---|
26 | n/a | # means the test harness provided directory isn't a safe option. |
---|
27 | n/a | # See http://bugs.python.org/issue15526 for more details |
---|
28 | n/a | with support.change_cwd(path.dirname(sys.executable)): |
---|
29 | n/a | empty = path.join(path.dirname(__file__), "empty.vbs") |
---|
30 | n/a | startfile(empty) |
---|
31 | n/a | startfile(empty, "open") |
---|
32 | n/a | |
---|
33 | n/a | if __name__ == "__main__": |
---|
34 | n/a | unittest.main() |
---|