Challenge - 5 Problems
Built-in Markers Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of pytest with skip marker
What will be the test execution result when running this pytest code?
PyTest
import pytest @pytest.mark.skip(reason="Not ready yet") def test_example(): assert 1 == 1
Attempts:
2 left
💡 Hint
The skip marker tells pytest not to run the test but to mark it as skipped.
✗ Incorrect
The @pytest.mark.skip decorator prevents the test from running and pytest reports it as skipped with the given reason.
❓ Predict Output
intermediate2:00remaining
Behavior of skipif marker with condition
What will pytest report when running this test on a Linux system?
PyTest
import pytest import sys @pytest.mark.skipif(sys.platform != 'linux', reason='Only runs on Linux') def test_linux_only(): assert True
Attempts:
2 left
💡 Hint
skipif skips the test only if the condition is True.
✗ Incorrect
The test runs only if sys.platform is 'linux'. On Linux it runs and passes; on other OS it is skipped.
❓ assertion
advanced2:00remaining
Assertion outcome with xfail marker
Given this pytest test marked with xfail, what is the final test report status if the assertion fails?
PyTest
import pytest @pytest.mark.xfail(reason='Known bug') def test_buggy(): assert 1 == 2
Attempts:
2 left
💡 Hint
xfail marks tests expected to fail without failing the suite.
✗ Incorrect
When a test marked xfail fails, pytest reports it as xfailed, meaning expected failure, not a failure.
❓ Predict Output
advanced2:00remaining
xfail with passing test behavior
What will pytest report if a test marked with xfail actually passes?
PyTest
import pytest @pytest.mark.xfail(reason='Known bug') def test_fixed(): assert 2 == 2
Attempts:
2 left
💡 Hint
xfail expects failure; passing is unexpected.
✗ Incorrect
If a test marked xfail passes, pytest reports it as xpassed, meaning it passed unexpectedly.
🔧 Debug
expert2:00remaining
Identify the error in skipif usage
Which option correctly identifies the error in this pytest code snippet?
PyTest
import pytest import sys @pytest.mark.skipif(sys.platform == "win32", reason='Skip on Windows') def test_func(): assert True
Attempts:
2 left
💡 Hint
skipif expects a boolean condition, not a string.
✗ Incorrect
The condition is a boolean expression, so the test skips only on Windows as intended.