From: Miro HronĨok Date: Thu, 27 Nov 2025 18:00:02 +0000 (+0100) Subject: gh-140210: Make test_sysconfig.test_parse_makefile_renamed_vars ignore environment... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=69f54ce4523174860a92271e3cec5c498f89627f;p=thirdparty%2FPython%2Fcpython.git gh-140210: Make test_sysconfig.test_parse_makefile_renamed_vars ignore environment variables (#140213) The test did not expect it could be run with e.g. CFLAGS set to a custom value. --- diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 8101657b04a5..502103ce6293 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -20,7 +20,7 @@ from test.support import ( ) from test.support.import_helper import import_module from test.support.os_helper import (TESTFN, unlink, skip_unless_symlink, - change_cwd) + change_cwd, EnvironmentVarGuard) from test.support.venv import VirtualEnvironmentMixin import sysconfig @@ -807,7 +807,9 @@ class MakefileTests(unittest.TestCase): print("PY_LDFLAGS=-lm", file=makefile) print("var2=$(LDFLAGS)", file=makefile) print("var3=$(CPPFLAGS)", file=makefile) - vars = _parse_makefile(TESTFN) + with EnvironmentVarGuard() as env: + env.clear() + vars = _parse_makefile(TESTFN) self.assertEqual(vars, { 'var1': '-Wall', 'CFLAGS': '-Wall', diff --git a/Misc/NEWS.d/next/Tests/2025-10-16-15-08-58.gh-issue-140210.P9vUP8.rst b/Misc/NEWS.d/next/Tests/2025-10-16-15-08-58.gh-issue-140210.P9vUP8.rst new file mode 100644 index 000000000000..f2064bfd377e --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2025-10-16-15-08-58.gh-issue-140210.P9vUP8.rst @@ -0,0 +1,2 @@ +Make ``test_sysconfig.test_parse_makefile_renamed_vars`` less fragile by +clearing the environment variables before parsing the Makefile.