0
0
PyTesttesting~10 mins

Why parallel tests reduce total time in PyTest - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run tests in parallel using pytest.

PyTest
pytest -n [1]
Drag options to blanks, or click blank then click option'
A2
B1
C4
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or 1 means tests run sequentially, not in parallel.
Choosing a number larger than available CPU cores can slow down tests.
2fill in blank
medium

Complete the code to import the pytest-xdist plugin for parallel testing.

PyTest
import [1]
Drag options to blanks, or click blank then click option'
Apytest-xdist
Bpytest
Cpytest_xdist
Dpytestxdist
Attempts:
3 left
💡 Hint
Common Mistakes
Using dashes instead of underscores causes import errors.
Trying to import the base pytest package instead of the plugin.
3fill in blank
hard

Fix the error in the pytest command to run tests in parallel on 3 CPUs.

PyTest
pytest -n [1]
Drag options to blanks, or click blank then click option'
An3
B3
C-3
Dthree
Attempts:
3 left
💡 Hint
Common Mistakes
Writing the number as a word causes command errors.
Adding extra characters breaks the command.
4fill in blank
hard

Fill both blanks to create a pytest command that runs tests in parallel and shows detailed output.

PyTest
pytest [1] [2]
Drag options to blanks, or click blank then click option'
A-n 2
B-v
C-q
D--maxfail=1
Attempts:
3 left
💡 Hint
Common Mistakes
Using -q hides output, not shows it.
Using --maxfail=1 stops tests early, not related to parallelism.
5fill in blank
hard

Fill all three blanks to write a pytest command that runs tests in parallel on 4 CPUs, stops after 2 failures, and shows verbose output.

PyTest
pytest [1] [2] [3]
Drag options to blanks, or click blank then click option'
A-n 4
B-v
C--maxfail=2
D-q
Attempts:
3 left
💡 Hint
Common Mistakes
Using -q instead of -v hides output.
Not including --maxfail means tests run even after many failures.