Bird
0
0

You have a test module named test_math.py with this code:

medium📝 Debug Q14 of 15
PyTest - Test Organization
You have a test module named test_math.py with this code:
def test_multiply():
    assert 2 * 3 == 5

When you run pytest, what will happen?
AThe test will fail because the assertion is incorrect.
Bpytest will not find any tests to run.
Cpytest will skip the test because of a syntax error.
DThe test will pass because 2 * 3 equals 6.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the assertion in test_multiply

    The assertion checks if 2 * 3 == 5, which is false because 2 * 3 equals 6.
  2. Step 2: Understand pytest test result

    pytest runs the test and finds the assertion false, so the test fails.
  3. Final Answer:

    The test will fail because the assertion is incorrect. -> Option A
  4. Quick Check:

    False assertion causes test failure [OK]
Quick Trick: Check if assertion condition is true or false [OK]
Common Mistakes:
MISTAKES
  • Assuming test passes despite wrong assertion
  • Confusing syntax errors with assertion failures
  • Thinking pytest skips failing tests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes