Bird
0
0

What is the likely cause?

medium📝 Debug Q6 of 15
PyTest - Test Organization
You have the following pytest code: ```python import pytest @pytest.mark.api def test_api_call(): assert True @pytest.mark.api def test_api_response(): assert True @pytest.mark.ui def test_ui_load(): assert True ``` You run pytest -m api but no tests run. What is the likely cause?
AThe tests are not marked correctly with @pytest.mark.api
BYou forgot to add the marker 'api' in pytest.ini or command line
Cpytest does not support multiple tests with the same marker
DThe test functions are missing the 'test_' prefix
Step-by-Step Solution
Solution:
  1. Step 1: Understand marker registration requirement

    pytest requires custom markers to be registered in pytest.ini or command line to avoid ignoring them.
  2. Step 2: Identify cause of no tests running

    Without registering 'api' marker, pytest skips tests marked 'api' when filtering.
  3. Final Answer:

    You forgot to add the marker 'api' in pytest.ini or command line -> Option B
  4. Quick Check:

    Custom markers must be registered to run with -m [OK]
Quick Trick: Register custom markers in pytest.ini to use -m filter [OK]
Common Mistakes:
MISTAKES
  • Assuming markers work without registration
  • Thinking pytest disallows multiple tests with same marker
  • Ignoring test function naming conventions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes