]> granicus.if.org Git - python/commitdiff
bpo-32601: Let test_expanduser use the same user if no others found. (GH-5246)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 14 May 2018 14:45:34 +0000 (07:45 -0700)
committerGitHub <noreply@github.com>
Mon, 14 May 2018 14:45:34 +0000 (07:45 -0700)
This happens in the NixOS build sandbox, for example, where the only
other user is nobody with home directory /.
(cherry picked from commit 5c0d462689e1a69537eaeba6ab94e3ff3524fc31)

Co-authored-by: Anders Kaseorg <andersk@mit.edu>
Lib/test/test_pathlib.py

index a4d2f8d9833361db6f17777af1d43db58caccb3b..db53a8f202dc9d8c0c8cbf486f59bd6fe6c85abb 100644 (file)
@@ -2145,6 +2145,9 @@ class PosixPathTest(_BasePathTest, unittest.TestCase):
             otherhome = pwdent.pw_dir.rstrip('/')
             if othername != username and otherhome:
                 break
+        else:
+            othername = username
+            otherhome = userhome
 
         p1 = P('~/Documents')
         p2 = P('~' + username + '/Documents')