Skip to content

Performance: Don't compute traceback if it's not going to be printed #9436

Open
@jonashaag

Description

@jonashaag

My use case (potentially there are others): Have a lot of xfail tests. Substantial amount of time is spent in repr_failure for those tests even if their traceback is never printed.

Minimal example:

# test_minimal.py
import pytest

@pytest.mark.xfail(reason="blah")
@pytest.mark.parametrize("_", range(1000))
def test_foo(_):
    assert 0
time pytest test_minimal.py
# 1.5 secs
# This has the exact same output but is faster
time pytest --tb=no test_minimal.py
# 1.3 secs

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: help wanteddevelopers would like help from experts on this topictopic: tracebacksrelated to displaying and handling of tracebackstype: enhancementnew feature or API change, should be merged into features branchtype: performanceperformance or memory problem/improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions