Bird
0
0

How should you correctly apply a 'slow' marker to a test function in pytest?

easy📝 Syntax Q3 of 15
PyTest - Markers
How should you correctly apply a 'slow' marker to a test function in pytest?
A@pytest.mark.slow def test_example(): pass
B@pytest.mark('slow') def test_example(): pass
C@pytest.mark.slow() def test_example(): pass
D@pytest.slow def test_example(): pass
Step-by-Step Solution
Solution:
  1. Step 1: Recall marker syntax

    Markers are applied as decorators with dot notation and no parentheses if no arguments.
  2. Step 2: Analyze options

    @pytest.mark.slow def test_example(): pass uses correct syntax: @pytest.mark.slow without parentheses.
  3. Final Answer:

    @pytest.mark.slow\ndef test_example(): pass -> Option A
  4. Quick Check:

    Markers without arguments do not use parentheses [OK]
Quick Trick: Use dot notation without parentheses for simple markers [OK]
Common Mistakes:
MISTAKES
  • Adding parentheses when no arguments are needed
  • Using incorrect decorator syntax
  • Confusing marker application with function calls

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes