Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_startfile.py @ 78069:a8aa77458e12 3.2
Add c_size_t and c_ssize_t to the ctypes summary table.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 12 Jul 2012 20:31:50 +0200 |
| parents | 8b7b3748f876 |
| children | bc5c5b79b7e1 |
| rev | line source |
|---|---|
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1 # Ridiculously simple test of the os.startfile function for Windows. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2 # |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
3 # empty.vbs is an empty file (except for a comment), which does |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
4 # nothing when run with cscript or wscript. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
5 # |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
6 # A possible improvement would be to have empty.vbs do something that |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
7 # we can detect here, to make sure that not only the os.startfile() |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
8 # call succeeded, but also the the script actually has run. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
9 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
10 import unittest |
|
47201
9c930a32cebb
#2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents:
43130
diff
changeset
|
11 from test import support |
|
52625
f84340886936
Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
R. David Murray <rdmurray@bitdance.com>
parents:
47201
diff
changeset
|
12 import os |
|
f84340886936
Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
R. David Murray <rdmurray@bitdance.com>
parents:
47201
diff
changeset
|
13 from os import path |
|
69433
8b7b3748f876
Fix sporadic failure in test_startfile.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
52625
diff
changeset
|
14 from time import sleep |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
15 |
|
52625
f84340886936
Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
R. David Murray <rdmurray@bitdance.com>
parents:
47201
diff
changeset
|
16 startfile = support.get_attribute(os, 'startfile') |
|
f84340886936
Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
R. David Murray <rdmurray@bitdance.com>
parents:
47201
diff
changeset
|
17 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
18 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
19 class TestCase(unittest.TestCase): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
20 def test_nonexisting(self): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
21 self.assertRaises(OSError, startfile, "nonexisting.vbs") |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
22 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
23 def test_empty(self): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
24 empty = path.join(path.dirname(__file__), "empty.vbs") |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
25 startfile(empty) |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
26 startfile(empty, "open") |
|
69433
8b7b3748f876
Fix sporadic failure in test_startfile.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
52625
diff
changeset
|
27 # Give the child process some time to exit before we finish. |
|
8b7b3748f876
Fix sporadic failure in test_startfile.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
52625
diff
changeset
|
28 # Otherwise the cleanup code will not be able to delete the cwd, |
|
8b7b3748f876
Fix sporadic failure in test_startfile.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
52625
diff
changeset
|
29 # because it is still in use. |
|
8b7b3748f876
Fix sporadic failure in test_startfile.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
52625
diff
changeset
|
30 sleep(0.1) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
31 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
32 def test_main(): |
|
47201
9c930a32cebb
#2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents:
43130
diff
changeset
|
33 support.run_unittest(TestCase) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
34 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
35 if __name__=="__main__": |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
36 test_main() |
