mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
Issue #15184: Ensure configuration-related environment variables
are unset during test execution.
This commit is contained in:
parent
636601dfba
commit
2731c049ac
1 changed files with 63 additions and 59 deletions
|
@ -20,6 +20,14 @@ class Test_OSXSupport(unittest.TestCase):
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
self.prog_name = 'bogus_program_xxxx'
|
self.prog_name = 'bogus_program_xxxx'
|
||||||
self.temp_path_dir = os.path.abspath(os.getcwd())
|
self.temp_path_dir = os.path.abspath(os.getcwd())
|
||||||
|
self.env = test.support.EnvironmentVarGuard()
|
||||||
|
self.addCleanup(self.env.__exit__)
|
||||||
|
for cv in ('CFLAGS', 'LDFLAGS', 'CPPFLAGS',
|
||||||
|
'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'CC',
|
||||||
|
'CXX', 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
|
||||||
|
'PY_CORE_CFLAGS'):
|
||||||
|
if cv in self.env:
|
||||||
|
self.env.unset(cv)
|
||||||
|
|
||||||
def add_expected_saved_initial_values(self, config_vars, expected_vars):
|
def add_expected_saved_initial_values(self, config_vars, expected_vars):
|
||||||
# Ensure that the initial values for all modified config vars
|
# Ensure that the initial values for all modified config vars
|
||||||
|
@ -29,10 +37,9 @@ class Test_OSXSupport(unittest.TestCase):
|
||||||
if config_vars[k] != expected_vars[k])
|
if config_vars[k] != expected_vars[k])
|
||||||
|
|
||||||
def test__find_executable(self):
|
def test__find_executable(self):
|
||||||
with test.support.EnvironmentVarGuard() as env:
|
if self.env['PATH']:
|
||||||
if env['PATH']:
|
self.env['PATH'] = self.env['PATH'] + ':'
|
||||||
env['PATH'] = env['PATH'] + ':'
|
self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir)
|
||||||
env['PATH'] = env['PATH'] + os.path.abspath(self.temp_path_dir)
|
|
||||||
test.support.unlink(self.prog_name)
|
test.support.unlink(self.prog_name)
|
||||||
self.assertIsNone(_osx_support._find_executable(self.prog_name))
|
self.assertIsNone(_osx_support._find_executable(self.prog_name))
|
||||||
self.addCleanup(test.support.unlink, self.prog_name)
|
self.addCleanup(test.support.unlink, self.prog_name)
|
||||||
|
@ -43,10 +50,9 @@ class Test_OSXSupport(unittest.TestCase):
|
||||||
_osx_support._find_executable(self.prog_name))
|
_osx_support._find_executable(self.prog_name))
|
||||||
|
|
||||||
def test__read_output(self):
|
def test__read_output(self):
|
||||||
with test.support.EnvironmentVarGuard() as env:
|
if self.env['PATH']:
|
||||||
if env['PATH']:
|
self.env['PATH'] = self.env['PATH'] + ':'
|
||||||
env['PATH'] = env['PATH'] + ':'
|
self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir)
|
||||||
env['PATH'] = env['PATH'] + os.path.abspath(self.temp_path_dir)
|
|
||||||
test.support.unlink(self.prog_name)
|
test.support.unlink(self.prog_name)
|
||||||
self.addCleanup(test.support.unlink, self.prog_name)
|
self.addCleanup(test.support.unlink, self.prog_name)
|
||||||
with open(self.prog_name, 'w') as f:
|
with open(self.prog_name, 'w') as f:
|
||||||
|
@ -133,9 +139,8 @@ class Test_OSXSupport(unittest.TestCase):
|
||||||
}
|
}
|
||||||
self.add_expected_saved_initial_values(config_vars, expected_vars)
|
self.add_expected_saved_initial_values(config_vars, expected_vars)
|
||||||
|
|
||||||
with test.support.EnvironmentVarGuard() as env:
|
suffix = (':' + self.env['PATH']) if self.env['PATH'] else ''
|
||||||
suffix = (':' + env['PATH']) if env['PATH'] else ''
|
self.env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix
|
||||||
env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix
|
|
||||||
for c_name, c_output in compilers:
|
for c_name, c_output in compilers:
|
||||||
test.support.unlink(c_name)
|
test.support.unlink(c_name)
|
||||||
self.addCleanup(test.support.unlink, c_name)
|
self.addCleanup(test.support.unlink, c_name)
|
||||||
|
@ -195,8 +200,7 @@ class Test_OSXSupport(unittest.TestCase):
|
||||||
config_vars))
|
config_vars))
|
||||||
|
|
||||||
def test__override_all_archs(self):
|
def test__override_all_archs(self):
|
||||||
with test.support.EnvironmentVarGuard() as env:
|
self.env['ARCHFLAGS'] = '-arch x86_64'
|
||||||
env['ARCHFLAGS'] = '-arch x86_64'
|
|
||||||
config_vars = {
|
config_vars = {
|
||||||
'CC': 'clang',
|
'CC': 'clang',
|
||||||
'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ',
|
'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue