Bird
0
0

A test module test_db.py has a function named check_connection() that is not running during pytest execution. How to fix this?

medium Q7 of 15
PyTest - Test Organization
A test module test_db.py has a function named check_connection() that is not running during pytest execution. How to fix this?
AImport the function in __init__.py
BAdd a decorator @pytest.test to the function
CMove the function to a different module
DRename the function to start with 'test_'
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest test function discovery

    pytest runs only functions starting with test_ by default.
  2. Step 2: Fix the function name to be recognized

    Renaming check_connection() to test_check_connection() will make pytest run it.
  3. Final Answer:

    Rename the function to start with 'test_' -> Option D
  4. Quick Check:

    Function names must start with 'test_' to run [OK]

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes