Commit 752d4b75 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-25094: Fix test_tools.test_sundry() on Windows (GH-8406)

When Python is installed on Windows, python -m test test_tools failed
because it tried to run Tools\scripts\2to3.py which requires an
argument. Skip this script. On other platforms or on Windows but when
run from source code (not installed), the script is called "2to3"
instead of "2to.py" and so was already skipped.

Modify also the unit test to unload all modules which have been
loaded by the test.
parent 8b96eed0
...@@ -25,15 +25,25 @@ class TestSundryScripts(unittest.TestCase): ...@@ -25,15 +25,25 @@ class TestSundryScripts(unittest.TestCase):
# scripts that use windows-only modules # scripts that use windows-only modules
windows_only = ['win_add2path'] windows_only = ['win_add2path']
# blacklisted for other reasons # blacklisted for other reasons
other = ['analyze_dxp'] other = ['analyze_dxp', '2to3']
skiplist = blacklist + whitelist + windows_only + other skiplist = blacklist + whitelist + windows_only + other
def test_sundry(self): def test_sundry(self):
old_modules = support.modules_setup()
try:
for fn in os.listdir(scriptsdir): for fn in os.listdir(scriptsdir):
if not fn.endswith('.py'):
continue
name = fn[:-3] name = fn[:-3]
if fn.endswith('.py') and name not in self.skiplist: if name in self.skiplist:
continue
import_tool(name) import_tool(name)
finally:
# Unload all modules loaded in this test
support.modules_cleanup(*old_modules)
@unittest.skipIf(sys.platform != "win32", "Windows-only test") @unittest.skipIf(sys.platform != "win32", "Windows-only test")
def test_sundry_windows(self): def test_sundry_windows(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment