Bird
0
0

You have tests marked db, api, and slow. You want to run tests that are either db or api but never slow. Which command is correct?

hard🚀 Application Q9 of 15
PyTest - Markers
You have tests marked db, api, and slow. You want to run tests that are either db or api but never slow. Which command is correct?
Apytest -m '(db or api) and not slow'
Bpytest -m 'db or api and not slow'
Cpytest -m 'db and api and not slow'
Dpytest -m 'db or api or not slow'
Step-by-Step Solution
Solution:
  1. Step 1: Understand operator precedence and grouping

    Parentheses group 'db or api' to run tests with either marker.
  2. Step 2: Exclude 'slow' tests with 'and not slow'

    The expression runs tests with 'db' or 'api' but excludes those marked 'slow'.
  3. Final Answer:

    pytest -m '(db or api) and not slow' -> Option A
  4. Quick Check:

    Use parentheses to group markers in -m expressions [OK]
Quick Trick: Group markers with parentheses to combine logic [OK]
Common Mistakes:
MISTAKES
  • Ignoring parentheses causing wrong logic
  • Using 'and' instead of 'or' incorrectly
  • Misplacing 'not' operator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes