Bird
0
0

How do you correctly apply a pytest marker named 'database' to a test function?

easy📝 Syntax Q3 of 15
PyTest - Test Organization
How do you correctly apply a pytest marker named 'database' to a test function?
A@pytest.mark.database def test_query(): pass
B@pytest.database def test_query(): pass
C@mark.database def test_query(): pass
D@pytest.mark('database') def test_query(): pass
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest marker syntax

    Markers are applied using @pytest.mark.
  2. Step 2: Apply marker correctly

    Use @pytest.mark.database before the test function definition.
  3. Final Answer:

    @pytest.mark.database\ndef test_query():\n pass -> Option A
  4. Quick Check:

    Markers require 'mark' attribute, not just 'database' [OK]
Quick Trick: Use @pytest.mark. to mark tests [OK]
Common Mistakes:
MISTAKES
  • Omitting 'mark' in the decorator
  • Using parentheses incorrectly with markers
  • Using undefined decorators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes