New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Note lifetime of temporary directories #8038
Docs: Note lifetime of temporary directories #8038
Conversation
I wasn't sure if the comment was best placed directly in the reference or in the pydocs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
src/_pytest/tmpdir.py
Outdated
@@ -172,7 +172,9 @@ def _mk_tmp(request: FixtureRequest, factory: TempPathFactory) -> Path: | |||
def tmpdir(tmp_path: Path) -> py.path.local: | |||
"""Return a temporary directory path object which is unique to each test | |||
function invocation, created as a sub directory of the base temporary | |||
directory. | |||
directory. After 3 sessions the directory will be removed by default, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to describe the situation in a bit more detail. I suggest writing this in a separate paragraph:
The temporary directory is created under a base directory. By default, a
new base is created each test session, and old bases are removed after 3
sessions, to aid in debugging. If ``--basetemp`` is used then it is
cleared each session. See :ref:`base temporary directory`.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that sounds good, particularly the extra link! I updated with 6a25660. I left out your first sentence since I thought it was sufficiently covered in the existing docs, but I can be persuaded otherwise.
Explanation: The default handling of these lifetimes is done in `tmpdir.TempPathFactory.getbasetemp`, which passes `keep=3` to `pathlib.make_numbered_dir_with_cleanup`. GH Issue: pytest-dev#8036
352d93e
to
6a25660
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @matthewhughes934!
Explanation: The default handling of these lifetimes is done in
tmpdir.TempPathFactory.getbasetemp
, which passeskeep=3
topathlib.make_numbered_dir_with_cleanup
.GH Issue: #8036