Bird
0
0

You have nested test files: tests/test_math.py and tests/helpers/test_utils.py. Which files will pytest run tests from by default?

hard🚀 Application Q9 of 15
PyTest - Basics and Setup
You have nested test files: tests/test_math.py and tests/helpers/test_utils.py. Which files will pytest run tests from by default?
AOnly <code>tests/test_math.py</code>
BBoth <code>tests/test_math.py</code> and <code>tests/helpers/test_utils.py</code>
COnly <code>tests/helpers/test_utils.py</code>
DNeither file
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest recursive discovery

    Pytest recursively searches directories for files named test_*.py or *_test.py.
  2. Step 2: Check both file names

    Both files start with test_, so pytest will run tests from both.
  3. Final Answer:

    Both tests/test_math.py and tests/helpers/test_utils.py -> Option B
  4. Quick Check:

    Pytest finds all test files recursively by default [OK]
Quick Trick: Pytest finds test files recursively in subfolders [OK]
Common Mistakes:
MISTAKES
  • Assuming pytest only runs tests in top-level folder
  • Thinking helper folders are skipped automatically
  • Confusing file naming with folder naming

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes