source: python/trunk/Lib/test/test_startfile.py

Last change on this file was 391, checked in by dmik, 11 years ago

python: Merge vendor 2.7.6 to trunk.

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
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
10import unittest
11from test import test_support
12import os
13from os import path
14from time import sleep
15
16startfile = test_support.get_attribute(os, 'startfile')
17
18
19class TestCase(unittest.TestCase):
20 def test_nonexisting(self):
21 self.assertRaises(OSError, startfile, "nonexisting.vbs")
22
23 def test_nonexisting_u(self):
24 self.assertRaises(OSError, startfile, u"nonexisting.vbs")
25
26 def test_empty(self):
27 empty = path.join(path.dirname(__file__), "empty.vbs")
28 startfile(empty)
29 startfile(empty, "open")
30 # Give the child process some time to exit before we finish.
31 # Otherwise the cleanup code will not be able to delete the cwd,
32 # because it is still in use.
33 sleep(0.1)
34
35 def test_empty_u(self):
36 empty = path.join(path.dirname(__file__), "empty.vbs")
37 startfile(unicode(empty, "mbcs"))
38 startfile(unicode(empty, "mbcs"), "open")
39 sleep(0.1)
40
41def test_main():
42 test_support.run_unittest(TestCase)
43
44if __name__=="__main__":
45 test_main()
Note: See TracBrowser for help on using the repository browser.