0
0
PyTesttesting~10 mins

Worker distribution strategies in PyTest - Interactive Code Practice

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's xdist plugin.

PyTest
pytest.main(['-n', '[1]'])
Drag options to blanks, or click blank then click option'
A4
B2
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 disables parallelism, so tests run sequentially.
Using 1 is effectively the same as no parallelism.
2fill in blank
medium

Complete the code to distribute tests by module using pytest xdist.

PyTest
pytest.main(['-n', '3', '--dist=[1]'])
Drag options to blanks, or click blank then click option'
Aloadscope
Bno
Cloadfile
Deach
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'no' disables distribution, so tests run sequentially.
Using 'loadscope' distributes by scope, not by file.
3fill in blank
hard

Fix the error in the pytest command to enable loadscope distribution with 4 workers.

PyTest
pytest.main(['-n', '[1]', '--dist=loadscope'])
Drag options to blanks, or click blank then click option'
A4
B0
Cone
D-4
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 disables parallelism.
Using negative numbers or strings causes errors.
4fill in blank
hard

Fill both blanks to configure pytest to run 3 workers and distribute tests by scope.

PyTest
pytest.main(['-n', '[1]', '--dist=[2]'])
Drag options to blanks, or click blank then click option'
A3
Bloadfile
Cloadscope
Dno
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'no' disables distribution.
Mixing worker count and distribution strategy incorrectly.
5fill in blank
hard

Fill all three blanks to run pytest with 5 workers, distribute by file, and enable boxed mode.

PyTest
pytest.main(['-n', '[1]', '--dist=[2]', '[3]'])
Drag options to blanks, or click blank then click option'
A4
B5
Cloadfile
D--boxed
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong worker count numbers.
Confusing distribution strategies.
Forgetting to enable boxed mode correctly.