Bird
0
0

Which file name must be used for pytest to automatically discover shared fixtures?

easy🧠 Conceptual Q2 of 15
PyTest - Fixtures
Which file name must be used for pytest to automatically discover shared fixtures?
Afixtures.py
Bconftest.py
Cshared_fixtures.py
Dsetup.py
Step-by-Step Solution
Solution:
  1. Step 1: Identify pytest fixture discovery rules

    pytest automatically discovers fixtures defined in files named conftest.py.
  2. Step 2: Understand naming conventions

    Other file names like fixtures.py or setup.py are not automatically used for fixture discovery.
  3. Final Answer:

    conftest.py -> Option B
  4. Quick Check:

    Fixture discovery file = conftest.py [OK]
Quick Trick: Always name shared fixture files conftest.py [OK]
Common Mistakes:
MISTAKES
  • Using arbitrary file names expecting automatic discovery
  • Confusing setup.py with conftest.py
  • Placing fixtures in test files only

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes