Bird
0
0

You have two test modules: test_math.py and test_string.py. You want to run only tests from test_string.py. Which command should you use?

medium Q9 of 15
PyTest - Test Organization
You have two test modules: test_math.py and test_string.py. You want to run only tests from test_string.py. Which command should you use?
Apytest -m test_string
Bpytest test_string.py
Cpytest --module=test_string.py
Dpytest --only=test_string.py
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest command line options for running specific modules

    pytest accepts file or directory names as arguments to run tests only from those locations.
  2. Step 2: Identify correct command to run tests from a single module

    Running pytest test_string.py runs tests only from that file. Other options are invalid or unsupported.
  3. Final Answer:

    pytest test_string.py -> Option B
  4. Quick Check:

    Run tests from a file by passing its name to pytest [OK]

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes