blob: ae9aeb9b6ce605fe49ed367a868d6eddb83949e0 [file] [log] [blame]
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001# 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
Benjamin Petersonee8712c2008-05-20 21:35:26 +000011from test import support
R. David Murraya21e4ca2009-03-31 23:16:50 +000012import os
Antoine Pitrou8a53dbe2012-09-16 00:12:50 +020013import sys
R. David Murraya21e4ca2009-03-31 23:16:50 +000014from os import path
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000015
R. David Murraya21e4ca2009-03-31 23:16:50 +000016startfile = support.get_attribute(os, 'startfile')
17
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000018
19class TestCase(unittest.TestCase):
20 def test_nonexisting(self):
21 self.assertRaises(OSError, startfile, "nonexisting.vbs")
22
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000023 def test_empty(self):
Antoine Pitrou8a53dbe2012-09-16 00:12:50 +020024 # Switch to an existing, but safe, working directory to let the
25 # cleanup code do its thing without permission errors.
26 with support.temp_cwd(path=path.dirname(sys.executable)):
27 empty = path.join(path.dirname(__file__), "empty.vbs")
28 startfile(empty)
29 startfile(empty, "open")
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000030
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000031def test_main():
Benjamin Petersonee8712c2008-05-20 21:35:26 +000032 support.run_unittest(TestCase)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000033
34if __name__=="__main__":
35 test_main()