diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-09-10 10:24:47 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-09-10 10:24:47 (GMT) |
commit | 0fc55a234f037d05a61d29eb1689ae727cd0ba05 (patch) | |
tree | 879e1d1d9b2984bb9a0065bbeedf2aa48fba4ab9 /Lib/test/test_platform.py | |
parent | b161562f72a28e83e62ec0a0a5de601e7724629f (diff) | |
download | cpython-0fc55a234f037d05a61d29eb1689ae727cd0ba05.zip cpython-0fc55a234f037d05a61d29eb1689ae727cd0ba05.tar.gz cpython-0fc55a234f037d05a61d29eb1689ae727cd0ba05.tar.bz2 |
test_platform: Save/restore os.environ on Windows
Diffstat (limited to 'Lib/test/test_platform.py')
-rw-r--r-- | Lib/test/test_platform.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 8eed7c0..3f29613 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -18,6 +18,12 @@ class PlatformTest(unittest.TestCase): # On Windows, the EXE needs to know where pythonXY.dll is at so we have # to add the directory to the path. if sys.platform == "win32": + def restore_environ(old_env): + os.environ.clear() + os.environ.update(old_env) + + self.addCleanup(restore_environ, dict(os.environ)) + os.environ["Path"] = "{};{}".format( os.path.dirname(sys.executable), os.environ["Path"]) @@ -26,6 +32,7 @@ class PlatformTest(unittest.TestCase): 'import platform; print(platform.architecture())'] p = subprocess.Popen(cmd, stdout=subprocess.PIPE) return p.communicate() + real = os.path.realpath(sys.executable) link = os.path.abspath(support.TESTFN) os.symlink(real, link) |