Bird
0
0

Given this pytest code:

medium📝 Predict Output Q5 of 15
PyTest - Markers
Given this pytest code:
import pytest

@pytest.mark.skip(reason="Deprecated test")
def test_old():
    assert False

@pytest.mark.skip(reason="Waiting for fix")
def test_new():
    assert True
What will pytest report after running?
Atest_old is skipped; test_new runs and passes
BBoth tests run and pass
Ctest_old runs and fails; test_new is skipped
DBoth tests are skipped with their reasons
Step-by-Step Solution
Solution:
  1. Step 1: Identify skip decorators on both tests

    Both test_old and test_new have @pytest.mark.skip with reasons, so both are skipped.
  2. Step 2: Understand pytest behavior on skipped tests

    Skipped tests do not run their code and pytest reports them as skipped with the given reasons.
  3. Final Answer:

    Both tests are skipped with their reasons -> Option D
  4. Quick Check:

    All tests with skip decorator are skipped = B [OK]
Quick Trick: All tests with skip decorator skip regardless of assertions [OK]
Common Mistakes:
MISTAKES
  • Assuming one test runs despite skip
  • Confusing skip with skipif
  • Expecting failed assertion to run
  • Ignoring skip reason in report

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes