Skip to content

TestReport.longrepr is a string when pytest.fail(..., pytrace=False) is used #1316

@The-Compiler

Description

@The-Compiler

I'd expect the assert in my conftest.py to pass, but it doesn't:

# test_foo.py

import pytest

def test_foo(foo):
    pytest.fail("Hello World", pytrace=False)
# conftest.py
import pytest

@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield
    report = outcome.get_result()
    assert not isinstance(report.longrepr, str)

Without pytrace=False, it's a py._code.code.ReprExceptionInfo instance, which means I can use report.longrepr.addsection to add additional information.

With pytrace=False, it's a str, and even appending something to that string won't get pytest to show the output I'd like to show.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: reportingrelated to terminal output and user-facing messages and errorstype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions