Update tmpdir.py

This commit is contained in:
Bruno Oliveira 2023-04-14 12:44:21 -03:00 committed by GitHub
parent 341ec662ff
commit 81be46308b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -305,13 +305,13 @@ def pytest_sessionfinish(session, exitstatus: Union[int, ExitCode]):
and policy == "failed"
and tmp_path_factory._given_basetemp is None
):
if basetemp.exists():
if basetemp.is_dir():
# We do a "best effort" to remove files, but it might not be possible due to some leaked resource,
# permissions, etc, in which case we ignore it.
rmtree(basetemp, ignore_errors=True)
return
# Remove dead symlinks.
if basetemp.is_dir():
cleanup_dead_symlinks(basetemp)