Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to run pytest tests in parallel using the pytest-xdist plugin.
PyTest
pytest.main(['-n', '[1]'])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or 1 disables parallelism.
Forgetting to install pytest-xdist plugin.
✗ Incorrect
The '-n' option followed by '2' tells pytest-xdist to run tests in 2 parallel workers.
2fill in blank
mediumComplete the GitHub Actions step to run pytest tests in parallel with 3 workers.
PyTest
run: pytest -n [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 disables parallelism.
Using 1 runs tests sequentially.
✗ Incorrect
Setting '-n 3' runs tests in 3 parallel workers in the CI environment.
3fill in blank
hardFix the error in the pytest command to enable parallel execution with 4 workers.
PyTest
pytest [1] 4
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--n' instead of '-n'.
Using uppercase '-N' which is invalid.
✗ Incorrect
The correct option to specify number of workers is '-n', not '--n'.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-x' which stops after first failure instead of verbose output.
Using '--maxfail=1' which limits failures but does not affect parallelism.
✗ Incorrect
The '-n 4' option runs tests in 4 parallel workers, and '-v' shows verbose output.
5fill in blank
hardFill all three blanks to configure pytest in GitHub Actions to run tests in parallel, stop after 2 failures, and show verbose output.
PyTest
pytest [1] [2] [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-x' which stops after first failure instead of '--maxfail=2'.
Not combining options correctly.
✗ Incorrect
Use '-n 3' for parallelism, '-v' for verbose output, and '--maxfail=2' to stop after 2 failures.