summaryrefslogtreecommitdiff
path: root/setuptools/tests/test_msvc9compiler.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-09-26 19:21:21 -0400
committerJason R. Coombs <jaraco@jaraco.com>2014-09-26 19:21:21 -0400
commit46a65a1a635cf3986c853907d1a16c5173cc125d (patch)
treedc670e97c855b17cfcfd0049fff9c888db1c6618 /setuptools/tests/test_msvc9compiler.py
parent8759ca96ec6c6c318d65e0c93ca8b3c93f45e7f9 (diff)
downloadpython-setuptools-git-46a65a1a635cf3986c853907d1a16c5173cc125d.tar.gz
Always restore os.environ even if an exception occurs.
Diffstat (limited to 'setuptools/tests/test_msvc9compiler.py')
-rw-r--r--setuptools/tests/test_msvc9compiler.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/setuptools/tests/test_msvc9compiler.py b/setuptools/tests/test_msvc9compiler.py
index ac5e3914..970f7679 100644
--- a/setuptools/tests/test_msvc9compiler.py
+++ b/setuptools/tests/test_msvc9compiler.py
@@ -79,11 +79,12 @@ def patch_env(**replacements):
os.environ.update(replacements)
- yield saved
-
- for key in replacements:
- os.environ.pop(key, None)
- os.environ.update(saved)
+ try:
+ yield saved
+ finally:
+ for key in replacements:
+ os.environ.pop(key, None)
+ os.environ.update(saved)
class TestMSVC9Compiler(unittest.TestCase):