summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tempfile.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2009-04-26 20:51:44 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2009-04-26 20:51:44 (GMT)
commit4b965f6ab17370b06ee587c7b12ad3bcd96163e3 (patch)
treef0b91e2341aac4251161bf630770740bd0b4c8af /Lib/test/test_tempfile.py
parente73cbe7a4eba3498f03e8cd27248affcd99e1d74 (diff)
downloadcpython-4b965f6ab17370b06ee587c7b12ad3bcd96163e3.zip
cpython-4b965f6ab17370b06ee587c7b12ad3bcd96163e3.tar.gz
cpython-4b965f6ab17370b06ee587c7b12ad3bcd96163e3.tar.bz2
Use test.test_support.EnvironmentVarGuard where tests change environment vars.
Diffstat (limited to 'Lib/test/test_tempfile.py')
-rw-r--r--Lib/test/test_tempfile.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index 792ad5d..2b46c46 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -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)