Bird
0
0

Identify the error in the following pytest test class:

medium📝 Debug Q14 of 15
PyTest - Test Organization
Identify the error in the following pytest test class:
class TestCalc:
    def test_multiply(self):
        assert 2 * 3 == 6
    
    def multiply_test(self):
        assert 4 * 5 == 20
AMethod 'multiply_test' will not be recognized as a test
BClass name must not start with 'Test'
CMissing assert statement in 'test_multiply'
DIndentation error in method definitions
Step-by-Step Solution
Solution:
  1. Step 1: Check method naming rules

    Pytest requires test methods to start with 'test_'. 'multiply_test' does not.
  2. Step 2: Understand consequences

    Method 'multiply_test' will be ignored by pytest and not run as a test.
  3. Final Answer:

    Method 'multiply_test' will not be recognized as a test -> Option A
  4. Quick Check:

    Test methods start with 'test_' = A [OK]
Quick Trick: Test methods must start with 'test_' [OK]
Common Mistakes:
MISTAKES
  • Thinking class name can't start with 'Test'
  • Missing assert in test method
  • Assuming indentation error without evidence

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes