Bird
0
0

You want to run only tests marked as slow in your project using pytest. Which command correctly runs only those tests?

hard🚀 Application Q15 of 15
PyTest - Basics and Setup
You want to run only tests marked as slow in your project using pytest. Which command correctly runs only those tests?
Apytest -m slow
Bpytest --only slow
Cpytest --mark slow
Dpytest -s slow
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest marker option

    The -m option runs tests matching a marker expression, such as slow.
  2. Step 2: Verify other options

    Options --only, --mark, and -s do not filter tests by marker.
  3. Final Answer:

    pytest -m slow -> Option A
  4. Quick Check:

    Use -m to run tests by marker = A [OK]
Quick Trick: Use -m marker to run tests with that marker [OK]
Common Mistakes:
MISTAKES
  • Using incorrect flags like --only or --mark
  • Confusing -s (capture output) with marker filtering
  • Not marking tests before filtering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes