Recall & Review
beginner
What is the main purpose of markers in pytest?
Markers help group and control tests so you can run specific sets easily, like running only slow tests or tests for a feature.
Click to reveal answer
beginner
How do markers improve test execution?
Markers let you select or skip tests based on labels, saving time by running only relevant tests.Click to reveal answer
beginner
Give an example of a common pytest marker and its use.
The marker @pytest.mark.slow labels tests that take longer. You can run only fast tests by skipping slow ones.
Click to reveal answer
intermediate
Why is categorizing tests with markers helpful in large projects?
It helps organize tests by feature, speed, or type, making it easier to manage and run tests efficiently.
Click to reveal answer
beginner
What command runs tests with a specific marker in pytest?
Use pytest -m <marker_name> to run only tests with that marker, for example pytest -m slow runs tests marked as slow.
Click to reveal answer
What does the pytest marker @pytest.mark.skip do?
✗ Incorrect
The @pytest.mark.skip marker tells pytest to skip the test when running.
How can you run only tests marked as 'fast' in pytest?
✗ Incorrect
The command pytest -m fast runs only tests marked with @pytest.mark.fast.
Why use markers to categorize tests?
✗ Incorrect
Markers help organize tests and decide which ones to run or skip.
Which pytest marker would you use to skip a test conditionally?
✗ Incorrect
@pytest.mark.skipif skips a test if a condition is true.
What happens if you run pytest without any markers?
✗ Incorrect
By default, pytest runs all tests regardless of markers unless filtered.
Explain why markers are useful for controlling test execution in pytest.
Think about how you might want to run only some tests in a big project.
You got /4 concepts.
Describe how you would use markers to run only slow tests in pytest.
Consider labeling tests and using a command to filter them.
You got /3 concepts.