How can I completely cleanup temporary directories from tmp_path? #10325
Unanswered
davidsc-unity3d
asked this question in
Q&A
Replies: 2 comments 1 reply
|
Xdist let's each worker have a subdirectory of the main folder As for deferred cleanup, it's a intentional feature, if stuff unexpectedly passes and/or fails, one can directly dig into the artifacts instead of having to rerun /pause tests |
0 replies
Personally I love this feature... I cannot count the number of times I inspect the temporary files to aid understand a failing test. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
This recaps a question I posted on stack overflow https://stackoverflow.com/questions/73888271/pytest-tmp-path-unit-tests-do-not-completely-clean-up-after-themselves
Using this pattern
I can delete all the temporary files for successful tests, meanwhile pytest is keeping the last 3 directories for successful and unsuccessful runs. I'm from the school of thought that tests should completely clean up after themselves, so I'd like a mechanism to delete those directories, and even the files if the test fails, but I haven't figured out how to get this to happen, but on the other hand, maybe I should change my school of thought - its fine to leave some directories around.
The other thing, it seems to run pytest distributed, you have to use a tool like https://pypi.org/project/pytest-xdist/ . I see pytest creates paths like
and it seems to always use the same random string?
dsk3240dl_random_string- for the use case of running the same test from two separate processes that don't talk to one another, it seems we could get a collision. That is a weird use case, so it is not supported?All reactions