diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-09-26 19:21:21 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-09-26 19:21:21 -0400 |
commit | 45b9c92e627a2996a1846d91aa01af7488f52dcf (patch) | |
tree | 06854cf5029d677329b2fbb99301c25140987608 | |
parent | 18830ceed0af48332e276bf87db1a5dd06640f8d (diff) | |
download | python-setuptools-bitbucket-45b9c92e627a2996a1846d91aa01af7488f52dcf.tar.gz |
Always restore os.environ even if an exception occurs.
-rw-r--r-- | setuptools/tests/test_msvc9compiler.py | 11 |
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): |