pytest-dev / pytest-dev/pytest
calling capture.resume_global_capture() changes the used terminal width
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
I have to suspend the global capture, because I ask the user for some user input in my pytest plugin.
But this leads to a changed terminal width.
conftest.py
import pytest
import shutil
@pytest.hookimpl(trylast=True)
def pytest_sessionfinish(session):
capture = session.config.pluginmanager.getplugin("capturemanager")
capture.suspend_global_capture(in_=True)
# some code to read user input
print(shutil.get_terminal_size())
capture.resume_global_capture()
print(shutil.get_terminal_size())
The === in the no tests ran line are shorter than above and the result of get_terminal_size changed.
pytest: 8.3.5
os: Debian
I performed this test in a directory that only contained the specified file conftest.py.
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 with the conftest.py reproduction and compare shutil.get_terminal_size() before and after capture.suspend_global_capture(in_=True) and capture.resume_global_capture(). Trace the capture manager entry points involved and add or update a regression test demonstrating the terminal width remains consistent after resuming global capture.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100