Recall & Review
beginner
Why should test files in pytest start with
test_?Pytest automatically discovers test files that start with
test_ or end with _test.py. This naming helps pytest find and run your tests without extra configuration.Click to reveal answer
beginner
What is the recommended naming pattern for test functions in pytest?
Test functions should start with
test_. For example, def test_addition():. This allows pytest to recognize and run them as tests.Click to reveal answer
beginner
Can you name a test file
calculator.py and expect pytest to run tests inside it automatically?No. Pytest will not discover tests in files without the
test_ prefix or _test.py suffix. The file should be named like test_calculator.py.Click to reveal answer
beginner
What happens if a test function does not start with
test_ in pytest?Pytest will ignore the function because it does not match the naming pattern for test functions. Only functions starting with
test_ are run as tests.Click to reveal answer
beginner
Why is consistent naming important in test files and functions?
Consistent naming helps pytest find tests automatically, keeps your project organized, and makes it easier for others to understand and run your tests.
Click to reveal answer
Which of these is a valid pytest test file name?
✗ Incorrect
Pytest recognizes files starting with 'test_' or ending with '_test.py'. Only 'test_math.py' fits this pattern.
How should you name a test function for pytest to recognize it?
✗ Incorrect
Test functions must start with 'test_' for pytest to discover and run them.
If a test file is named
calculator.py, what will pytest do?✗ Incorrect
Pytest ignores files without 'test_' prefix or '_test.py' suffix during automatic test discovery.
What prefix should test functions have in pytest?
✗ Incorrect
The 'test_' prefix is required for pytest to recognize functions as tests.
Why is it important to follow naming conventions in pytest?
✗ Incorrect
Naming conventions help pytest discover tests without extra setup.
Explain the naming conventions for test files and test functions in pytest and why they matter.
Think about how pytest finds tests without manual configuration.
You got /4 concepts.
What happens if you name a test function without the 'test_' prefix in pytest?
Consider how pytest identifies test functions.
You got /3 concepts.