Bird
0
0

You want to run all tests marked ui but exclude those also marked slow. Which command achieves this?

hard🚀 Application Q8 of 15
PyTest - Markers
You want to run all tests marked ui but exclude those also marked slow. Which command achieves this?
Apytest -m 'ui or slow'
Bpytest -m 'not ui and slow'
Cpytest -m 'ui and slow'
Dpytest -m 'ui and not slow'
Step-by-Step Solution
Solution:
  1. Step 1: Understand logical operators in marker expressions

    'and not' selects tests with the first marker but excludes those with the second.
  2. Step 2: Apply to markers 'ui' and 'slow'

    Command pytest -m 'ui and not slow' runs tests marked 'ui' but excludes 'slow'.
  3. Final Answer:

    pytest -m 'ui and not slow' -> Option D
  4. Quick Check:

    Exclude markers with 'and not' in -m [OK]
Quick Trick: Use 'and not' to exclude markers when running tests [OK]
Common Mistakes:
MISTAKES
  • Using 'or' instead of 'and not'
  • Confusing marker logic
  • Running unwanted slow tests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes