Recall & Review
beginner
What is the purpose of the
setup.cfg file in pytest?The
setup.cfg file is used to configure pytest settings and options in a simple, declarative way without needing command-line arguments.Click to reveal answer
beginner
How do you specify the directory where pytest should look for tests in
setup.cfg?You can specify the test directory using the
testpaths option under the [tool:pytest] section, for example:<br>[tool:pytest] testpaths = tests
Click to reveal answer
beginner
What section header is used in
setup.cfg to configure pytest options?The section header is
[tool:pytest]. All pytest options go under this section.Click to reveal answer
intermediate
How can you add command-line options like
--maxfail=2 and -v in setup.cfg?Use the
addopts option under [tool:pytest], for example:<br>[tool:pytest] addopts = -v --maxfail=2
Click to reveal answer
beginner
Why is using
setup.cfg for pytest configuration better than passing options via command line every time?It keeps configuration consistent and reusable across runs and team members, avoids mistakes from missing options, and makes automation easier.
Click to reveal answer
Which section header is correct for pytest settings in
setup.cfg?✗ Incorrect
The correct section header for pytest configuration in
setup.cfg is [tool:pytest].How do you tell pytest to look for tests in the
tests folder using setup.cfg?✗ Incorrect
The option
testpaths specifies directories where pytest looks for tests.What does the
addopts option do in setup.cfg?✗ Incorrect
addopts lets you add command-line options like -v or --maxfail=2 in the config file.If you want pytest to stop after 1 failure, how do you set this in
setup.cfg?✗ Incorrect
You use
addopts = --maxfail=1 to tell pytest to stop after one failure.Why might teams prefer
setup.cfg over command-line options for pytest?✗ Incorrect
Using
setup.cfg keeps test settings consistent and avoids forgetting options.Explain how to configure pytest to run tests in a specific folder and add verbose output using
setup.cfg.Think about the section header and the two main options for paths and extra command-line flags.
You got /3 concepts.
Describe the benefits of using
setup.cfg for pytest configuration instead of command-line arguments.Consider how configuration files help teams and automation.
You got /4 concepts.