0
0
PyTesttesting~20 mins

pytest-xdist installation - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
pytest-xdist Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding pytest-xdist Installation Command

Which command correctly installs pytest-xdist using pip for Python?

Apip install pytest-xdist
Bpip install pytest xdist
Cpip install pytest-xdist --upgrade
Dpip install pytest_xdist
Attempts:
2 left
💡 Hint

Think about the exact package name and how pip installs packages with hyphens.

Predict Output
intermediate
1:30remaining
Output of pytest-xdist Version Check

What is the output when running pytest --version after installing pytest-xdist?

PyTest
pytest --version
Apytest 7.0.1 (plugin: xdist-3.2.1)
Bpytest 7.0.1 (pytest-xdist 3.2.1) installed
Cpytest 7.0.1 (plugins: xdist-3.2.1)
DThis is pytest version 7.0.1 with xdist plugin 3.2.1
Attempts:
2 left
💡 Hint

Look for the exact format pytest uses to show plugins in version output.

assertion
advanced
2:00remaining
Correct Assertion for Parallel Test Execution

Which assertion correctly verifies that tests ran in parallel using pytest-xdist with 4 CPUs?

PyTest
result = run_pytest_with_xdist(cpus=4)
# result.stdout contains test run summary
Aassert 'gw0' in result.stdout and 'gw3' in result.stdout
Bassert 'gw1' not in result.stdout and 'gw4' in result.stdout
Cassert 'gw0' in result.stdout and 'gw4' in result.stdout
Dassert 'gw0' in result.stdout and 'gw5' in result.stdout
Attempts:
2 left
💡 Hint

Worker IDs start at 0 and go up to number of CPUs minus one.

🔧 Debug
advanced
2:00remaining
Debugging pytest-xdist Installation Failure

You run pip install pytest-xdist but get an error: ERROR: Could not find a version that satisfies the requirement pytest-xdist. What is the most likely cause?

AYour Python version is too new and incompatible with pytest-xdist
BYou typed the package name incorrectly as pytest_xdist
CYou forgot to activate your virtual environment before installing
DYou are using an outdated pip version that does not support the package
Attempts:
2 left
💡 Hint

Consider compatibility between pip and package indexes.

framework
expert
2:30remaining
Configuring pytest-xdist for Parallel Tests in pytest.ini

Which pytest.ini configuration correctly sets pytest-xdist to run tests in 3 parallel processes?

PyTest
[pytest]
addopts = 
A
[pytest]
addopts = --dist=loadscope -n3
B
[pytest]
addopts = -n 3 --dist=loadfile
C
[pytest]
addopts = -n=3 --dist=loadfile
D
[pytest]
addopts = -n 3
Attempts:
2 left
💡 Hint

Check the correct syntax for number of workers and distribution mode.