Closed
Description
From http://pytest.org/latest/skipping.html#mark-a-test-function-as-expected-to-fail:
This test will be run but no traceback will be reported when it fails. Instead terminal reporting will list it in the “expected to fail” or “unexpectedly passing” sections.
Consider this snippet:
def test_xfail():
import pytest
pytest.xfail("doesn't work")
import os
os._exit(0)
This produces an "x" in the pytest output. If the test were actually run beyond the xfail
as documented, then the interpreter should have just exited. What xfail
seems to do is terminate the execution of the test. But that's inconvenient. Suppose you have a test that'll always raise an exception. You'd have to wrap the test in a try block and call xfail
in a finally
clause. Instead, pytest should mark the test as expecting to fail and continue on.