Make tmpdir resiliant to user ids that do not exist

Previously, the tmpdir fixture would fail if the current process's user
id does not correspond to a valid user (e.g. running pytest in a Docker
container with 'docker run -u').
This commit is contained in:
Andy Freeland
2015-09-18 21:06:13 -04:00
parent f02d9425f9
commit b1c9b8b415
2 changed files with 35 additions and 1 deletions

View File

@@ -78,7 +78,7 @@ def get_user():
import getpass
try:
return getpass.getuser()
except ImportError:
except (ImportError, KeyError):
return None
# backward compatibility