Bird
0
0

In a pytest project, where is the best place to keep your test scripts to ensure they are easily discoverable?

easy🧠 Conceptual Q1 of 15
PyTest - Basics and Setup
In a pytest project, where is the best place to keep your test scripts to ensure they are easily discoverable?
AInside the <code>docs/</code> folder
BMixed with source files in the <code>src/</code> folder
CIn a hidden folder named <code>.pytest/</code>
DInside a dedicated <code>tests/</code> directory at the root of the project
Step-by-Step Solution
Solution:
  1. Step 1: Identify pytest discovery conventions

    pytest automatically looks for tests inside a tests/ folder by default.
  2. Step 2: Understand project organization best practices

    Keeping tests separate from source code in a tests/ folder improves maintainability and clarity.
  3. Final Answer:

    Inside a dedicated tests/ directory at the root of the project -> Option D
  4. Quick Check:

    Tests belong in tests/ folder [OK]
Quick Trick: Use a root-level tests/ folder for pytest discovery [OK]
Common Mistakes:
MISTAKES
  • Placing tests inside source code folders
  • Using hidden or unrelated folders for tests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes