Recall & Review
beginner
What is a custom marker in pytest?
A custom marker is a label you create to tag tests for special handling, like grouping or skipping them during test runs.
Click to reveal answer
beginner
How do you define a custom marker in pytest?
You define a custom marker by adding it to the pytest.ini file under the [pytest] section using the markers option.
Click to reveal answer
beginner
How do you apply a custom marker to a test function?
Use the @pytest.mark.<marker_name> decorator above the test function to apply the custom marker.
Click to reveal answer
beginner
What command runs only tests with a specific custom marker?
Use pytest -m '<marker_name>' to run only tests tagged with that custom marker.
Click to reveal answer
intermediate
Why should you register custom markers in pytest.ini?
Registering markers avoids warnings and helps pytest recognize your custom tags properly.
Click to reveal answer
How do you mark a test with a custom marker named 'slow'?
✗ Incorrect
Use the decorator @pytest.mark.slow to apply the 'slow' marker to a test.
Where do you register custom markers to avoid warnings?
✗ Incorrect
Custom markers should be registered in pytest.ini under the [pytest] section.
What does the command 'pytest -m slow' do?
✗ Incorrect
The -m option runs only tests that have the specified marker.
What happens if you use a custom marker without registering it?
✗ Incorrect
Pytest warns about unknown markers if they are not registered.
Which file is best for defining markers used across many test files?
✗ Incorrect
pytest.ini is the central place to register markers for all tests.
Explain how to create and use a custom marker in pytest.
Think about registration, tagging, and running tests.
You got /3 concepts.
Why is it important to register custom markers in pytest.ini?
Consider what happens if you don't register.
You got /3 concepts.