pytest icon indicating copy to clipboard operation
pytest copied to clipboard

Make xpass a failure again

Open RonnyPfannschmidt opened this issue 2 years ago • 13 comments

What's the problem this feature will solve?

Some years ago we accepted a change which made xpass not a failure

I recently hit multiple cases where it was missed that a test was fixed

That's not an acceptable default

Describe the solution you'd like

Alternative Solutions

Additional context

RonnyPfannschmidt avatar Sep 25 '23 05:09 RonnyPfannschmidt

This means changing the default of the strict parameter to True?

nicoddemus avatar Sep 25 '23 12:09 nicoddemus

That's would be the starting point, In the long run it should go away

RonnyPfannschmidt avatar Sep 25 '23 14:09 RonnyPfannschmidt

Hi, How we can test this scenario, I can't see xpass as a marker in pytest.

TanyaAgarwal28 avatar Oct 09 '23 12:10 TanyaAgarwal28

@TanyaAgarwal28 xpass is a test outcome for when a xfail marked test passed "unexpectedly"

RonnyPfannschmidt avatar Oct 09 '23 14:10 RonnyPfannschmidt

Yeah Got it so what we are facing issue here? Isin't a feature that if xfail testcase is passed then it will came as xpassed in outcome? import pytest

@pytest.mark.xfail def test_example_expected_fail(): assert 3 + 3 == 6

image

TanyaAgarwal28 avatar Oct 10 '23 04:10 TanyaAgarwal28

@TanyaAgarwal28 the problem is that its a misfeature - it hides important change for a non-flaky testsuite - fixing a previously failing test by accident

when non-strict xfail was introduced, it was a major mistake not to use a new mark

RonnyPfannschmidt avatar Oct 10 '23 10:10 RonnyPfannschmidt

So basically we have to revert this change and if xfail testcase is by mistakly fixed then the outcome should be passed?? And for non_strict_xfail we should have new mark??

TanyaAgarwal28 avatar Oct 11 '23 10:10 TanyaAgarwal28

Overview of 4 scenarios for xfail and non_strict_xfail xfail testcase which is expectedly fail: import pytest

@pytest.mark.xfail def test_example_expected_fail(): assert 3 + 3 == 7 # This test is marked as expected fail

image

xfail testcase which is passed: import pytest

@pytest.mark.xfail def test_example_expected_fail(): assert 3 + 3 == 6 # This test is marked as expected fail

image

non_strict_xfail testcase is passed: import pytest

@pytest.mark.non_strict_xfail def test_example_expected_fail(): assert 3 + 3 == 6 # This test is marked as expected fail image

TanyaAgarwal28 avatar Oct 11 '23 11:10 TanyaAgarwal28

So basically we have to revert this change and if xfail testcase is by mistakly fixed then the outcome should be passed?? And for non_strict_xfail we should have new mark??

IMHO what should be done:

  1. pytest.mark.xfail has a strict parameter, which defaults to False today. We want to issue a warning that this default will change to True in the future, but only if the strict flag has not been passed explicitly.
  2. A few major releases later, we change the default to True and remove the warning.

Is this what you have in mind @RonnyPfannschmidt ?

nicoddemus avatar Oct 11 '23 13:10 nicoddemus

Correct, once the default is switched I'd like to ensure xpass is either a warning or a failure in any case

RonnyPfannschmidt avatar Oct 11 '23 16:10 RonnyPfannschmidt

okay Got it Thanks

TanyaAgarwal28 avatar Oct 12 '23 06:10 TanyaAgarwal28