Bird
0
0

In this structure:

medium📝 Debug Q7 of 15
PyTest - Basics and Setup
In this structure:
project/
  tests/
    test_api.py
    helpers/
      helper.py
Running pytest does not run tests inside helper.py. Why?
Apytest cannot run tests in subfolders
Bhelpers folder is missing __init__.py
Ctest_api.py is empty
Dhelper.py is not named as a test file
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest test file naming conventions

    pytest runs tests only in files named starting with test_ or ending with _test.py.
  2. Step 2: Check helper.py name

    helper.py does not follow naming rules, so tests inside won't run.
  3. Final Answer:

    helper.py is not named as a test file -> Option D
  4. Quick Check:

    Test file names must start with 'test_' [OK]
Quick Trick: Test files must be named with 'test_' prefix [OK]
Common Mistakes:
MISTAKES
  • Expecting pytest to run tests in any .py file
  • Assuming __init__.py affects test discovery

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes