Bird
0
0

Which filename will pytest automatically recognize as a test file when running tests?

easy📝 Syntax Q3 of 15
PyTest - Basics and Setup
Which filename will pytest automatically recognize as a test file when running tests?
Autils.py
Butils_test.py
CTestUtils.py
Dtest_utils.py
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest test file naming rules

    Pytest discovers test files that start with test_ or end with _test.py, but the recommended and most reliable pattern is starting with test_.
  2. Step 2: Evaluate each option

    • test_utils.py starts with test_ - valid.
    • utils_test.py ends with _test.py - also valid but less common.
    • TestUtils.py starts with uppercase 'T' - pytest is case-sensitive and expects lowercase test_.
    • utils.py does not follow naming conventions - invalid.
  3. Step 3: Choose the best answer

    Both A and B are valid, but A is the most standard and recommended.
  4. Final Answer:

    test_utils.py -> Option D
  5. Quick Check:

    Test files start with 'test_' lowercase [OK]
Quick Trick: Test files start with 'test_' prefix [OK]
Common Mistakes:
MISTAKES
  • Using uppercase 'Test' prefix
  • Not starting or ending filename with 'test'
  • Using generic names without 'test' keyword

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes