mirror of
https://github.com/python/cpython.git
synced 2025-07-30 22:54:16 +00:00
Use test.test_support.EnvironmentVarGuard where tests change environment vars.
This commit is contained in:
parent
e73cbe7a4e
commit
4b965f6ab1
6 changed files with 36 additions and 56 deletions
|
@ -149,13 +149,11 @@ class test__candidate_tempdir_list(TC):
|
|||
# _candidate_tempdir_list contains the expected directories
|
||||
|
||||
# Make sure the interesting environment variables are all set.
|
||||
added = []
|
||||
try:
|
||||
with test_support.EnvironmentVarGuard() as env:
|
||||
for envname in 'TMPDIR', 'TEMP', 'TMP':
|
||||
dirname = os.getenv(envname)
|
||||
if not dirname:
|
||||
os.environ[envname] = os.path.abspath(envname)
|
||||
added.append(envname)
|
||||
env.set(envname, os.path.abspath(envname))
|
||||
|
||||
cand = tempfile._candidate_tempdir_list()
|
||||
|
||||
|
@ -173,9 +171,6 @@ class test__candidate_tempdir_list(TC):
|
|||
|
||||
# Not practical to try to verify the presence of OS-specific
|
||||
# paths in this list.
|
||||
finally:
|
||||
for p in added:
|
||||
del os.environ[p]
|
||||
|
||||
test_classes.append(test__candidate_tempdir_list)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue