bpo-32601: Let test_expanduser use the same user if no others found. (GH-5246)

This happens in the NixOS build sandbox, for example, where the only
other user is nobody with home directory /.
(cherry picked from commit 5c0d462689)

Co-authored-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Miss Islington (bot) 2018-05-14 07:22:05 -07:00 committed by GitHub
parent f1ee4a2e52
commit 2e01f7d5fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -2142,6 +2142,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')