Recall & Review
beginner
What is the purpose of the
pyproject.toml file in pytest?The
pyproject.toml file is used to configure pytest settings in a simple, centralized way without needing command-line options or separate config files.Click to reveal answer
intermediate
How do you specify the minimum pytest version required in
pyproject.toml?Use the
minversion option under [tool.pytest.ini_options], for example: <br>[tool.pytest.ini_options] minversion = "7.0"
Click to reveal answer
beginner
Which section header is used in
pyproject.toml to configure pytest options?The section header is
[tool.pytest.ini_options]. Under this, you can set options like addopts, testpaths, and others.Click to reveal answer
intermediate
How do you add extra command-line options like verbose mode in
pyproject.toml for pytest?Use the
addopts option under [tool.pytest.ini_options], for example: <br>addopts = "-v --maxfail=2"to run tests verbosely and stop after 2 failures.
Click to reveal answer
intermediate
Can you configure test discovery paths in
pyproject.toml? How?Yes. Use the
testpaths option under [tool.pytest.ini_options] to list directories or files where pytest looks for tests, e.g.: <br>testpaths = ["tests", "integration"]
Click to reveal answer
Which section header is correct to configure pytest in
pyproject.toml?✗ Incorrect
The correct section header for pytest configuration in pyproject.toml is [tool.pytest.ini_options].
How do you add verbose output to pytest runs using
pyproject.toml?✗ Incorrect
You add command-line options like verbose mode using addopts = "-v" under [tool.pytest.ini_options].
What does the
testpaths option do in pyproject.toml for pytest?✗ Incorrect
testpaths tells pytest where to find test files to run.
Which of these is a valid way to stop pytest after 3 failures using
pyproject.toml?✗ Incorrect
You use addopts = "--maxfail=3" to pass this option to pytest.
Is it possible to configure pytest entirely using
pyproject.toml without command-line arguments?✗ Incorrect
pytest supports configuring all common options in pyproject.toml under [tool.pytest.ini_options].
Explain how to configure pytest options using the pyproject.toml file.
Think about the section header and common options you can set.
You got /4 concepts.
Describe the benefits of using pyproject.toml for pytest configuration instead of command-line arguments.
Consider how configuration files help in projects.
You got /5 concepts.