Bird
0
0

You want to run tests in parallel using pytest. Which command correctly runs tests in 4 parallel workers?

hard🚀 Application Q8 of 15
PyTest - Basics and Setup
You want to run tests in parallel using pytest. Which command correctly runs tests in 4 parallel workers?
Apytest -p 4
Bpytest --workers=4
Cpytest -n 4
Dpytest --parallel=4
Step-by-Step Solution
Solution:
  1. Step 1: Identify pytest-xdist plugin usage

    Running tests in parallel requires the pytest-xdist plugin, which uses -n to specify worker count.
  2. Step 2: Analyze options

    --workers, --parallel, and -p are not valid options for parallel execution.
  3. Final Answer:

    pytest -n 4 -> Option C
  4. Quick Check:

    Parallel tests use -n with pytest-xdist [OK]
Quick Trick: Use pytest -n N to run tests in N parallel workers [OK]
Common Mistakes:
MISTAKES
  • Using --workers or --parallel which are invalid
  • Confusing -p with plugin option
  • Not installing pytest-xdist plugin before parallel run

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes