pytest-dev / pytest-dev/pytest
Logfile clobbered when using xdist plugin
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
When using the pytest-xdist plugin, the pytest log file gets clobbered by one of the worker processes, so the resulting file contains only the logs from one worker.
This is because the log file always truncates and only supports a single filename:
https://github.com/pytest-dev/pytest/blob/3c23b5b0106b240597f57b1ce0bbfaebfcb8591c/src/_pytest/logging.py#L406-L409
It would be great if one of these options was implemented:
- Add the ability to specify the PID as part of the log filename (e.g. --log-file "something-%p.log")
- Add some internal way of changing it, so that the xdist plugin can make use of it, without having to completely do logging from scratch.
Versions:
pytest==3.6.4
pytest-forked==0.2
pytest-xdist==1.22.5
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
Read src/_pytest/logging.py around lines 406-409 and inspect how pytest-xdist starts worker processes. Compare the two proposed approaches; done means concurrent workers no longer truncate each other’s logs and the resulting files retain the expected worker output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100