You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
importpytestimportshutil@pytest.hookimpl(trylast=True)defpytest_sessionfinish(session):
capture=session.config.pluginmanager.getplugin("capturemanager")
capture.suspend_global_capture(in_=True)
# some code to read user inputprint(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.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this! It looks like suspending global capture is affecting how pytest handles terminal settings, which in turn changes the reported terminal width. This is likely due to how pytest manages stdout and stderr during capture.
Potential Workarounds:
✅ Store and restore the terminal size manually before and after suspending capture:
``
`import pytest
import shutil
import os
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
The
===
in the no tests ran line are shorter than above and the result ofget_terminal_size
changed.pytest: 8.3.5
os: Debian
I performed this test in a directory that only contained the specified file
conftest.py
.The text was updated successfully, but these errors were encountered: