Bird
0
0

Identify the error in the following pytest code snippet:

medium📝 Debug Q14 of 15
PyTest - Markers
Identify the error in the following pytest code snippet:
import pytest

@pytest.mark.skipif(reason='No condition provided')
def test_example():
    assert True
AReason argument should be outside skipif
BIncorrect import statement for pytest
CMissing condition argument in skipif decorator
DMissing assert statement in test
Step-by-Step Solution
Solution:
  1. Step 1: Check skipif decorator usage

    @pytest.mark.skipif requires a condition argument to decide when to skip.
  2. Step 2: Identify missing condition

    Here, only reason is provided, no condition, so syntax is invalid.
  3. Final Answer:

    Missing condition argument in skipif decorator -> Option C
  4. Quick Check:

    skipif needs condition argument [OK]
Quick Trick: Always provide condition before reason in skipif [OK]
Common Mistakes:
MISTAKES
  • Omitting the condition argument
  • Placing reason before condition
  • Confusing skipif with skip

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes