Skip to content
Discussion options

You must be logged in to vote

Hi @amolgawai

Use the report's when value in addition to passed / failed.

pytest creates separate reports for setup, the actual test call, and teardown. A normal assertion/test failure is generally:

report.when == "call" and report.failed

while what pytest displays as an ERROR is normally a setup or teardown failure.

For example:

def pytest_runtest_logreport(report):
    if report.when == "call":
        if report.passed:
            passed += 1
        elif report.failed:
            failed += 1
        elif report.skipped:
            skipped += 1

    elif report.when in ("setup", "teardown") and report.failed:
        errors += 1

The important part is to count normal test outcomes onl…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@amolgawai
Comment options

Answer selected by amolgawai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants