Bird
0
0

Which of the following function names will pytest recognize as a test function inside a test file?

easy🧠 Conceptual Q2 of 15
PyTest - Basics and Setup
Which of the following function names will pytest recognize as a test function inside a test file?
Atest_example_function
Bexample_test_function
Ccheck_example_function
DexampleFunctionTest
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest naming conventions

    Pytest requires test functions to start with test_ to be auto-discovered.
  2. Step 2: Analyze each option

    • test_example_function starts with test_ - valid.
    • example_test_function does not start with test_ - invalid.
    • check_example_function does not start with test_ - invalid.
    • exampleFunctionTest does not start with test_ - invalid.
  3. Final Answer:

    test_example_function -> Option A
  4. Quick Check:

    Test functions must start with test_ [OK]
Quick Trick: Test functions start with 'test_' prefix [OK]
Common Mistakes:
MISTAKES
  • Using suffix 'test' instead of prefix
  • Using camelCase instead of snake_case
  • Using 'check_' prefix instead of 'test_'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes