Skip to content

Commit 51c70de

Browse files
authored
gh-118351: Adapt support.TEST_MODULES_ENABLED for builds without the config variable (GH-118354)
1 parent 44f57a9 commit 51c70de

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Lib/test/support/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,8 +1181,9 @@ def requires_limited_api(test):
11811181
return test
11821182

11831183

1184-
TEST_MODULES_ENABLED = sysconfig.get_config_var('TEST_MODULES') == 'yes'
1185-
1184+
# Windows build doesn't support --disable-test-modules feature, so there's no
1185+
# 'TEST_MODULES' var in config
1186+
TEST_MODULES_ENABLED = (sysconfig.get_config_var('TEST_MODULES') or 'yes') == 'yes'
11861187

11871188
def requires_specialization(test):
11881189
return unittest.skipUnless(

Lib/test/test_capi/test_run.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import unittest
33
from collections import UserDict
44
from test.support import import_helper
5-
from test.support.os_helper import unlink, TESTFN, TESTFN_UNDECODABLE
5+
from test.support.os_helper import unlink, TESTFN, TESTFN_ASCII, TESTFN_UNDECODABLE
66

77
NULL = None
88
_testcapi = import_helper.import_module('_testcapi')
@@ -35,6 +35,7 @@ class CAPITest(unittest.TestCase):
3535

3636
def test_run_stringflags(self):
3737
# Test PyRun_StringFlags().
38+
# XXX: fopen() uses different path encoding than Python on Windows.
3839
def run(s, *args):
3940
return _testcapi.run_stringflags(s, Py_file_input, *args)
4041
source = b'a\n'
@@ -63,7 +64,7 @@ def run(s, *args):
6364

6465
def test_run_fileexflags(self):
6566
# Test PyRun_FileExFlags().
66-
filename = os.fsencode(TESTFN)
67+
filename = os.fsencode(TESTFN if os.name != 'nt' else TESTFN_ASCII)
6768
with open(filename, 'wb') as fp:
6869
fp.write(b'a\n')
6970
self.addCleanup(unlink, filename)
@@ -89,6 +90,7 @@ def run(*args):
8990
# CRASHES run(UserDict(), dict(a=1))
9091

9192
@unittest.skipUnless(TESTFN_UNDECODABLE, 'only works if there are undecodable paths')
93+
@unittest.skipIf(os.name == 'nt', 'does not work on Windows')
9294
def test_run_fileexflags_with_undecodable_filename(self):
9395
run = _testcapi.run_fileexflags
9496
try:

0 commit comments

Comments
 (0)