Challenge - 5 Problems
pytest Plugin Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding pytest plugin installation
Which command correctly installs the pytest plugin named
pytest-cov using pip?Attempts:
2 left
💡 Hint
Use pip to install Python packages.
✗ Incorrect
The correct way to install pytest plugins is by using pip install followed by the plugin name. 'pip install pytest-cov' installs the coverage plugin for pytest.
❓ Predict Output
intermediate2:00remaining
Output of pytest plugin list command
What is the expected output when running
pytest --trace-config after installing the pytest-mock plugin?Attempts:
2 left
💡 Hint
The --trace-config option shows plugin loading details.
✗ Incorrect
The --trace-config option prints detailed info about all plugins pytest loads, including third-party plugins like pytest-mock.
❓ assertion
advanced2:00remaining
Correct assertion to verify plugin availability
Which assertion correctly checks if the
pytest-cov plugin is active in a pytest session object named session?Attempts:
2 left
💡 Hint
Use pluginmanager's has_plugin('cov') to check for the plugin.
✗ Incorrect
The pytest-cov plugin registers under the name 'cov'. The has_plugin('cov') method returns True if the plugin is loaded.
🔧 Debug
advanced2:00remaining
Debugging plugin import error
You installed
pytest-html but get an ImportError when running pytest. Which option explains the most likely cause?Attempts:
2 left
💡 Hint
Check your Python environments and where packages are installed.
✗ Incorrect
ImportError usually means the plugin is not installed in the Python environment used by pytest. Multiple environments can cause this mismatch.
❓ framework
expert3:00remaining
Managing plugin versions in pytest
You want to ensure your project always uses
pytest-cov version 4.0.0 exactly. Which is the best way to enforce this in your project?Attempts:
2 left
💡 Hint
Use dependency files and isolated environments for consistent versions.
✗ Incorrect
Pinning the exact version in requirements.txt or pyproject.toml and using a virtual environment ensures consistent plugin versions across all developers and CI.