Skip to content

py.test ignores exceptions in fixtures #1480

Closed
@Wilfred

Description

@Wilfred

pytest seems to silently ignore any exception inside fixtures.

import pytest

@pytest.yield_fixture(scope='session', autouse=True)
def my_fixture():
    print "inside fixture"
    raise Exception("oh dear")
    yield

def test_foo():
    assert True

Running this with py.test exception.py -s gives:

exception.py inside fixture
.
================================================ 1 passed in 0.01 seconds =================================================

I would expect py.test to at least warn me that my fixture threw an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: criticalgrave problem or usability issue that affects lots of userstype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions