Bird
0
0

In pytest, what is the effect of using the -m option when executing tests?

easy🧠 Conceptual Q1 of 15
PyTest - Markers
In pytest, what is the effect of using the -m option when executing tests?
AIt runs tests in parallel using multiple CPUs.
BIt runs only the tests that have the specified marker.
CIt generates a coverage report for the tests.
DIt disables all markers and runs all tests unconditionally.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the -m option

    The -m option in pytest is used to select tests based on markers.
  2. Step 2: Effect of -m

    When you specify -m marker_name, pytest runs only tests decorated with that marker.
  3. Final Answer:

    It runs only the tests that have the specified marker. -> Option B
  4. Quick Check:

    Check pytest documentation for -m usage [OK]
Quick Trick: Use -m to run tests with specific markers only [OK]
Common Mistakes:
MISTAKES
  • Confusing -m with parallel test execution
  • Assuming -m disables markers
  • Thinking -m generates reports

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes