From 69f54ce4523174860a92271e3cec5c498f89627f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Miro=20Hron=C4=8Dok?= Date: Thu, 27 Nov 2025 19:00:02 +0100 Subject: [PATCH] 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. --- Lib/test/test_sysconfig.py | 6 ++++-- .../Tests/2025-10-16-15-08-58.gh-issue-140210.P9vUP8.rst | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2025-10-16-15-08-58.gh-issue-140210.P9vUP8.rst 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. -- 2.47.3