But pytest gives a warning about unknown markers. What is the likely cause?
medium
A. Markers need to be registered with full description and no typos
B. Missing a blank line after [pytest] section
C. Markers must be listed under [tool:pytest] section
D. python_files setting conflicts with markers
Solution
Step 1: Check marker registration format
Markers must be registered exactly with correct spelling and description.
Step 2: Understand warning cause
Warnings usually occur if marker name is misspelled or description is missing.
Final Answer:
Markers need to be registered with full description and no typos -> Option A
Quick Check:
Correct marker registration avoids warnings [OK]
Hint: Check marker spelling and description carefully [OK]
Common Mistakes:
Placing markers under wrong section
Forgetting marker description after colon
Assuming python_files affects markers
5. You want pytest to automatically ignore tests in the legacy_tests folder without typing command line options. How do you configure setup.cfg to do this?
hard
A. [pytest]
markers = ignore: skip legacy tests
B. [pytest]
python_files = test_*.py
ignore = legacy_tests
C. [pytest]
addopts = --ignore=legacy_tests
D. [pytest]
filterwarnings = ignore::legacy_tests
Solution
Step 1: Identify option to ignore folders
The --ignore=folder option tells pytest to skip that folder.
Step 2: Set addopts in setup.cfg
Adding addopts = --ignore=legacy_tests runs pytest with this option automatically.
Final Answer:
[pytest]\naddopts = --ignore=legacy_tests -> Option C
Quick Check:
addopts sets default command line options [OK]
Hint: Use addopts to add default command line options [OK]
Common Mistakes:
Using ignore key instead of addopts
Confusing markers with ignore settings
Using filterwarnings incorrectly for ignoring tests
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.