gh-131277: allow EnvironmentVarGuard to unset more than one environment variable at once (#131280)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
Bénédikt Tran 2025-03-16 14:09:33 +01:00 committed by GitHub
parent 9558d22ac3
commit 3185e3115c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 38 additions and 45 deletions

View file

@ -3232,7 +3232,7 @@ class PathTest(PurePathTest):
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')
@ -3345,10 +3345,7 @@ class PathTest(PurePathTest):
def test_expanduser_windows(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
@ -3386,8 +3383,7 @@ class PathTest(PurePathTest):
env['HOMEPATH'] = 'Users\\alice'
check()
env.pop('HOMEDRIVE', None)
env.pop('HOMEPATH', None)
env.unset('HOMEDRIVE', 'HOMEPATH')
env['USERPROFILE'] = 'C:\\Users\\alice'
check()