Bird
0
0

You want pytest to discover tests in files named 'check_*.py' and functions starting with 'check_'. How can you configure pytest to do this?

hard🚀 Application Q8 of 15
PyTest - Test Organization
You want pytest to discover tests in files named 'check_*.py' and functions starting with 'check_'. How can you configure pytest to do this?
ARename files to start with 'test_' and functions to start with 'test_'
BAdd 'python_files = check_*.py' and 'python_functions = check_*' in pytest.ini
CUse @pytest.mark.check decorator on all test functions
DSet environment variable PYTEST_DISCOVER=check
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest configuration options

    pytest.ini can set 'python_files' and 'python_functions' to customize discovery patterns.
  2. Step 2: Apply correct settings

    Setting 'python_files = check_*.py' and 'python_functions = check_*' tells pytest to discover those files and functions.
  3. Final Answer:

    Add 'python_files = check_*.py' and 'python_functions = check_*' in pytest.ini -> Option B
  4. Quick Check:

    Customize discovery via pytest.ini settings [OK]
Quick Trick: Use pytest.ini to customize file and function patterns [OK]
Common Mistakes:
MISTAKES
  • Thinking renaming files is the only way
  • Assuming decorators change discovery patterns
  • Believing environment variables control discovery

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes