Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to specify the test paths in setup.cfg.
PyTest
[tool:pytest]
testpaths = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'src' instead of 'tests' for testpaths.
Leaving testpaths empty or missing.
✗ Incorrect
The 'testpaths' option in setup.cfg tells pytest where to find test files. Usually, tests are in the 'tests' folder.
2fill in blank
mediumComplete the code to add markers configuration in setup.cfg.
PyTest
[tool:pytest]
markers =
slow: marks tests as slow (skip with -m "not slow")
[1]: marks tests that need database access Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated marker names like 'fast' or 'ui' here.
Forgetting to add markers section.
✗ Incorrect
Markers help categorize tests. 'db' is commonly used for tests needing database access.
3fill in blank
hardFix the error in the setup.cfg snippet to correctly ignore cache directories.
PyTest
[tool:pytest]
addopts = --cache-clear --ignore=[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Ignoring 'cache' instead of '__pycache__'.
Using unrelated folders like 'build' or 'dist'.
✗ Incorrect
The '__pycache__' directory stores Python bytecode cache and should be ignored by pytest.
4fill in blank
hardFill both blanks to configure pytest to show detailed info and stop after first failure.
PyTest
[tool:pytest] addopts = [1] [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-q' which reduces output instead of '-v'.
Using '--maxfail=1' instead of '-x' for stopping early.
✗ Incorrect
The '-v' option shows detailed test info, and '-x' stops testing after the first failure.
5fill in blank
hardFill all three blanks to configure pytest to add markers, ignore cache, and set test paths.
PyTest
[tool:pytest] markers = [1]: marks tests needing network addopts = --ignore=[2] testpaths = [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing marker names or ignoring wrong folders.
Setting testpaths to wrong folder.
✗ Incorrect
The 'network' marker labels network tests, '__pycache__' is ignored, and 'tests' is the folder with test files.