Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to run pytest tests in parallel using the -n auto option.
PyTest
pytest.main(['test_sample.py', '-n', '[1]'])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-n all' which is not a valid option.
Using '-n threads' which is incorrect syntax.
✗ Incorrect
The '-n auto' option tells pytest-xdist to automatically detect the number of CPUs and run tests in parallel accordingly.
2fill in blank
mediumComplete the command to run pytest with parallel execution automatically detecting CPU cores.
PyTest
pytest [1] test_module.py Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-n 4' which fixes the number of workers instead of auto.
Using '-x' which stops after first failure.
✗ Incorrect
The '-n auto' option runs tests in parallel using all available CPU cores automatically.
3fill in blank
hardFix the error in the pytest command to enable automatic parallel test execution.
PyTest
pytest -n [1] test_parallel.py Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'all' which is not recognized by pytest-xdist.
Using 'max' or 'cpu' which are invalid options.
✗ Incorrect
The correct option is 'auto' to let pytest-xdist detect CPU cores automatically. Other options are invalid.
4fill in blank
hardFill both blanks to run pytest in parallel with automatic CPU detection and verbose output.
PyTest
pytest [1] [2] tests/
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-q' which reduces output instead of verbose.
Using '--maxfail=1' which stops tests early, not related to parallelism.
✗ Incorrect
Use '-n auto' for parallel execution and '-v' for verbose output.
5fill in blank
hardFill all three blanks to run pytest with automatic parallelism, verbose output, and stop after first failure.
PyTest
pytest [1] [2] [3] my_tests/
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--maxfail=2' which stops after two failures, not first.
Omitting '-v' which reduces output detail.
✗ Incorrect
Use '-n auto' for parallel runs, '-v' for verbose, and '-x' to stop after first failure.