Bird
0
0

How do you run only the tests marked with the slow marker using pytest?

hard🚀 Application Q9 of 15
PyTest - Basics and Setup
How do you run only the tests marked with the slow marker using pytest?
Apytest --filter slow
Bpytest --only slow
Cpytest -k slow
Dpytest -m slow
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest markers

    Markers are used to label tests, and pytest can filter tests by markers using the -m option.
  2. Step 2: Use the correct option

    The correct syntax to run tests with a specific marker is pytest -m markername.
  3. Step 3: Apply to 'slow'

    To run only tests marked as slow, use pytest -m slow.
  4. Final Answer:

    pytest -m slow -> Option D
  5. Quick Check:

    Use -m to select tests by marker [OK]
Quick Trick: Use pytest -m markername to run marked tests [OK]
Common Mistakes:
MISTAKES
  • Using -k instead of -m to filter by markers.
  • Using non-existent options like --only or --filter.
  • Assuming marker filtering requires additional plugins.

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes