pytest-dev / pytest-dev/pytest-timeout
Suggestion: Using capturemanager.global_and_fixture_disabled
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 258
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
I came across some odd behavior when I was debugging something related to terminal logging in pytest.
And noticed pytest-timeout was disabling capturemanager and doing it's own printing
Ref: https://github.com/pytest-dev/pytest-timeout/blob/2.3.1/pytest_timeout.py#L511
I think the better approach here may be to use global_and_fixture_disabled which is a context manager to temporarily disable capturemanager and write your own terminal outputs while it is disabled
https://github.com/pytest-dev/pytest/blob/main/src/_pytest/capture.py#L819
Any thoughts on whether this would make the logging logic simpler here?
Contributor guide
No contributing guide indexed for this repository
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 in pytest_timeout.py around line 511 and compare its capturemanager handling with pytest's capture.py around line 819, where global_and_fixture_disabled is defined. Reproduce the terminal-logging behavior, then determine whether switching to that context manager simplifies the logic; done means the behavior is understood and the logging path is covered without regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100