Skip to content
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

Clarify whether and when tmp_path is deleted after each use #8036

Closed
xuhdev opened this issue Nov 14, 2020 · 13 comments
Closed

Clarify whether and when tmp_path is deleted after each use #8036

xuhdev opened this issue Nov 14, 2020 · 13 comments
Labels
status: help wanted developers would like help from experts on this topic type: docs documentation improvement, missing or needing clarification

Comments

@xuhdev
Copy link
Contributor

xuhdev commented Nov 14, 2020

Currently the document is unclear about whether and when tmp_path is deleted after each use. After I digged into the code, I still have no idea. I wish there could be some clarification on this topic in the document.

@RonnyPfannschmidt
Copy link
Member

Pytest keeps around the last 3 test runs, we ought to make that more discoverable

@RonnyPfannschmidt RonnyPfannschmidt added type: docs documentation improvement, missing or needing clarification status: help wanted developers would like help from experts on this topic labels Nov 14, 2020
@matthewhughes934
Copy link
Contributor

Hi, I'm interested in helping here. Where would be best to note this so that it's more discoverable? It looks to be already noted here: https://github.com/pytest-dev/pytest/blob/master/doc/en/tmpdir.rst#the-default-base-temporary-directory, could this be moved to somewhere more visible?

@nicoddemus
Copy link
Member

We might add a note to tmpdir and tmp_path in the reference docs.

@xuhdev
Copy link
Contributor Author

xuhdev commented Nov 14, 2020

Pytest keeps around the last 3 test runs, we ought to make that more discoverable

Thanks. When you say "the last 3 test runs," do you mean the last 3 test sessions, or the last 3 individual tests?

@RonnyPfannschmidt
Copy link
Member

@xuhdev the last 3 sessions, when creating a new basetemp, pytest tries to keep the last 3 around to aid debugging

matthewhughes934 added a commit to matthewhughes934/pytest that referenced this issue Nov 14, 2020
Explanation: The default handling in
`tmpdir.TempPathFactory.getbasetemp` handles these lifetimes, passing
`keep=3` to `pathlib.make_numbered_dir_with_cleanup`.

GH Issue: pytest-dev#8036
matthewhughes934 added a commit to matthewhughes934/pytest that referenced this issue Nov 14, 2020
Explanation: The default handling in
`tmpdir.TempPathFactory.getbasetemp` handles these lifetimes, passing
`keep=3` to `pathlib.make_numbered_dir_with_cleanup`.

GH Issue: pytest-dev#8036
matthewhughes934 added a commit to matthewhughes934/pytest that referenced this issue Nov 15, 2020
Explanation: The default handling in
`tmpdir.TempPathFactory.getbasetemp` handles these lifetimes, passing
`keep=3` to `pathlib.make_numbered_dir_with_cleanup`.

GH Issue: pytest-dev#8036
matthewhughes934 added a commit to matthewhughes934/pytest that referenced this issue Nov 15, 2020
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
matthewhughes934 added a commit to matthewhughes934/pytest that referenced this issue Nov 28, 2020
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
@hmaarrfk
Copy link

Would it be acceptable to add a flag where the tempfiles are delete if the test is successful? for large datasets that get created for tests, it is advantageous for us to be able to use a standard fixture, without worrying about running out of diskspace.

@nicoddemus
Copy link
Member

Hi @hmaarrfk,

I think a configuration option would be acceptable, something like tmp_keep, which by default is 3 but could be set to 0 to accomplish what you mention. 👍

@RonnyPfannschmidt
Copy link
Member

An option to generally keep only failed tests could be a big space safer

@nicoddemus
Copy link
Member

An option to generally keep only failed tests could be a big space safer

Ahh indeed, I misinterpreted @hmaarrfk's request.

I agree keeping only the tmp directory of failed tests would make for a better option.

@matthewhughes934
Copy link
Contributor

I agree keeping only the tmp directory of failed tests would make for a better option.

If this feature (or another from this thread) is desired, I'd be interested in working on it.

@RonnyPfannschmidt
Copy link
Member

its a desired feature, lets open a issue to clarify the details and then it can be started

@nicoddemus
Copy link
Member

Agreed, created: #8141

@nicoddemus
Copy link
Member

Closing this as fixed by #8038

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted developers would like help from experts on this topic type: docs documentation improvement, missing or needing clarification
Projects
None yet
Development

No branches or pull requests

5 participants