Bird
0
0

Which of the following is the correct syntax to mark a test function with a custom marker named database?

easy📝 Syntax Q3 of 15
PyTest - Markers
Which of the following is the correct syntax to mark a test function with a custom marker named database?
A@pytest.mark('database')\ndef test_func(): pass
B@pytest.database.mark\ndef test_func(): pass
C@mark.database\ndef test_func(): pass
D@pytest.mark.database\ndef test_func(): pass
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest marker syntax

    Markers are used as decorators with @pytest.mark.markername.
  2. Step 2: Check each option's syntax

    Only @pytest.mark.database\ndef test_func(): pass uses the correct decorator format.
  3. Final Answer:

    @pytest.mark.database\ndef test_func(): pass -> Option D
  4. Quick Check:

    Correct marker syntax = @pytest.mark.name [OK]
Quick Trick: Use @pytest.mark.markername to mark tests [OK]
Common Mistakes:
MISTAKES
  • Using @pytest.database.mark instead of @pytest.mark.database
  • Omitting pytest or using wrong decorator syntax
  • Passing marker name as a string argument incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes