mirror of
https://github.com/python/cpython.git
synced 2025-11-06 00:22:07 +00:00
[3.13] gh-131277: allow EnvironmentVarGuard to unset more than one environment variable at once (GH-131280) (#131409)
(cherry picked from commit 3185e3115c)
---------
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
parent
25ae2045a8
commit
85c20374c0
10 changed files with 27 additions and 36 deletions
|
|
@ -1391,7 +1391,7 @@ def test_expanduser_posix(self):
|
|||
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')
|
||||
|
|
@ -1504,10 +1504,7 @@ def test_absolute_windows(self):
|
|||
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
|
||||
|
|
@ -1545,8 +1542,7 @@ def check():
|
|||
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