pytest-dev / pytest-dev/pytest-timeout

Suggestion: Using capturemanager.global_and_fixture_disabled

Open
#172 1 comment 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.