https://github.com/python/cpython/commit/02cb5fdee391670d63b2fc0a92ca9b36a32ac95a
commit: 02cb5fdee391670d63b2fc0a92ca9b36a32ac95a
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2024-07-01T17:49:03+02:00
summary:
gh-121200: Fix test_expanduser_pwd2() of test_posixpath (#121228)
Call getpwnam() to get pw_dir, since it can be different than
getpwall() pw_dir.
files:
A Misc/NEWS.d/next/Tests/2024-07-01-16-15-06.gh-issue-121200.4Pc-gc.rst
M Lib/test/test_posixpath.py
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index 9f36a4cd9ce43f..fb714fd90ae2b3 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -359,11 +359,16 @@ def test_expanduser_pwd(self):
"no home directory on VxWorks")
def test_expanduser_pwd2(self):
pwd = import_helper.import_module('pwd')
- for entry in pwd.getpwall():
- name = entry.pw_name
+ for all_entry in pwd.getpwall():
+ name = all_entry.pw_name
+
+ # gh-121200: pw_dir can be different between getpwall() and
+ # getpwnam(), so use getpwnam() pw_dir as expanduser() does.
+ entry = pwd.getpwnam(name)
home = entry.pw_dir
home = home.rstrip('/') or '/'
- with self.subTest(pwd=entry):
+
+ with self.subTest(all_entry=all_entry, entry=entry):
self.assertEqual(posixpath.expanduser('~' + name), home)
self.assertEqual(posixpath.expanduser(os.fsencode('~' + name)),
os.fsencode(home))
diff --git
a/Misc/NEWS.d/next/Tests/2024-07-01-16-15-06.gh-issue-121200.4Pc-gc.rst
b/Misc/NEWS.d/next/Tests/2024-07-01-16-15-06.gh-issue-121200.4Pc-gc.rst
new file mode 100644
index 00000000000000..01e0d9b9f217d4
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2024-07-01-16-15-06.gh-issue-121200.4Pc-gc.rst
@@ -0,0 +1,3 @@
+Fix ``test_expanduser_pwd2()`` of ``test_posixpath``. Call ``getpwnam()``
+to get ``pw_dir``, since it can be different than ``getpwall()`` ``pw_dir``.
+Patch by Victor Stinner.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]