]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-121200: Log pwd entry in test_expanduser_pwd2() (GH-121207) (#121214)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 1 Jul 2024 10:02:34 +0000 (12:02 +0200)
committerGitHub <noreply@github.com>
Mon, 1 Jul 2024 10:02:34 +0000 (10:02 +0000)
gh-121200: Log pwd entry in test_expanduser_pwd2() (GH-121207)

Use subTest() to log the pwd entry in test_expanduser_pwd2() of
test_posixpath to help debugging.
(cherry picked from commit 05a6f8da6042cc87da1cd3824c1375d12753e5a1)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_posixpath.py

index 932d8a35d31fa9d345d6ea6def045e18d81c7c61..9f54311d2ad60b5548a06cd3f4625e32eed822cc 100644 (file)
@@ -347,13 +347,14 @@ class PosixPathTest(unittest.TestCase):
                      "no home directory on VxWorks")
     def test_expanduser_pwd2(self):
         pwd = import_helper.import_module('pwd')
-        for e in pwd.getpwall():
-            name = e.pw_name
-            home = e.pw_dir
+        for entry in pwd.getpwall():
+            name = entry.pw_name
+            home = entry.pw_dir
             home = home.rstrip('/') or '/'
-            self.assertEqual(posixpath.expanduser('~' + name), home)
-            self.assertEqual(posixpath.expanduser(os.fsencode('~' + name)),
-                             os.fsencode(home))
+            with self.subTest(pwd=entry):
+                self.assertEqual(posixpath.expanduser('~' + name), home)
+                self.assertEqual(posixpath.expanduser(os.fsencode('~' + name)),
+                                 os.fsencode(home))
 
     NORMPATH_CASES = [
         ("", "."),