Bird
0
0

Find the issue in this code snippet:

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

@pytest.mark.parametrize('val', [pytest.param(10, marks=pytest.mark.skipif(sys.platform == 'linux', reason='Skip Linux'))])
def test_val(val):
    assert val == 10
AThe platform string comparison is incorrect; should be 'linux' not 'Linux'
BThe skipif condition will skip tests on Linux correctly
CThe test will fail because val is not 10
DThe marks argument is missing
Step-by-Step Solution
Solution:
  1. Step 1: Check platform string case sensitivity

    sys.platform returns 'linux' in lowercase, so comparison is correct.
  2. Step 2: Confirm skipif usage

    Tests with val=10 will be skipped on Linux as intended.
  3. Final Answer:

    The skipif condition will skip tests on Linux correctly -> Option B
  4. Quick Check:

    Platform string is lowercase 'linux', skipif works [OK]
Quick Trick: Check exact sys.platform string values for skipif [OK]
Common Mistakes:
MISTAKES
  • Assuming platform string is capitalized
  • Thinking marks argument is missing
  • Confusing skipif condition logic

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes