Bird
0
0

Find the error in this pytest code:

medium📝 Debug Q7 of 15
PyTest - Parametrize
Find the error in this pytest code:
import pytest

@pytest.mark.parametrize('a,b', [(1, 2), (3, 4)])
def test_sum(a, b):
    assert a + b = 3
AAssignment operator used instead of comparison in assertion
BParameter names should be a list, not a string
CParametrize decorator missing parentheses
DTest function missing return statement
Step-by-Step Solution
Solution:
  1. Step 1: Review assertion syntax

    The assertion uses '=' which is assignment, not comparison.
  2. Step 2: Correct syntax

    It should use '==' to compare values in assert statements.
  3. Final Answer:

    Assignment operator used instead of comparison in assertion -> Option A
  4. Quick Check:

    Use '==' for comparisons in assert [OK]
Quick Trick: Use '==' in assert, not '=' [OK]
Common Mistakes:
MISTAKES
  • Using '=' instead of '==' in assert
  • Wrong param names format
  • Missing parentheses in decorator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes