Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
podusowski opened this issue Feb 19, 2021 · 1 comment
Closed

Comments

@podusowski
Copy link

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.

@bluetech
Copy link
Member

You are correct. This issue is a duplicate of #8217, so I'll close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants