Bird
0
0

What will happen if you run pytest -m "not slow" on the following code? ```python import pytest @pytest.mark.slow def test_download(): assert True def test_upload(): assert True ```

medium📝 Predict Output Q5 of 15
PyTest - Test Organization
What will happen if you run pytest -m "not slow" on the following code? ```python import pytest @pytest.mark.slow def test_download(): assert True def test_upload(): assert True ```
ARuns only test_upload
BRuns only test_download
CRuns both tests
DRuns no tests
Step-by-Step Solution
Solution:
  1. Step 1: Understand 'not' in marker expression

    pytest -m "not slow" runs tests NOT marked with 'slow'.
  2. Step 2: Identify tests without 'slow' marker

    test_upload is unmarked, so it runs; test_download is marked slow, so skipped.
  3. Final Answer:

    Runs only test_upload -> Option A
  4. Quick Check:

    not slow runs unmarked tests [OK]
Quick Trick: Use 'not' to exclude tests with a marker [OK]
Common Mistakes:
MISTAKES
  • Running all tests ignoring 'not' filter
  • Running only marked tests instead of unmarked
  • Confusing marker negation syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes