]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-140210: Make test_sysconfig.test_parse_makefile_renamed_vars ignore environment...
authorMiro Hrončok <miro@hroncok.cz>
Thu, 27 Nov 2025 18:00:02 +0000 (19:00 +0100)
committerGitHub <noreply@github.com>
Thu, 27 Nov 2025 18:00:02 +0000 (10:00 -0800)
The test did not expect it could be run with e.g. CFLAGS set to a custom value.

Lib/test/test_sysconfig.py
Misc/NEWS.d/next/Tests/2025-10-16-15-08-58.gh-issue-140210.P9vUP8.rst [new file with mode: 0644]

index 8101657b04a5c626febcb99f63d6db5951cba748..502103ce6293585cc942678eb4f9110f5b68dc30 100644 (file)
@@ -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 (file)
index 0000000..f2064bf
--- /dev/null
@@ -0,0 +1,2 @@
+Make ``test_sysconfig.test_parse_makefile_renamed_vars`` less fragile by
+clearing the environment variables before parsing the Makefile.