Recall & Review
beginner
What is the purpose of the
addopts setting in pytest?The
addopts setting in pytest allows you to specify default command-line options that pytest will use every time it runs. This helps avoid typing common options repeatedly.Click to reveal answer
beginner
Where do you add the
addopts setting to configure default pytest options?You add the
addopts setting in the pytest.ini file or other pytest configuration files like tox.ini or setup.cfg.Click to reveal answer
beginner
Example: How to set pytest to always show detailed test output by default using
addopts?In
pytest.ini, add:<br>[pytest] addopts = -v<br>This makes pytest run with verbose output every time without typing
-v.Click to reveal answer
intermediate
Can command-line options override
addopts settings?Yes. Options given directly on the command line when running pytest will override the defaults set in
addopts.Click to reveal answer
intermediate
Why is using
addopts helpful in a team environment?Using
addopts ensures everyone runs pytest with the same default options, leading to consistent test runs and easier debugging.Click to reveal answer
Where is the
addopts setting typically placed to set default pytest options?✗ Incorrect
The
addopts setting is placed in configuration files like pytest.ini to apply default options globally.What happens if you run pytest with a command-line option that conflicts with
addopts?✗ Incorrect
Command-line options have higher priority and override the defaults set in
addopts.Which of these is a valid use of
addopts in pytest.ini?✗ Incorrect
Option C correctly sets default command-line options for pytest in the config file.
Why might you want to use
addopts instead of typing options every time?✗ Incorrect
addopts helps run tests consistently and saves typing effort.Which file can also contain
addopts besides pytest.ini?✗ Incorrect
tox.ini can include pytest configuration including addopts.Explain how to use
addopts to set default pytest options and why it is useful.Think about how to save time and keep test runs consistent.
You got /5 concepts.
Describe a scenario where using
addopts improves teamwork in testing.Consider how shared settings help a team.
You got /4 concepts.