Bird
0
0

You have tests marked as follows: ```python @pytest.mark.smoke @pytest.mark.api def test_api_smoke(): assert True @pytest.mark.smoke def test_ui_smoke(): assert True @pytest.mark.api def test_api(): assert True ``` How would you run all smoke tests except those marked as api?

hard🚀 Application Q9 of 15
PyTest - Test Organization
You have tests marked as follows: ```python @pytest.mark.smoke @pytest.mark.api def test_api_smoke(): assert True @pytest.mark.smoke def test_ui_smoke(): assert True @pytest.mark.api def test_api(): assert True ``` How would you run all smoke tests except those marked as api?
Apytest -m "smoke or not api"
Bpytest -m "not smoke and api"
Cpytest -m "smoke and api"
Dpytest -m "smoke and not api"
Step-by-Step Solution
Solution:
  1. Step 1: Understand marker logic for exclusion

    To run smoke tests excluding api, use 'smoke and not api'.
  2. Step 2: Verify other options

    'or not api' runs too many tests; 'smoke and api' runs only both markers; 'not smoke and api' excludes smoke.
  3. Final Answer:

    pytest -m "smoke and not api" -> Option D
  4. Quick Check:

    Exclude markers with 'not' in pytest -m [OK]
Quick Trick: Use 'and not' to exclude markers in pytest -m [OK]
Common Mistakes:
MISTAKES
  • Using 'or not' which includes unwanted tests
  • Confusing 'and api' with exclusion
  • Misusing 'not smoke and api' which excludes smoke tests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes