Skip to content

Test listed twice when there's an error during teardown #1004

Description

@The-Compiler

With this code:

import pytest

@pytest.yield_fixture
def fixt():
    yield
    raise Exception

def test_foo(fixt):
    pass

We get this output:

collected 1 items 

py/test_foo.py::test_foo PASSED
py/test_foo.py::test_foo ERROR

================================== ERRORS ===================================
_______________________ ERROR at teardown of test_foo _______________________

    @pytest.yield_fixture
    def fixt():
        yield
>       raise Exception
E       Exception

py/test_foo.py:6: Exception
===================== 1 passed, 1 error in 0.41 seconds ====================

The test obviously only should be listed once, and no passed tests should be listed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: help wanteddevelopers would like help from experts on this topictopic: reportingrelated to terminal output and user-facing messages and errorstype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions