Bird
0
0

Given this pytest.ini content:

medium📝 Debug Q7 of 15
PyTest - Markers
Given this pytest.ini content:
[pytest]
markers =
    smoke: quick smoke tests
    regression: regression tests

And tests:
@pytest.mark.smoke
def test_smoke(): pass

@pytest.mark.regression
def test_regression(): pass

@pytest.mark.performance
def test_perf(): pass

What happens when you run pytest -m performance?
ANo tests run but no error
BOnly test_perf runs successfully
CAll tests run ignoring markers
Dpytest raises an unknown marker error
Step-by-Step Solution
Solution:
  1. Step 1: Check marker registration in pytest.ini

    Only 'smoke' and 'regression' markers are registered. 'performance' is unregistered.
  2. Step 2: Effect of unregistered marker 'performance'

    pytest warns about the unknown marker but collects test_perf and runs it successfully since it matches '-m performance'. Other tests do not match.
  3. Final Answer:

    Only test_perf runs successfully -> Option B
  4. Quick Check:

    Unregistered marker with -m: warning but matching test runs [OK]
Quick Trick: Always register all custom markers in pytest.ini [OK]
Common Mistakes:
MISTAKES
  • Assuming unregistered markers run silently
  • Ignoring pytest.ini marker list
  • Expecting tests to run without registration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes