-
We want to run pytest inside an environment where it's only helpful to get an exit code 0 without any output from pytest but given any failure, I would like to get the assert error messages from stderr. We have not created a plugin yet, but we tinkered with cli options, as far as we can tell, we cannot use Ideally, given Will I need a custom plugin? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I was able to come up with this: class X:
def pytest_terminal_summary(self, terminalreporter, exitstatus, config):
"""Show failure messages only. Given it's used with -p no:terminal"""
if exitstatus != 0:
reports = terminalreporter.stats.get("failed", [])
for report in reports:
print(f"{report.longrepr}", file=sys.stderr) |
Beta Was this translation helpful? Give feedback.
I was able to come up with this: