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.
This commit is contained in:
Miro Hrončok 2025-11-27 19:00:02 +01:00 committed by GitHub
parent e02801dc37
commit 69f54ce452
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -20,7 +20,7 @@
)
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 @@ def test_parse_makefile_renamed_vars(self):
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',

View file

@ -0,0 +1,2 @@
Make ``test_sysconfig.test_parse_makefile_renamed_vars`` less fragile by
clearing the environment variables before parsing the Makefile.