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 = testsThis 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=2This 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?✗ Incorrect
The correct section header is [pytest]. This tells pytest to read the options under this section.
Which option in
pytest.ini sets the default command-line arguments?✗ Incorrect
The addopts option lets you specify default command-line arguments for pytest.
How do you declare a custom marker named 'slow' in
pytest.ini?✗ Incorrect
You declare custom markers under the markers option with a description.
Where should you place the
pytest.ini file for pytest to find it automatically?✗ Incorrect
pytest looks for pytest.ini in the root folder of your project.
What does the
testpaths option do in pytest.ini?✗ Incorrect
testpaths tells pytest which directories to search for test files.
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.