Skip to content

Commit

Permalink
pythongh-121200: Debug test_posixpath.test_expanduser_pwd2()
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed Jul 1, 2024
1 parent 08bef50 commit fcdc96d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Lib/posixpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Lib/test/test_posixpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit fcdc96d

Please sign in to comment.