Bird
0
0

You have nested test packages with __init__.py files and want to run only tests from a subpackage. Which command is correct?

hard🚀 Application Q9 of 15
PyTest - Test Organization
You have nested test packages with __init__.py files and want to run only tests from a subpackage. Which command is correct?
Apytest --subpackage tests/
Bpytest tests/__init__.py
Cpytest tests/
Dpytest tests/subpackage/
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest folder targeting

    pytest runs tests in the folder path given; specifying subfolder runs only those tests.
  2. Step 2: Analyze options

    pytest tests/subpackage/ runs tests in tests/subpackage/ only, which is the desired behavior.
  3. Final Answer:

    pytest tests/subpackage/ -> Option D
  4. Quick Check:

    Run tests in subfolder = pytest path/to/subfolder [OK]
Quick Trick: Run tests in subpackage by specifying its folder path [OK]
Common Mistakes:
MISTAKES
  • Trying to run __init__.py directly
  • Using invalid pytest options like --subpackage
  • Running top-level folder runs all tests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes