pytest-dev / pytest-dev/pytest
Add "pre setup" log entry when enabling "--show-setup"
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?
I've spent a long time trying to debug a fixture that was interacting with the environment and got stuck because the subprocess was trying to read from the PTY (It spawned an SSH that accidentally asked for host key verification) and it's been really hard trying to figure out what was going on (read: 4-6hs spent debugging this). Due to further environmental restrictions (being run in a NixOS vm test environment) I also had a hard time using strace not giving me relevant output.
I started with the process being stuck in collection (but this was an IO buffering issue) and then noticed that it's likely stuck while setting up some fixture. When using --show-setup I noticed that this only reports on the success of a fixture - I would have needed to get info which fixture is currently being set up.
Describe the solution you'd like
I'd like to add more output (maybe introducing the -vvv level if this becomes too verbose for the -vv level) that shows a "PRESETUP" stage (or something similar) before calling the setup of a fixture.
This would have allowed me to more quickly pinpoint where my code is going wrong.
Alternative Solutions
I normally have pytest-timeout report those kinds of things to me, but for some reason it didn't trigger here. If it did trigger then it would have shown me the subprocess call which is stuck. We could ask the pytest-timeout authors whether they could take a look at that behaviour, too.
Additional context
I'd be happy to work on the PR if this is interesting.
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 from pytest's --show-setup entry point and trace how fixture setup success is currently logged. Add coverage for a pre-setup entry identifying the fixture, then verify the output when setup blocks or fails and confirm the existing setup reporting remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100