From aff7a4fb6370972a7b112a4ff7f21f589077c7c9 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Sat, 27 Apr 2024 22:54:54 +0300 Subject: [PATCH 1/3] Adopt TEST_MODULES_ENABLED for Windows build --- Lib/test/support/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index ea4945466cac82..f8336681230086 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -1181,8 +1181,9 @@ def requires_limited_api(test): return test -TEST_MODULES_ENABLED = sysconfig.get_config_var('TEST_MODULES') == 'yes' - +# Windows build doesn't support --disable-test-modules feature, so there's no +# 'TEST_MODULES' var in config +TEST_MODULES_ENABLED = sys.platform == "win32" or sysconfig.get_config_var('TEST_MODULES') == 'yes' def requires_specialization(test): return unittest.skipUnless( From 4e0c16f44e04a6d3b77cbd0de438e2b0682b510e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 29 Apr 2024 10:28:56 +0300 Subject: [PATCH 2/3] Fix test_capi.test_run on Windows. --- Lib/test/test_capi/test_run.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_capi/test_run.py b/Lib/test/test_capi/test_run.py index bc0ca9dbb7f31e..3a390273ec21ad 100644 --- a/Lib/test/test_capi/test_run.py +++ b/Lib/test/test_capi/test_run.py @@ -2,7 +2,7 @@ import unittest from collections import UserDict from test.support import import_helper -from test.support.os_helper import unlink, TESTFN, TESTFN_UNDECODABLE +from test.support.os_helper import unlink, TESTFN, TESTFN_ASCII, TESTFN_UNDECODABLE NULL = None _testcapi = import_helper.import_module('_testcapi') @@ -35,6 +35,7 @@ class CAPITest(unittest.TestCase): def test_run_stringflags(self): # Test PyRun_StringFlags(). + # XXX: fopen() uses different path encoding than Python on Windows. def run(s, *args): return _testcapi.run_stringflags(s, Py_file_input, *args) source = b'a\n' @@ -63,7 +64,7 @@ def run(s, *args): def test_run_fileexflags(self): # Test PyRun_FileExFlags(). - filename = os.fsencode(TESTFN) + filename = os.fsencode(TESTFN if os.name != 'nt' else TESTFN_ASCII) with open(filename, 'wb') as fp: fp.write(b'a\n') self.addCleanup(unlink, filename) @@ -89,6 +90,7 @@ def run(*args): # CRASHES run(UserDict(), dict(a=1)) @unittest.skipUnless(TESTFN_UNDECODABLE, 'only works if there are undecodable paths') + @unittest.skipIf(os.name == 'nt', 'does not work on Windows') def test_run_fileexflags_with_undecodable_filename(self): run = _testcapi.run_fileexflags try: From 1dea0cc812f12c12f31d4e779eb147a840316874 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Mon, 29 Apr 2024 16:14:34 +0300 Subject: [PATCH 3/3] Update Lib/test/support/__init__.py Co-authored-by: Steve Dower --- Lib/test/support/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index f8336681230086..70d2610aa495c7 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -1183,7 +1183,7 @@ def requires_limited_api(test): # Windows build doesn't support --disable-test-modules feature, so there's no # 'TEST_MODULES' var in config -TEST_MODULES_ENABLED = sys.platform == "win32" or sysconfig.get_config_var('TEST_MODULES') == 'yes' +TEST_MODULES_ENABLED = (sysconfig.get_config_var('TEST_MODULES') or 'yes') == 'yes' def requires_specialization(test): return unittest.skipUnless(