Skip to content

How to remove all of pytest output and keep only error messages from asserts in stderr #13129

Closed Answered by Lorac
Lorac asked this question in Q&A
Discussion options

You must be logged in to vote

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)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Lorac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant