Bird
0
0

You have tests marked as api, ui, and db. You want to run tests that are either api or ui, but not db. Which command achieves this?

hard🚀 Application Q15 of 15
PyTest - Markers
You have tests marked as api, ui, and db. You want to run tests that are either api or ui, but not db. Which command achieves this?
Apytest -m "api or (ui and not db)"
Bpytest -m "api or ui and not db"
Cpytest -m "(api or ui) and not db"
Dpytest -m "api and ui and not db"
Step-by-Step Solution
Solution:
  1. Step 1: Understand operator precedence

    Logical AND has higher precedence than OR, so parentheses are needed to group api or ui together.
  2. Step 2: Analyze each option

    pytest -m "(api or ui) and not db" correctly groups (api or ui) and excludes db with and not db.
  3. Final Answer:

    pytest -m "(api or ui) and not db" -> Option C
  4. Quick Check:

    Use parentheses to group OR conditions = A [OK]
Quick Trick: Use parentheses to group markers with OR before AND [OK]
Common Mistakes:
MISTAKES
  • Ignoring operator precedence without parentheses
  • Using AND instead of OR between api and ui
  • Including db tests by mistake

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes