0
0
PyTesttesting~5 mins

setup.cfg configuration in PyTest - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A[pytest]
B[tool:pytest]
C[pytest-config]
D[tool:python]
How do you tell pytest to look for tests in the tests folder using setup.cfg?
Atests_folder = tests
Btestdir = tests
Ctestpaths = tests
Dtest_location = tests
What does the addopts option do in setup.cfg?
AAdds extra command-line options to pytest runs
BSpecifies the test file extensions
CDefines the Python version to use
DSets the test timeout duration
If you want pytest to stop after 1 failure, how do you set this in setup.cfg?
Aaddopts = --maxfail=1
Bmaxfail = 1
Cfailfast = true
Dstop_after_fail = 1
Why might teams prefer setup.cfg over command-line options for pytest?
AIt runs tests faster
BIt disables all warnings
CIt automatically fixes test failures
DIt ensures consistent test settings for everyone
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.