Which command correctly installs pytest-xdist using pip for Python?
Think about the exact package name and how pip installs packages with hyphens.
The correct package name is pytest-xdist. The command pip install pytest-xdist installs it properly. Option A tries to install two separate packages, which is incorrect. Option A uses an underscore instead of a hyphen, which is invalid. Option A includes --upgrade, so it is not the basic install command.
What is the output when running pytest --version after installing pytest-xdist?
pytest --version
Look for the exact format pytest uses to show plugins in version output.
Pytest shows plugins in parentheses with the format (plugins: xdist-3.2.1). Option C matches this format exactly. Other options have incorrect wording or punctuation.
Which assertion correctly verifies that tests ran in parallel using pytest-xdist with 4 CPUs?
result = run_pytest_with_xdist(cpus=4) # result.stdout contains test run summary
Worker IDs start at 0 and go up to number of CPUs minus one.
When running with 4 CPUs, worker IDs are gw0, gw1, gw2, and gw3. Option A correctly checks for gw0 and gw3 presence. Options A, C, and D check for invalid worker IDs (gw4 or gw5) or absence of valid ones.
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?
Consider compatibility between pip and package indexes.
An outdated pip version often cannot find or install newer packages. Option D is incorrect because the command was correct. Option D is unlikely because pytest-xdist supports recent Python versions. Option D would not cause this specific error.
Which pytest.ini configuration correctly sets pytest-xdist to run tests in 3 parallel processes?
[pytest] addopts =
Check the correct syntax for number of workers and distribution mode.
Option B correctly uses -n 3 to specify 3 workers and --dist=loadfile for distribution mode. Option B misses distribution mode. Option B has no space between -n and 3. Option B uses an invalid syntax -n=3.