Skip to content

Commit 296b056

Browse files
committed
gh-140210: Make test_sysconfig.test_parse_makefile_renamed_vars ignore environment variables
The test did not expect it could be run with e.g. CFLAGS set to a custom value. Fixes #140210
1 parent 379fd02 commit 296b056

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Lib/test/test_sysconfig.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121
from test.support.import_helper import import_module
2222
from test.support.os_helper import (TESTFN, unlink, skip_unless_symlink,
23-
change_cwd)
23+
change_cwd, EnvironmentVarGuard)
2424
from test.support.venv import VirtualEnvironmentMixin
2525

2626
import sysconfig
@@ -807,7 +807,9 @@ def test_parse_makefile_renamed_vars(self):
807807
print("PY_LDFLAGS=-lm", file=makefile)
808808
print("var2=$(LDFLAGS)", file=makefile)
809809
print("var3=$(CPPFLAGS)", file=makefile)
810-
vars = _parse_makefile(TESTFN)
810+
with EnvironmentVarGuard() as env:
811+
env.clear()
812+
vars = _parse_makefile(TESTFN)
811813
self.assertEqual(vars, {
812814
'var1': '-Wall',
813815
'CFLAGS': '-Wall',
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make ``test_sysconfig.test_parse_makefile_renamed_vars`` less fragile by
2+
clearing the environment variables before parsing the Makefile.

0 commit comments

Comments
 (0)