pytest-assume icon indicating copy to clipboard operation
pytest-assume copied to clipboard

Tests are passing when there is a Fail inside pytest.assume in the teardown

Open Tiarles opened this issue 1 year ago • 2 comments

Tests are passing when there is a Fail inside pytest.assume in the teardown. Also, when not using pytest.assume, only the last test is failing.

test code:

import pytest


@pytest.fixture(scope='module')
def fixt_1():
    yield
    with pytest.assume:
        assert False


@pytest.mark.parametrize('x', (1, 2))
def test_1(fixt_1, x):
    pass


@pytest.fixture(scope='module')
def fixt_2():
    yield
    assert False


@pytest.mark.parametrize('x', (10, 20))
def test_2(fixt_2, x):
    pass

Tiarles avatar Aug 31 '23 13:08 Tiarles

That is expected. We only hook into runtest_call, not fixture setup/teardown.

astraw38 avatar Aug 31 '23 19:08 astraw38

I am facing the same issue. I want to use assume in teardown to record error without breaking the teardown process.

One side effect is that the assume recorded in teardown is being reported in the next test !

stan-freefly avatar Jun 27 '24 00:06 stan-freefly