Bird
0
0

You want to run only tests marked as 'database' but skip those also marked 'slow'. Which pytest command achieves this?

hard📝 framework Q15 of 15
PyTest - Markers
You want to run only tests marked as 'database' but skip those also marked 'slow'. Which pytest command achieves this?
Apytest -m "database and not slow"
Bpytest -m "slow and not database"
Cpytest -m "database or slow"
Dpytest -m "not database and slow"
Step-by-Step Solution
Solution:
  1. Step 1: Understand the requirement

    Run tests with 'database' marker but exclude those with 'slow'.
  2. Step 2: Translate to pytest marker expression

    Use 'database and not slow' to select tests marked database but not slow.
  3. Final Answer:

    pytest -m "database and not slow" -> Option A
  4. Quick Check:

    Use 'and not' to exclude markers [OK]
Quick Trick: Combine markers with 'and not' to exclude tests [OK]
Common Mistakes:
MISTAKES
  • Swapping marker names in the expression
  • Using 'or' instead of 'and not'
  • Misunderstanding marker logic in pytest -m

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes