aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_pathlib/test_pathlib.py
diff options
context:
space:
mode:
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>2025-03-16 14:09:33 +0100
committerGitHub <noreply@github.com>2025-03-16 14:09:33 +0100
commit3185e3115c918ec189e16cf9f5b51a13a0146556 (patch)
tree4a773847ee275359ae58832afea1071858e539af /Lib/test/test_pathlib/test_pathlib.py
parent9558d22ac308c102e4f843541eead2022050225e (diff)
downloadcpython-3185e3115c918ec189e16cf9f5b51a13a0146556.tar.gz
cpython-3185e3115c918ec189e16cf9f5b51a13a0146556.zip
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>
Diffstat (limited to 'Lib/test/test_pathlib/test_pathlib.py')
-rw-r--r--Lib/test/test_pathlib/test_pathlib.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py
index 36fb62e53e1..bda94f51968 100644
--- a/Lib/test/test_pathlib/test_pathlib.py
+++ b/Lib/test/test_pathlib/test_pathlib.py
@@ -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()