Bird
0
0

Which of the following is the correct way to import a test module named test_math.py inside another test module?

medium Q3 of 15
PyTest - Test Organization
Which of the following is the correct way to import a test module named test_math.py inside another test module?
Aimport test-math
Bimport test_math
Cimport math
Dimport test_math.py
Step-by-Step Solution
Solution:
  1. Step 1: Understand Python import syntax for modules

    Module names must be valid Python identifiers without special characters like hyphens.
  2. Step 2: Check each option for syntax correctness

    A: import test-math invalid syntax due to hyphen.
    B: import test_math.py invalid; omit .py extension.
    C: import math imports standard library module.
    D: import test_math is correct.
  3. Final Answer:

    import test_math -> Option B
  4. Quick Check:

    Import modules using valid Python names without special characters [OK]

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes