mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
[3.12] gh-131277: allow EnvironmentVarGuard to unset more than one environment variable at once (GH-131280) (#131410)
(cherry picked from commit 3185e3115c
)
---------
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
parent
38ef8d78bb
commit
865bd6de99
8 changed files with 25 additions and 32 deletions
|
@ -3111,7 +3111,7 @@ class PosixPathTest(_BasePathTest, unittest.TestCase):
|
|||
p7 = P(f'~{fakename}/Documents')
|
||||
|
||||
with os_helper.EnvironmentVarGuard() as env:
|
||||
env.pop('HOME', None)
|
||||
env.unset('HOME')
|
||||
|
||||
self.assertEqual(p1.expanduser(), P(userhome) / 'Documents')
|
||||
self.assertEqual(p2.expanduser(), P(userhome) / 'Documents')
|
||||
|
@ -3222,10 +3222,7 @@ class WindowsPathTest(_BasePathTest, unittest.TestCase):
|
|||
def test_expanduser(self):
|
||||
P = self.cls
|
||||
with os_helper.EnvironmentVarGuard() as env:
|
||||
env.pop('HOME', None)
|
||||
env.pop('USERPROFILE', None)
|
||||
env.pop('HOMEPATH', None)
|
||||
env.pop('HOMEDRIVE', None)
|
||||
env.unset('HOME', 'USERPROFILE', 'HOMEPATH', 'HOMEDRIVE')
|
||||
env['USERNAME'] = 'alice'
|
||||
|
||||
# test that the path returns unchanged
|
||||
|
@ -3263,8 +3260,7 @@ class WindowsPathTest(_BasePathTest, unittest.TestCase):
|
|||
env['HOMEPATH'] = 'Users\\alice'
|
||||
check()
|
||||
|
||||
env.pop('HOMEDRIVE', None)
|
||||
env.pop('HOMEPATH', None)
|
||||
env.unset('HOMEDRIVE', 'HOMEPATH')
|
||||
env['USERPROFILE'] = 'C:\\Users\\alice'
|
||||
check()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue