Bird
0
0

Which filename pattern will pytest automatically detect as a test module when scanning a directory?

medium Q1 of 15
PyTest - Test Organization
Which filename pattern will pytest automatically detect as a test module when scanning a directory?
Atest_example.py
Bexample_test.py
Cexample.py
DTestExample.py
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest naming conventions

    pytest by default recognizes files starting with test_ or ending with _test.py as test modules.
  2. Step 2: Analyze each option

    • test_example.py starts with test_ so pytest detects it.
    • example_test.py ends with _test.py which is also valid and detected by pytest.
    • example.py does not follow naming conventions.
    • TestExample.py uses uppercase and does not start with test_.
  3. Final Answer:

    test_example.py and example_test.py -> Option A
  4. Quick Check:

    File must start with test_ or end with _test.py [OK]

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes