Recall & Review
beginner
What is a marker in pytest?
A marker is a label you can add to tests to organize, select, or skip them during test runs.
Click to reveal answer
beginner
Why do you need to register markers in pytest?
To avoid warnings and to document custom markers so pytest knows they are valid and how to use them.
Click to reveal answer
beginner
Where do you register custom markers in pytest?
In the pytest.ini file under the [pytest] section using the markers option.
Click to reveal answer
beginner
Example of registering a custom marker named 'slow' in pytest.ini?
Add this line in pytest.ini:
markers = slow: marks tests as slow to run
Click to reveal answer
beginner
How do you run only tests marked with a registered marker 'slow'?
Use the command: pytest -m slow
Click to reveal answer
What happens if you use a custom marker without registering it in pytest.ini?
✗ Incorrect
Pytest warns you about unknown markers to encourage proper registration.
Where do you add marker registration in a pytest project?
✗ Incorrect
Markers are registered in pytest.ini to be recognized project-wide.
How do you mark a test as 'slow' in pytest after registering the marker?
✗ Incorrect
You use the decorator @pytest.mark.slow to mark the test.
What command runs only tests marked with 'slow'?
✗ Incorrect
The -m option filters tests by marker name.
Which section header is used in pytest.ini to register markers?
✗ Incorrect
Markers are registered under the [pytest] section.
Explain how to create and register a custom marker in pytest.
Think about configuration and usage steps.
You got /5 concepts.
Describe how to run tests selectively using markers in pytest.
Focus on command line usage.
You got /4 concepts.