diff options
author | Walter Dörwald <walter@livinglogic.de> | 2009-05-01 19:58:58 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2009-05-01 19:58:58 (GMT) |
commit | 155374d95d8ecd235d3a3edd92dd6f6a23d59f11 (patch) | |
tree | 91deb4c1d292387d2b216d869e79311cad1dbc61 /Lib/test/test_ntpath.py | |
parent | 33841c34896834daa8ee38d3ff54d7800b9723c2 (diff) | |
download | cpython-155374d95d8ecd235d3a3edd92dd6f6a23d59f11.zip cpython-155374d95d8ecd235d3a3edd92dd6f6a23d59f11.tar.gz cpython-155374d95d8ecd235d3a3edd92dd6f6a23d59f11.tar.bz2 |
Merged revisions 72167 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72167 | walter.doerwald | 2009-05-01 19:35:37 +0200 (Fr, 01 Mai 2009) | 5 lines
Make test.test_support.EnvironmentVarGuard behave like a dictionary.
All changes are mirrored to the underlying os.environ dict, but rolled back
on exit from the with block.
........
Diffstat (limited to 'Lib/test/test_ntpath.py')
-rw-r--r-- | Lib/test/test_ntpath.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index 3dc7765..2b2b7d5 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -141,12 +141,11 @@ class TestNtpath(unittest.TestCase): tester("ntpath.normpath('//machine/share//a/b')", r'\\machine\share\a\b') def test_expandvars(self): - oldenv = os.environ.copy() - try: - os.environ.clear() - os.environ["foo"] = "bar" - os.environ["{foo"] = "baz1" - os.environ["{foo}"] = "baz2" + with support.EnvironmentVarGuard() as env: + env.clear() + env["foo"] = "bar" + env["{foo"] = "baz1" + env["{foo}"] = "baz2" tester('ntpath.expandvars("foo")', "foo") tester('ntpath.expandvars("$foo bar")', "bar bar") tester('ntpath.expandvars("${foo}bar")', "barbar") @@ -166,9 +165,6 @@ class TestNtpath(unittest.TestCase): tester('ntpath.expandvars("%?bar%")', "%?bar%") tester('ntpath.expandvars("%foo%%bar")', "bar%bar") tester('ntpath.expandvars("\'%foo%\'%bar")', "\'%foo%\'%bar") - finally: - os.environ.clear() - os.environ.update(oldenv) def test_abspath(self): # ntpath.abspath() can only be used on a system with the "nt" module |