mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Use test.test_support.EnvironmentVarGuard where tests change environment vars.
This commit is contained in:
parent
e73cbe7a4e
commit
4b965f6ab1
6 changed files with 36 additions and 56 deletions
|
@ -345,10 +345,9 @@ class PosixPathTest(unittest.TestCase):
|
|||
self.assert_(isinstance(posixpath.expanduser("~root/"), basestring))
|
||||
self.assert_(isinstance(posixpath.expanduser("~foo/"), basestring))
|
||||
|
||||
orig_home = os.environ['HOME']
|
||||
os.environ['HOME'] = '/'
|
||||
self.assertEqual(posixpath.expanduser("~"), "/")
|
||||
os.environ['HOME'] = orig_home
|
||||
with test_support.EnvironmentVarGuard() as env:
|
||||
env.set('HOME', '/')
|
||||
self.assertEqual(posixpath.expanduser("~"), "/")
|
||||
|
||||
self.assertRaises(TypeError, posixpath.expanduser)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue