<p>pytest makes it easier to flag tests that are expected to fail. It's really useful when in development, e.g., feature not yet implement or bug not totally fixed. Making use of it is as simple as:</p>
<pre><code>import pytest
@pytest.mark.xfail
def test_xpto():
...
</code></pre>
<p>This way, it'll be presented differently in the terminal report and one can track whether a test is failing as expected or unexpectedly passing.</p>
<p>While the test marked as expected to fail will be presented as <code>xfailed</code> in the test summary, if it passes it'll be displayed as <code>xpassed</code> and when that happens it's not displayed as <code>passed</code> because that test was marked to expect failure.</p>
<p>One can even go further and set a reason to why a test is expected to fail, one can set a reason:</p>
<pre><code>import pytest
@pytest.mark.xfail(reason="feature not totally implemented")
def test_xpto():
...
</code></pre>
<p>To display this reason in the test summary, one can use the <code>-r</code> option with the corresponding "short" letters shown in progress(<code>x</code> for <code>xfail</code> and/or <code>X</code> for <code>xpass</code>), e.g. <code>pytest -rxX</code>.</p>
<p>For more information, check the documentation at: #xfail-mark-test-functions-as-expected-to-fail</p>