Repository navigation
Replies: 1 comment
|
If you want to keep the last 100 lines of captured stdout in each test report, a small import pytest
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
report.sections[:] = [
(heading, "\n".join(text.splitlines()[-100:]) + "\n")
if heading.startswith("Captured stdout") else (heading, text)
for heading, text in report.sections
]I tested a failing test that prints 150 numbered lines on pytest 7.3.1 and 9.1.1; both reported exactly lines 050 through 149. This changes what pytest displays for a failed test, not how much output the application generates or pytest captures in memory. For simply hiding captured stdout altogether, |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello, my stdout is excessively long. Is there a way to limit the output, like showing only the last 100 lines?
All reactions