Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_startfile.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | f4c5e3a64be2 |
| children | 84272228d7db |
| rev | line source |
|---|---|
|
37478
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
1 # Ridiculously simple test of the os.startfile function for Windows. |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
2 # |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
3 # empty.vbs is an empty file (except for a comment), which does |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
4 # nothing when run with cscript or wscript. |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
5 # |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
6 # A possible improvement would be to have empty.vbs do something that |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
7 # we can detect here, to make sure that not only the os.startfile() |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
8 # call succeeded, but also the the script actually has run. |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
9 |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
10 import unittest |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
11 from test import test_support |
|
52456
f2c90fd05d66
Add import_function method to test.test_support, and modify a number of
R. David Murray <rdmurray@bitdance.com>
parents:
37485
diff
changeset
|
12 import os |
|
f2c90fd05d66
Add import_function method to test.test_support, and modify a number of
R. David Murray <rdmurray@bitdance.com>
parents:
37485
diff
changeset
|
13 from os import path |
|
37478
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
14 |
|
52491
f4c5e3a64be2
Change more tests to use import_module for the modules that
R. David Murray <rdmurray@bitdance.com>
parents:
52456
diff
changeset
|
15 startfile = test_support.get_attribute(os, 'startfile') |
|
52456
f2c90fd05d66
Add import_function method to test.test_support, and modify a number of
R. David Murray <rdmurray@bitdance.com>
parents:
37485
diff
changeset
|
16 |
|
37478
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
17 |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
18 class TestCase(unittest.TestCase): |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
19 def test_nonexisting(self): |
|
37480
d6ecba596e1e
Change the import statement so that the test is skipped when
Thomas Heller <theller@ctypes.org>
parents:
37478
diff
changeset
|
20 self.assertRaises(OSError, startfile, "nonexisting.vbs") |
|
37478
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
21 |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
22 def test_nonexisting_u(self): |
|
37480
d6ecba596e1e
Change the import statement so that the test is skipped when
Thomas Heller <theller@ctypes.org>
parents:
37478
diff
changeset
|
23 self.assertRaises(OSError, startfile, u"nonexisting.vbs") |
|
37478
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
24 |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
25 def test_empty(self): |
|
37485
896f9fead17e
we need os.path too for the normal run on windows
Neal Norwitz <nnorwitz@gmail.com>
parents:
37480
diff
changeset
|
26 empty = path.join(path.dirname(__file__), "empty.vbs") |
|
37480
d6ecba596e1e
Change the import statement so that the test is skipped when
Thomas Heller <theller@ctypes.org>
parents:
37478
diff
changeset
|
27 startfile(empty) |
|
d6ecba596e1e
Change the import statement so that the test is skipped when
Thomas Heller <theller@ctypes.org>
parents:
37478
diff
changeset
|
28 startfile(empty, "open") |
|
37478
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
29 |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
30 def test_empty_u(self): |
|
37485
896f9fead17e
we need os.path too for the normal run on windows
Neal Norwitz <nnorwitz@gmail.com>
parents:
37480
diff
changeset
|
31 empty = path.join(path.dirname(__file__), "empty.vbs") |
|
37480
d6ecba596e1e
Change the import statement so that the test is skipped when
Thomas Heller <theller@ctypes.org>
parents:
37478
diff
changeset
|
32 startfile(unicode(empty, "mbcs")) |
|
d6ecba596e1e
Change the import statement so that the test is skipped when
Thomas Heller <theller@ctypes.org>
parents:
37478
diff
changeset
|
33 startfile(unicode(empty, "mbcs"), "open") |
|
37478
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
34 |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
35 def test_main(): |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
36 test_support.run_unittest(TestCase) |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
37 |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
38 if __name__=="__main__": |
|
852f1c1a89b4
Add a simple test for os.startfile().
Thomas Heller <theller@ctypes.org>
parents:
diff
changeset
|
39 test_main() |
