2006-04-21 07:40:58 -03:00
|
|
|
# Ridiculously simple test of the os.startfile function for Windows.
|
|
|
|
#
|
|
|
|
# empty.vbs is an empty file (except for a comment), which does
|
|
|
|
# nothing when run with cscript or wscript.
|
|
|
|
#
|
|
|
|
# A possible improvement would be to have empty.vbs do something that
|
|
|
|
# we can detect here, to make sure that not only the os.startfile()
|
2013-01-27 00:20:14 -04:00
|
|
|
# call succeeded, but also the script actually has run.
|
2006-04-21 07:40:58 -03:00
|
|
|
|
|
|
|
import unittest
|
2008-05-20 18:35:26 -03:00
|
|
|
from test import support
|
2020-08-07 12:18:38 -03:00
|
|
|
from test.support import os_helper
|
Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
........
r70734 | r.david.murray | 2009-03-30 15:04:00 -0400 (Mon, 30 Mar 2009) | 7 lines
Add import_function method to test.test_support, and modify a number of
tests that expect to be skipped if imports fail or functions don't
exist to use import_function and import_module. The ultimate goal is
to change regrtest to not skip automatically on ImportError. Checking
in now to make sure the buldbots don't show any errors on platforms
I can't direct test on.
........
r70775 | r.david.murray | 2009-03-30 19:05:48 -0400 (Mon, 30 Mar 2009) | 4 lines
Change more tests to use import_module for the modules that
should cause tests to be skipped. Also rename import_function
to the more descriptive get_attribute and add a docstring.
........
r70856 | r.david.murray | 2009-03-31 14:32:17 -0400 (Tue, 31 Mar 2009) | 7 lines
A few more test skips via import_module, and change import_module to
return the error message produced by importlib, so that if an import
in the package whose import is being wrapped is what failed the skip
message will contain the name of that module instead of the name of the
wrapped module. Also fixed formatting of some previous comments.
........
r70874 | r.david.murray | 2009-03-31 15:33:15 -0400 (Tue, 31 Mar 2009) | 5 lines
Improve test_support.import_module docstring, remove
deprecated flag from get_attribute since it isn't likely
to do anything useful.
........
r70876 | r.david.murray | 2009-03-31 15:49:15 -0400 (Tue, 31 Mar 2009) | 4 lines
Remove the regrtest check that turns any ImportError into a skipped test.
Hopefully all modules whose imports legitimately result in a skipped
test have been properly wrapped by the previous commits.
........
r70877 | r.david.murray | 2009-03-31 15:57:24 -0400 (Tue, 31 Mar 2009) | 2 lines
Add NEWS entry for regrtest change.
........
2009-03-31 20:16:50 -03:00
|
|
|
import os
|
2019-04-25 15:36:45 -03:00
|
|
|
import platform
|
2012-09-15 19:12:50 -03:00
|
|
|
import sys
|
Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
........
r70734 | r.david.murray | 2009-03-30 15:04:00 -0400 (Mon, 30 Mar 2009) | 7 lines
Add import_function method to test.test_support, and modify a number of
tests that expect to be skipped if imports fail or functions don't
exist to use import_function and import_module. The ultimate goal is
to change regrtest to not skip automatically on ImportError. Checking
in now to make sure the buldbots don't show any errors on platforms
I can't direct test on.
........
r70775 | r.david.murray | 2009-03-30 19:05:48 -0400 (Mon, 30 Mar 2009) | 4 lines
Change more tests to use import_module for the modules that
should cause tests to be skipped. Also rename import_function
to the more descriptive get_attribute and add a docstring.
........
r70856 | r.david.murray | 2009-03-31 14:32:17 -0400 (Tue, 31 Mar 2009) | 7 lines
A few more test skips via import_module, and change import_module to
return the error message produced by importlib, so that if an import
in the package whose import is being wrapped is what failed the skip
message will contain the name of that module instead of the name of the
wrapped module. Also fixed formatting of some previous comments.
........
r70874 | r.david.murray | 2009-03-31 15:33:15 -0400 (Tue, 31 Mar 2009) | 5 lines
Improve test_support.import_module docstring, remove
deprecated flag from get_attribute since it isn't likely
to do anything useful.
........
r70876 | r.david.murray | 2009-03-31 15:49:15 -0400 (Tue, 31 Mar 2009) | 4 lines
Remove the regrtest check that turns any ImportError into a skipped test.
Hopefully all modules whose imports legitimately result in a skipped
test have been properly wrapped by the previous commits.
........
r70877 | r.david.murray | 2009-03-31 15:57:24 -0400 (Tue, 31 Mar 2009) | 2 lines
Add NEWS entry for regrtest change.
........
2009-03-31 20:16:50 -03:00
|
|
|
from os import path
|
|
|
|
|
|
|
|
startfile = support.get_attribute(os, 'startfile')
|
2006-04-21 07:40:58 -03:00
|
|
|
|
|
|
|
|
|
|
|
class TestCase(unittest.TestCase):
|
|
|
|
def test_nonexisting(self):
|
|
|
|
self.assertRaises(OSError, startfile, "nonexisting.vbs")
|
|
|
|
|
2019-04-25 15:36:45 -03:00
|
|
|
@unittest.skipIf(platform.win32_is_iot(), "starting files is not supported on Windows IoT Core or nanoserver")
|
2006-04-21 07:40:58 -03:00
|
|
|
def test_empty(self):
|
2013-07-29 04:51:16 -03:00
|
|
|
# We need to make sure the child process starts in a directory
|
|
|
|
# we're not about to delete. If we're running under -j, that
|
|
|
|
# means the test harness provided directory isn't a safe option.
|
|
|
|
# See http://bugs.python.org/issue15526 for more details
|
2020-08-07 12:18:38 -03:00
|
|
|
with os_helper.change_cwd(path.dirname(sys.executable)):
|
2013-07-29 04:51:16 -03:00
|
|
|
empty = path.join(path.dirname(__file__), "empty.vbs")
|
2012-09-15 19:12:50 -03:00
|
|
|
startfile(empty)
|
2013-07-29 04:51:16 -03:00
|
|
|
startfile(empty, "open")
|
2006-04-21 07:40:58 -03:00
|
|
|
|
2015-04-13 17:00:43 -03:00
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|