Bird
0
0

You want to create a custom marker db that accepts a parameter for database type (e.g., 'mysql'). How should you mark a test to pass 'mysql' as a parameter?

hard🚀 Application Q9 of 15
PyTest - Markers
You want to create a custom marker db that accepts a parameter for database type (e.g., 'mysql'). How should you mark a test to pass 'mysql' as a parameter?
A@pytest.mark.db('mysql')\ndef test_db(): pass
B@pytest.mark.db(mysql)\ndef test_db(): pass
C@pytest.mark.db[param='mysql']\ndef test_db(): pass
D@pytest.mark.db[param=mysql]\ndef test_db(): pass
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest marker parameter syntax

    Markers can be called like functions with parameters in parentheses.
  2. Step 2: Identify correct parameter passing

    Passing 'mysql' as a string argument requires quotes inside parentheses.
  3. Final Answer:

    @pytest.mark.db('mysql')\ndef test_db(): pass -> Option A
  4. Quick Check:

    Use parentheses and quotes to pass marker parameters [OK]
Quick Trick: Pass marker parameters like function arguments [OK]
Common Mistakes:
MISTAKES
  • Omitting quotes around string parameters
  • Using square brackets instead of parentheses
  • Passing parameters without quotes causing syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes