Bird
0
0

You have a test file named TestExample.py with a function def test_func():. When running pytest, no tests are found. What is the likely cause?

medium📝 Debug Q6 of 15
PyTest - Basics and Setup
You have a test file named TestExample.py with a function def test_func():. When running pytest, no tests are found. What is the likely cause?
AFile name has uppercase letters
BFunction name does not start with 'test_'
CMissing assert statement in test function
DTest function is not indented
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest file discovery rules

    Pytest looks for files named test_*.py or *_test.py in lowercase.
  2. Step 2: Analyze file name TestExample.py

    Uppercase letters in file names can cause pytest to skip the file.
  3. Final Answer:

    File name has uppercase letters -> Option A
  4. Quick Check:

    File names must be lowercase for pytest discovery [OK]
Quick Trick: Test file names must be lowercase for pytest to find them [OK]
Common Mistakes:
MISTAKES
  • Using uppercase letters in test file names
  • Assuming function name alone controls discovery
  • Forgetting to save the file before running tests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes