Recall & Review
beginner
What is the purpose of the pytest-timeout plugin?
pytest-timeout is used to set a maximum time limit for test functions. If a test runs longer than the specified time, it is stopped and marked as failed.
Click to reveal answer
beginner
How do you apply a timeout of 5 seconds to a single test function using pytest-timeout?
You add the decorator
@pytest.mark.timeout(5) above the test function to limit its execution time to 5 seconds.Click to reveal answer
beginner
What happens if a test exceeds the timeout set by pytest-timeout?
The test is interrupted and marked as failed with a timeout error, helping to catch tests that hang or run too long.
Click to reveal answer
intermediate
How can you set a global timeout for all tests in pytest using pytest-timeout?
You can add
timeout = 5 in the pytest.ini configuration file under the [pytest] section to apply a 5-second timeout to all tests.Click to reveal answer
beginner
Why is it useful to set time limits on tests?
Setting time limits helps detect infinite loops, slow tests, or deadlocks early, improving test suite reliability and speed.
Click to reveal answer
Which pytest-timeout decorator sets a 10-second limit on a test?
✗ Incorrect
The correct decorator is @pytest.mark.timeout(10) to set a 10-second timeout.
What happens when a test exceeds the timeout set by pytest-timeout?
✗ Incorrect
The test is stopped and marked as failed due to timeout.
Where do you configure a global timeout for all tests using pytest-timeout?
✗ Incorrect
Global timeout is set in pytest.ini under the [pytest] section.
Which of these is NOT a benefit of using pytest-timeout?
✗ Incorrect
pytest-timeout does not fix bugs; it only stops tests that run too long.
How do you install pytest-timeout?
✗ Incorrect
The correct package name is pytest-timeout.
Explain how to set a timeout for a single test and what happens if the test exceeds this timeout.
Think about the decorator and test failure behavior.
You got /4 concepts.
Describe how to configure a global timeout for all tests in pytest using pytest-timeout.
Consider pytest configuration files.
You got /4 concepts.