Skip to content

Make xpass a failure again  #11467

Description

@RonnyPfannschmidt

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

Activity

  1. added
    topic: reportingrelated to terminal output and user-facing messages and errors
    type: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelog
    on Sep 25, 2023
  2. added this to the 8.0 milestone on Sep 25, 2023
  3. nicoddemus commented on Sep 25, 2023

    @nicoddemus
    Member

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

  4. RonnyPfannschmidt commented on Sep 25, 2023

    @RonnyPfannschmidt
    MemberAuthor

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

  5. TanyaAgarwal28 commented on Oct 9, 2023

    @TanyaAgarwal28
    Contributor

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

  6. RonnyPfannschmidt commented on Oct 9, 2023

    @RonnyPfannschmidt
    MemberAuthor

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

  7. TanyaAgarwal28 commented on Oct 10, 2023

    @TanyaAgarwal28
    Contributor

    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

  8. RonnyPfannschmidt commented on Oct 10, 2023

    @RonnyPfannschmidt
    MemberAuthor

    @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

  9. TanyaAgarwal28 commented on Oct 11, 2023

    @TanyaAgarwal28
    Contributor

    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??

  10. TanyaAgarwal28 commented on Oct 11, 2023

    @TanyaAgarwal28
    Contributor

    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

  11. nicoddemus commented on Oct 11, 2023

    @nicoddemus
    Member

    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 ?

  12. RonnyPfannschmidt commented on Oct 11, 2023

    @RonnyPfannschmidt
    MemberAuthor

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

  13. TanyaAgarwal28 commented on Oct 12, 2023

    @TanyaAgarwal28
    Contributor

    okay Got it
    Thanks

  14. modified the milestones: 8.0, 9.0 on Jan 17, 2024
  15. modified the milestones: 9.0, 10.0 on Nov 5, 2025
  16. bluetech commented on Nov 5, 2025

    @bluetech
    Member

    We now have strict mode which enables strict_xfail. Maybe that's enough to close this issue?

  17. RonnyPfannschmidt commented on Nov 5, 2025

    @RonnyPfannschmidt
    MemberAuthor

    this issue is about making it default to true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: reportingrelated to terminal output and user-facing messages and errorstype: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelog

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions