Bird
0
0

Identify the error in this pytest fixture usage:

medium📝 Debug Q14 of 15
PyTest - Fixtures
Identify the error in this pytest fixture usage:
import pytest

@pytest.fixture(scope='modul')
def setup_env():
    pass

def test_example(setup_env):
    assert True
AMissing @pytest.mark.usefixtures decorator.
BTypo in scope value causes fixture not to run.
CFixture function must return a value.
DTest function missing parentheses.
Step-by-Step Solution
Solution:
  1. Step 1: Check fixture scope spelling

    The scope value 'modul' is misspelled; correct is 'module'.
  2. Step 2: Understand effect of typo

    Pytest will not recognize the scope and may default or error, causing fixture not to run properly.
  3. Final Answer:

    Typo in scope value causes fixture not to run. -> Option B
  4. Quick Check:

    Scope must be spelled correctly [OK]
Quick Trick: Check scope spelling carefully to avoid errors [OK]
Common Mistakes:
MISTAKES
  • Assuming fixture must return a value
  • Confusing fixture decorator with marker
  • Ignoring spelling errors in parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes