Recall & Review
beginner
Why is it important to follow test naming conventions in pytest?
Following test naming conventions helps pytest automatically discover tests, makes tests easier to understand, and improves collaboration among team members.
Click to reveal answer
beginner
What prefix should pytest test functions start with?
Test functions should start with the prefix
test_ so pytest can recognize and run them automatically.Click to reveal answer
beginner
How should test names be written for clarity?
Test names should be descriptive and clear, explaining what the test checks, often using underscores to separate words, e.g.,
test_user_login_success.Click to reveal answer
intermediate
Can pytest test classes have any name?
No, test classes should start with
Test (capital T) and should not have an __init__ method to be discovered by pytest.Click to reveal answer
beginner
What happens if a test function does not start with
test_ in pytest?Pytest will not recognize or run the function as a test, so it will be ignored during test execution.
Click to reveal answer
Which prefix should pytest test functions start with?
✗ Incorrect
Pytest automatically discovers test functions that start with the prefix
test_.What is the recommended prefix for pytest test classes?
✗ Incorrect
Test classes should start with a capital
T as Test for pytest to discover them.Why should test names be descriptive?
✗ Incorrect
Descriptive test names help developers quickly understand the purpose of the test.
What happens if a test function is named
check_login instead of test_login?✗ Incorrect
Pytest ignores functions not starting with
test_ during test discovery.Which of these is a good test function name?
✗ Incorrect
Using lowercase with underscores and descriptive words like
test_user_login_success follows pytest naming conventions.Explain why pytest test functions must start with
test_ and how this affects test discovery.Think about how pytest finds tests to run.
You got /4 concepts.
Describe best practices for naming test functions and classes in pytest to improve readability and maintainability.
Consider clarity and pytest discovery rules.
You got /5 concepts.