From fcdc96d33bfb8383605f8300ed6bc0a8355cdddc Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 1 Jul 2024 15:27:28 +0200 Subject: [PATCH] gh-121200: Debug test_posixpath.test_expanduser_pwd2() --- Lib/posixpath.py | 1 + Lib/test/test_posixpath.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/posixpath.py b/Lib/posixpath.py index fccca4e066b76f1..10dda744d4d4dba 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -266,6 +266,7 @@ def expanduser(path): name = os.fsdecode(name) try: pwent = pwd.getpwnam(name) + print(f"expanduser: {pwent=!r}") except KeyError: # bpo-10496: if the user name from the path doesn't exist in the # password database, return the path unchanged diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index 9f36a4cd9ce43f7..5e69d68b0f527e7 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -361,9 +361,11 @@ def test_expanduser_pwd2(self): pwd = import_helper.import_module('pwd') for entry in pwd.getpwall(): name = entry.pw_name + entry2 = pwd.getpwnam(name) + home = entry.pw_dir home = home.rstrip('/') or '/' - with self.subTest(pwd=entry): + with self.subTest(pwd=entry, entry2=entry2): self.assertEqual(posixpath.expanduser('~' + name), home) self.assertEqual(posixpath.expanduser(os.fsencode('~' + name)), os.fsencode(home))