pytest-dev / pytest-dev/pytest
tmp_path: basetemp with retention
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
from the tmp_path how-to docs:
Temporary directories are by default created as sub-directories of the system temporary directory. ... entries older than 3 temporary directories will be removed. ... can be configured with
tmp_path_retention_count...Using the
--basetempoption will remove the directory before every run, effectively meaning the temporary directories
of only the most recent run will be kept.
Is there any particular reason that the retention feature (keep 3 by default) is not supported when --basetemp is used?
It seems like these features should be orthogonal, but that's not the case which is counter-intuitive.
Current workaround is apparently to use the PYTEST_DEBUG_TEMPROOT env var instead of --basetemp but that feature is not documented as far as I could find.
I understand that there are concerns about backward compatibility, but I think basetemp+retention can be implented in a backward compatible way:
- use
--basetemp, but notmp_path_retention_countconfig set: use custom temp root without retention (existing behavior) - use
--basetempandtmp_path_retention_count: use custom temp root with retention (this feature request)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the tmp_path how-to docs and trace the existing --basetemp and tmp_path_retention_count handling. Check how PYTEST_DEBUG_TEMPROOT is used, then determine where coverage should verify the proposed backward-compatible behavior. Done means basetemp honors retention when configured while preserving its current behavior when retention is unset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100