diff options
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 |