Skip to content
Discussion options

You must be logged in to vote

Hi @atatarn

I would attach the URL as a custom marker and add it to the test report, rather than trying to rewrite every AssertionError.

There is no general public hook for safely rewriting the text of every arbitrary assertion failure. pytest_runtest_makereport is a better fit because it lets you augment the failure while preserving pytest's original assertion diagnostics.

For example:

# conftest.py
import pytest


def pytest_configure(config):
    config.addinivalue_line(
        "markers",
        "fix_doc(url): documentation explaining how to fix this test",
    )


@pytest.hookimpl(wrapper=True)
def pytest_runtest_makereport(item, call):
    report = yield

    if report.when == "call" 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by atatarn
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