pytest-dev / pytest-dev/pytest
Allow to change permissions of temp directories created with tmp_path
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
What's the problem this feature will solve?
Any temp directory created with the fixture tmp_path has read/write permissions only for the specific user running the tests because mode is set to 0o700.
Although this is probably motivated by security concerns, there are scenarios where more relaxed permissions can be useful.
Describe the solution you'd like
I'd like to be able to override the 0o700 mode that is currently hardcoded in pytest.
For example, the tests may be run in a CI pipeline by a special service user, that's different from the user that should investigate any possible error.
If the mode is set 0o750 and the users belong to the same group, the second user would be able to read the temp files.
Alternative Solutions
I tried to enforce chmod on the temp directory after the tests are executed, but this adds complexity and it's not enough if the pipeline is killed due to a timeout.
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 by locating the tmp_path fixture and the hardcoded 0o700 assignment. Check how fixture options are configured elsewhere in pytest before deciding where an override belongs. Done means the secure default remains unchanged and callers can verify a requested mode such as 0o750 on created temporary directories.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100