Bird
0
0

You have a test module named test_api.py but pytest does not run any tests from it. What is the most likely cause?

medium Q6 of 15
PyTest - Test Organization
You have a test module named test_api.py but pytest does not run any tests from it. What is the most likely cause?
AThe module is located outside the current directory
BThe test functions inside do not start with 'test_'
CThe file is not saved with .py extension
DThe module name is too long
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest test function naming rules

    pytest only runs functions starting with test_ inside test modules.
  2. Step 2: Analyze why tests might not run

    If functions do not start with test_, pytest will not recognize them as tests, so no tests run.
  3. Final Answer:

    The test functions inside do not start with 'test_' -> Option B
  4. Quick Check:

    Test functions must start with 'test_' to be discovered [OK]

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes