Skip to content

Commit ba1810e

Browse files
bpo-25094: Fix test_tools.test_sundry() on Windows (GH-8406) (GH-8407)
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. (cherry picked from commit 752d4b7) Co-authored-by: Victor Stinner <[email protected]>
1 parent 05a72f1 commit ba1810e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Lib/test/test_tools/test_sundry.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,25 @@ class TestSundryScripts(unittest.TestCase):
2525
# scripts that use windows-only modules
2626
windows_only = ['win_add2path']
2727
# blacklisted for other reasons
28-
other = ['analyze_dxp']
28+
other = ['analyze_dxp', '2to3']
2929

3030
skiplist = blacklist + whitelist + windows_only + other
3131

3232
def test_sundry(self):
33-
for fn in os.listdir(scriptsdir):
34-
name = fn[:-3]
35-
if fn.endswith('.py') and name not in self.skiplist:
33+
old_modules = support.modules_setup()
34+
try:
35+
for fn in os.listdir(scriptsdir):
36+
if not fn.endswith('.py'):
37+
continue
38+
39+
name = fn[:-3]
40+
if name in self.skiplist:
41+
continue
42+
3643
import_tool(name)
44+
finally:
45+
# Unload all modules loaded in this test
46+
support.modules_cleanup(*old_modules)
3747

3848
@unittest.skipIf(sys.platform != "win32", "Windows-only test")
3949
def test_sundry_windows(self):

0 commit comments

Comments
 (0)