0
0
PyTesttesting~5 mins

pytest.ini configuration - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the pytest.ini file?
The pytest.ini file is used to configure pytest settings globally for a project. It helps set options like test paths, markers, and command-line flags so you don't have to type them every time.
Click to reveal answer
beginner
How do you specify the directory where pytest should look for tests in pytest.ini?
You use the testpaths option under the [pytest] section. For example:<br>
[pytest]
testpaths = tests
This tells pytest to look inside the tests folder for test files.
Click to reveal answer
intermediate
What is the use of the markers option in pytest.ini?
The markers option lets you declare custom markers to label tests. This helps organize or selectively run tests. For example:<br>
[pytest]
markers = slow: marks tests as slow to run
Click to reveal answer
intermediate
How can you add command-line options permanently using pytest.ini?
You can add default command-line options using the addopts setting. For example:<br>
[pytest]
addopts = -v --maxfail=2
This runs tests in verbose mode and stops after 2 failures.
Click to reveal answer
beginner
Where should the pytest.ini file be placed in your project?
Place pytest.ini in the root folder of your project. Pytest automatically finds it there and applies the settings when you run tests.
Click to reveal answer
What section header must be used in pytest.ini to configure pytest?
A[settings]
B[config]
C[pytest]
D[test]
Which option in pytest.ini sets the default command-line arguments?
Aaddopts
Bmarkers
Ctestpaths
Dlog_level
How do you declare a custom marker named 'slow' in pytest.ini?
Amarker = slow
Baddopts = slow
Ctestpaths = slow
Dmarkers = slow: marks slow tests
Where should you place the pytest.ini file for pytest to find it automatically?
AIn the root folder of the project
BInside the tests folder
CIn the home directory
DIn the Python installation folder
What does the testpaths option do in pytest.ini?
ASpecifies which tests to skip
BSpecifies directories where pytest looks for tests
CSets the verbosity level
DDefines test markers
Explain how to configure pytest to run tests only from a specific folder using pytest.ini.
Think about telling pytest where to look for tests.
You got /3 concepts.
    Describe how to add a custom marker and use it to label tests in pytest.ini.
    Markers help organize tests by labels.
    You got /3 concepts.