C. test_addition, testMultiplication, and test_divide
D. test_addition only
Solution
Step 1: Identify pytest discovery rules for functions and methods
pytest finds functions starting with test_ and methods inside classes named Test* starting with test_.
Step 2: Analyze each function/method
test_addition is found; check_subtraction is ignored; testMultiplication is ignored due to camelCase; test_divide inside TestDivision class is found.
Final Answer:
test_addition and test_divide only -> Option A
Quick Check:
Functions/methods start with test_ = A [OK]
Hint: pytest finds test_ functions and test_ methods in Test* classes [OK]
Common Mistakes:
Assuming camelCase test names are found
Ignoring test methods inside Test classes
Thinking all functions are discovered
4. You wrote a test function named Test_login but pytest does not run it. What is the most likely reason?
medium
A. Function is inside a class without Test prefix
B. Function name contains uppercase letters
C. Function is missing parentheses
D. Function name does not start with lowercase test_
Solution
Step 1: Recall pytest naming rules for functions
pytest requires test functions to start with lowercase test_ exactly.
Step 2: Analyze the function name Test_login
It starts with uppercase T, so pytest ignores it.
Final Answer:
Function name does not start with lowercase test_ -> Option D
Quick Check:
Lowercase test_ prefix required = A [OK]
Hint: Test function names must start with lowercase test_ [OK]
Common Mistakes:
Using uppercase T in test function names
Assuming pytest finds any function with 'test' inside
Ignoring function naming case sensitivity
5. You want to write clear pytest test names that describe what they check. Which of the following is the best test function name for checking if a user can log in with valid credentials?
hard
A. test1
B. test_valid_user_login
C. test_login
D. test_user_login_with_valid_credentials_and_session_creation
Solution
Step 1: Consider clarity and brevity in test names
Good test names are clear but not overly long or vague.
Step 2: Evaluate each option
test_valid_user_login clearly states the test purpose concisely. test1 is vague. test_login is too general. test_user_login_with_valid_credentials_and_session_creation is too long and hard to read.
Final Answer:
test_valid_user_login -> Option B
Quick Check:
Clear and concise descriptive names = B [OK]
Hint: Choose clear, concise test names describing the check [OK]
Common Mistakes:
Using vague or generic names like test1
Writing overly long test names
Using names that don't describe the test purpose
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.