Skip to content

When multiple fixtures raise during tear down, only one exception is seen #8355

Closed
@podusowski

Description

@podusowski

My test looks like this.

import pytest

@pytest.fixture
def foo():
    yield
    print("foo")
    raise ValueError("foo")

@pytest.fixture
def bar():
    yield
    print("bar")
    raise ValueError("foo")


def test_foo(foo, bar):
    pass

And it gives me this output:

======================= test session starts =======================
platform linux -- Python 3.6.9[pypy-7.3.1-final], pytest-6.0.1, py-1.9.0, pluggy-0.13.0
rootdir: /home/ppodusowski/Playground/pytest-fixtures
plugins: asyncio-0.14.0, flakefinder-1.0.0, timeout-1.4.2
collected 1 item                                                  


test_foo.py .E                                              [100%]

============================= ERRORS ==============================
__________________ ERROR at teardown of test_foo __________________

    @pytest.fixture
    def bar():
        yield
        print("bar")
>       raise ValueError("foo")
E       ValueError: foo

test_foo.py:13: ValueError
-------------------- Captured stdout teardown ---------------------
bar
foo
===================== short test summary info =====================
ERROR test_foo.py::test_foo - ValueError: foo
=================== 1 passed, 1 error in 0.26s ====================

So despite both finalizers being called, exception from only one of them is reported. Apparently the issue is known.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions