Bird
0
0

Given this project layout:

medium📝 Predict Output Q4 of 15
PyTest - Basics and Setup
Given this project layout:
project/
  main.py
  tests/
    test_math.py
    helpers/
      test_helpers.py
Which command will execute all tests under tests/ including subdirectories?
Apytest tests
Bpytest tests/test_math.py
Cpytest main.py
Dpytest helpers/test_helpers.py
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest default behavior

    Running pytest tests runs all tests in tests/ and its subfolders.
  2. Step 2: Analyze options

    Options B and D run only specific files; C runs no tests as main.py is not a test file.
  3. Final Answer:

    pytest tests -> Option A
  4. Quick Check:

    Run pytest on the tests folder to execute all tests [OK]
Quick Trick: Run pytest on the tests folder to run all tests recursively [OK]
Common Mistakes:
MISTAKES
  • Running pytest on a single test file only
  • Running pytest on non-test source files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes