0
0
PyTesttesting~20 mins

Why plugins extend PyTest capabilities - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PyTest Plugin Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use plugins in PyTest?
Which of the following best explains why plugins are used to extend PyTest capabilities?
APlugins add new features and hooks to customize test runs without changing PyTest core.
BPlugins replace PyTest core to run tests faster by skipping setup steps.
CPlugins are used to write tests in different programming languages inside PyTest.
DPlugins automatically fix failing tests by rewriting test code.
Attempts:
2 left
💡 Hint
Think about how plugins help without modifying the main tool.
Predict Output
intermediate
2:00remaining
Output of PyTest with a plugin hook
What will be the output when running this PyTest test with a plugin that implements pytest_runtest_setup hook printing 'Setup called'?
PyTest
def test_example():
    assert True
A
Setup called
.
1 passed
B
.
Setup called
1 passed
C
1 passed
Setup called
D
Setup called
1 failed
Attempts:
2 left
💡 Hint
The setup hook runs before the test and prints first.
assertion
advanced
2:00remaining
Correct assertion for plugin-added marker
Given a PyTest plugin adds a marker 'slow' to tests, which assertion correctly checks if a test has this marker?
PyTest
def test_has_marker(request):
    # Check if 'slow' marker is present
    pass
Aassert request.node.has_marker('slow')
Bassert 'slow' in request.node.keywords
Cassert request.node.get_closest_marker('slow') is not None
Dassert request.node.marker('slow') == True
Attempts:
2 left
💡 Hint
Use the official PyTest API to get markers.
🔧 Debug
advanced
2:00remaining
Debugging plugin import error in PyTest
A PyTest plugin fails to load with error: ModuleNotFoundError: No module named 'pytest_custom'. What is the most likely cause?
AThe test function is missing the @pytest.mark decorator.
BThe test file name does not start with 'test_'.
CPyTest version is too new and does not support plugins.
DThe plugin package 'pytest_custom' is not installed in the environment.
Attempts:
2 left
💡 Hint
ModuleNotFoundError means Python cannot find the module.
framework
expert
3:00remaining
How plugins affect PyTest test discovery
Which statement correctly describes how PyTest plugins can influence test discovery?
APlugins only affect test execution, not discovery.
BPlugins can add custom hooks to modify or filter which files and tests PyTest discovers and runs.
CPlugins disable PyTest's built-in test discovery and require manual test listing.
DPlugins force PyTest to discover tests only in the current directory.
Attempts:
2 left
💡 Hint
Think about how plugins can change PyTest behavior before tests run.