0
0
PyTesttesting~20 mins

Installing and managing plugins in PyTest - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
pytest Plugin Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding pytest plugin installation
Which command correctly installs the pytest plugin named pytest-cov using pip?
Apip install pytest-cov
Bpytest install pytest-cov
Cpip pytest install pytest-cov
Dinstall pytest-cov
Attempts:
2 left
💡 Hint
Use pip to install Python packages.
Predict Output
intermediate
2:00remaining
Output of pytest plugin list command
What is the expected output when running pytest --trace-config after installing the pytest-mock plugin?
ARuns tests without showing any plugin information
BShows an error: unknown option '--trace-config'
CLists all loaded plugins including pytest-mock with their configuration files
DOnly lists built-in pytest plugins, excluding pytest-mock
Attempts:
2 left
💡 Hint
The --trace-config option shows plugin loading details.
assertion
advanced
2: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?
Aassert 'cov' in session.config.pluginmanager.get_plugins()
Bassert 'pytest-cov' in session.plugins
Cassert session.has_plugin('pytest-cov')
Dassert session.config.pluginmanager.has_plugin('cov')
Attempts:
2 left
💡 Hint
Use pluginmanager's has_plugin('cov') to check for the plugin.
🔧 Debug
advanced
2:00remaining
Debugging plugin import error
You installed pytest-html but get an ImportError when running pytest. Which option explains the most likely cause?
Apytest-html requires a special license key to work
BThe plugin was installed in a different Python environment than the one running pytest
Cpytest-html is incompatible with pytest versions above 5.0
Dpytest-html must be imported manually in every test file
Attempts:
2 left
💡 Hint
Check your Python environments and where packages are installed.
framework
expert
3: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?
ASpecify 'pytest-cov==4.0.0' in your requirements.txt or pyproject.toml and use a virtual environment
BInstall pytest-cov globally with pip install pytest-cov==4.0.0
CAdd 'pytest-cov>=4.0.0' in your setup.cfg without a virtual environment
DManually check plugin version before each test run and reinstall if needed
Attempts:
2 left
💡 Hint
Use dependency files and isolated environments for consistent versions.