0
0
PyTesttesting~5 mins

pyproject.toml configuration in PyTest - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A[tool.pytest.settings]
B[pytest.config]
C[tool.pytest.ini_options]
D[pytest.ini]
How do you add verbose output to pytest runs using pyproject.toml?
Aaddopts = "-v" under [tool.pytest.ini_options]
Bverbose = true under [tool.pytest]
Cverbosity = 1 under [pytest]
Dverbose = yes under [tool.pytest.ini_options]
What does the testpaths option do in pyproject.toml for pytest?
ASets the output directory for test reports
BLists plugins to load
CDefines the Python version to use
DSpecifies directories or files where pytest looks for tests
Which of these is a valid way to stop pytest after 3 failures using pyproject.toml?
Amaxfail = 3
Baddopts = "--maxfail=3"
Cstop_after_failures = 3
Dfail_limit = 3
Is it possible to configure pytest entirely using pyproject.toml without command-line arguments?
AYes, all common pytest options can be set there
BNo, you must always use command-line options
COnly some options can be set in pyproject.toml
Dpyproject.toml is only for plugin configuration
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.