Bird
0
0

Given this project structure:

medium📝 Predict Output Q13 of 15
PyTest - Basics and Setup
Given this project structure:
project/
  app.py
  tests/
    test_math.py
    utils/
      test_utils.py
Which files will pytest run by default when you run pytest in the project root?
AOnly <code>tests/utils/test_utils.py</code>
BOnly <code>tests/test_math.py</code>
CBoth <code>tests/test_math.py</code> and <code>tests/utils/test_utils.py</code>
DNo tests run because of subfolder
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest recursive discovery

    pytest looks inside the tests/ folder and all its subfolders for files starting with test_.
  2. Step 2: Identify test files

    Both test_math.py and test_utils.py match naming rules and are inside tests/ or its subfolder.
  3. Final Answer:

    Both tests/test_math.py and tests/utils/test_utils.py -> Option C
  4. Quick Check:

    pytest finds tests recursively in tests/ [OK]
Quick Trick: pytest finds test files recursively inside tests/ folder [OK]
Common Mistakes:
MISTAKES
  • Thinking pytest ignores subfolders
  • Assuming only root tests/ files run
  • Believing subfolders need special config

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes