summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_posixpath.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2009-05-01 19:58:58 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2009-05-01 19:58:58 (GMT)
commit155374d95d8ecd235d3a3edd92dd6f6a23d59f11 (patch)
tree91deb4c1d292387d2b216d869e79311cad1dbc61 /Lib/test/test_posixpath.py
parent33841c34896834daa8ee38d3ff54d7800b9723c2 (diff)
downloadcpython-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_posixpath.py')
-rw-r--r--Lib/test/test_posixpath.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index a37be25..eb918f4 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -420,18 +420,17 @@ class PosixPathTest(unittest.TestCase):
self.assert_(isinstance(posixpath.expanduser(b"~foo/"), bytes))
with support.EnvironmentVarGuard() as env:
- env.set('HOME', '/')
+ env['HOME'] = '/'
self.assertEqual(posixpath.expanduser("~"), "/")
self.assertRaises(TypeError, posixpath.expanduser)
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"
self.assertEqual(posixpath.expandvars("foo"), "foo")
self.assertEqual(posixpath.expandvars("$foo bar"), "bar bar")
self.assertEqual(posixpath.expandvars("${foo}bar"), "barbar")
@@ -457,11 +456,7 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.expandvars(b"${{foo}}"), b"baz1}")
self.assertEqual(posixpath.expandvars(b"$foo$foo"), b"barbar")
self.assertEqual(posixpath.expandvars(b"$bar$bar"), b"$bar$bar")
- finally:
- os.environ.clear()
- os.environ.update(oldenv)
-
- self.assertRaises(TypeError, posixpath.expandvars)
+ self.assertRaises(TypeError, posixpath.expandvars)
def test_normpath(self):
self.assertEqual(posixpath.normpath(""), ".")