Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pytest reporting in JUnit, XML, or JSON format

Here we have some tests with various special marks we have seen earlier.

import pytest


def test_blue():
    pass


def test_red():
    assert 1 == 2


@pytest.mark.skip(reason="So we can show skip reporting")
def test_purple():
    assert 1 == 3


@pytest.mark.xfail(reason="To show xfail that really fails")
def test_orange():
    assert 1 == 4


@pytest.mark.xfail(reason="To show xfail that passes")
def test_green():
    pass