Recall & Review
beginner
What is the purpose of command-line options in pytest?
Command-line options in pytest allow you to customize test runs, such as selecting tests, setting verbosity, or enabling features without changing the code.
Click to reveal answer
beginner
How do you run pytest with increased verbosity using command-line options?
Use the
-v or --verbose option to increase verbosity, showing more details about each test run.Click to reveal answer
intermediate
What does the
-k option do in pytest?The
-k option lets you run tests that match a specific expression or substring in their names, helping to select tests easily.Click to reveal answer
intermediate
Explain the use of the
--maxfail option in pytest.The
--maxfail=N option stops the test run after N failures, which helps save time by not running all tests if many fail.Click to reveal answer
beginner
How can you run tests from a specific file using pytest command-line options?
You can specify the test file path directly after the
pytest command, for example: pytest tests/test_example.py to run tests only from that file.Click to reveal answer
Which pytest option runs tests with detailed output?
✗ Incorrect
The
-v option increases verbosity, showing detailed output for each test.What does the
-k option do in pytest?✗ Incorrect
The
-k option filters tests by name or expression.How do you stop pytest after 3 test failures?
✗ Incorrect
Use
--maxfail=3 to stop after 3 failures.Which command runs tests only from a specific file?
✗ Incorrect
Specifying the file path runs tests only from that file.
What does the
-q option do in pytest?✗ Incorrect
The
-q option reduces output for a quieter test run.Describe how you can use pytest command-line options to select and control test execution.
Think about filtering tests and controlling output.
You got /4 concepts.
Explain why command-line options are useful when running tests with pytest.
Consider flexibility and efficiency.
You got /4 concepts.