Skip to content

exclude empty setup/teardown from --durations #4063

@azrdev

Description

@azrdev

Write a test without setup or tear-down:

def test_sleep():
    import time
    time.sleep(2)

Run pytest --durations 0 on this test. Observe something like

======================= slowest test durations =======================
2.00s call     tests/test.py::test_sleep
0.00s teardown tests/test.py::test_sleep
0.00s setup    tests/test.py::test_sleep

On medium-size testsuites, where one would like to see timings off all tests that run, these useless 0.00s entries clutter the output, so I'd suggest to remove them.

Versions

python-pytest 3.8.1-1
python 3.7.0-4
from archlinux repos

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributortopic: reportingrelated to terminal output and user-facing messages and errorstype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions