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

Failing pytest assume will always XPASS a test marked xfail

Open astraw38 opened this issue 9 years ago • 6 comments

Simple example:

@pytest.mark.xfail(run=True, reason="Should fail w/ XFAIL")
def test_xfail():
    pytest.assume(False)

Will always comeback XPASS instead of XFAIL. This is because the xfail marker makes report.failed == XPASS, and report.skipped == XFAIL. In this plugin, we manually set report to failed when assumptions fail.

astraw38 avatar Jan 06 '16 17:01 astraw38

Why this been closed? I still see this problem on pytest-assume==2.2.1

ArtemPopov-GuardiCore avatar Nov 17 '20 10:11 ArtemPopov-GuardiCore

Got a working counter example?

There's a test for this that is passing, so if you got one that will trigger a failure, that'd help out. Or at least some output showing that it's not working as expected.

astraw38 avatar Nov 17 '20 16:11 astraw38

@astraw38 Here's a working example:

@pytest.mark.xfail(run=True, reason="Should fail w/ XFAIL", strict=True)
def test_xfail():
    pytest.assume(False)

Note the strict=True. Without it, test returns XFAIL, as expected. With it, for some reason, test returns XPASS.

omriossie avatar Nov 29 '20 11:11 omriossie

@astraw38 Can this issue be reopened so it won't be forgotten?

omriossie avatar Dec 02 '20 14:12 omriossie

Quick analysis:

strict-xfail checking is done in pytest_pyfunc_call. That was the hook we originally were using to do the core logic behind assumption validation; but that was dropped in favor of pytest_runtest_call because the former wouldn't work with unittest-based tests.

So the XFAIL/XPASS is set before we even get to our hook. Initial thought about checking that outcome in particular seems somewhat hacky, but would be a decent stop-gap.

astraw38 avatar Dec 02 '20 15:12 astraw38

I think this was closed by #45.

bilderbuchi avatar Jun 25 '21 10:06 bilderbuchi