diff options
author | Simon K <jackofspaces@gmail.com> | 2021-02-25 08:28:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-25 08:28:57 +0000 |
commit | b7f2d7ca61d6169495e5780fffc252daaacd6583 (patch) | |
tree | b19f52b713dd56fbbd15d90cb35c6eac60635281 /src/_pytest | |
parent | bbea18d7f9738caa0ef21727137f85b7494c9518 (diff) | |
download | pytest-b7f2d7ca61d6169495e5780fffc252daaacd6583.tar.gz |
Fixed an issue where `getpass.getuser()` contained illegal characters for file directories (#8365)
* retry writing pytest-of dir when invalid chars are in directory name
* add unit tests for getbasetemp() and changelog
* patch _basetemp & _given_basetemp for testing basetemp()
* Tweak changelog for #8317, tidy up comments
Diffstat (limited to 'src/_pytest')
-rw-r--r-- | src/_pytest/tmpdir.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index 29c7e19d7..47729ae5f 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -115,7 +115,12 @@ class TempPathFactory: # use a sub-directory in the temproot to speed-up # make_numbered_dir() call rootdir = temproot.joinpath(f"pytest-of-{user}") - rootdir.mkdir(exist_ok=True) + try: + rootdir.mkdir(exist_ok=True) + except OSError: + # getuser() likely returned illegal characters for the platform, use unknown back off mechanism + rootdir = temproot.joinpath("pytest-of-unknown") + rootdir.mkdir(exist_ok=True) basetemp = make_numbered_dir_with_cleanup( prefix="pytest-", root=rootdir, keep=3, lock_timeout=LOCK_TIMEOUT ) |