Complete the code to mark the test as expected to fail using pytest.
import pytest @pytest.mark.[1] def test_example(): assert 1 == 2
The @pytest.mark.xfail decorator marks a test as expected to fail.
Complete the code to mark the test as expected to fail only if the condition is True.
import pytest @pytest.mark.xfail(condition=[1]) def test_conditional(): assert 0 == 1
Setting condition=True means the test is expected to fail.
Fix the error in the code to correctly mark the test as expected to fail with a reason.
import pytest @pytest.mark.xfail(reason=[1]) def test_reason(): assert False
The reason must be a string literal enclosed in quotes.
Fill both blanks to mark the test as expected to fail only on Python 3.12 and provide a reason.
import pytest import sys @pytest.mark.xfail(sys.version_info[:2] == [1], reason=[2]) def test_version(): assert False
The condition checks if Python version is 3.12, and the reason is a string explaining the failure.
Fill all three blanks to mark the test as expected to fail with a reason and strict mode enabled.
import pytest @pytest.mark.xfail(condition=[1], reason=[2], strict=[3]) def test_strict(): assert False
condition=True enables xfail to expect failure, reason provides explanation, strict=True treats unexpected passes as errors.