Bird
0
0

Find the issue in this test suite setup:

medium📝 Debug Q7 of 15
Testing Fundamentals - Test Documentation
Find the issue in this test suite setup:
import unittest

def test_func():
    assert 1 == 1

suite = unittest.TestSuite()
suite.addTest(test_func)
runner = unittest.TextTestRunner()
runner.run(suite)
AaddTest requires unittest.TestCase instances, not plain functions
Bassert statement cannot be used in tests
CTextTestRunner cannot run suites
Dtest_func is missing a return statement
Step-by-Step Solution
Solution:
  1. Step 1: Understand unittest requirements

    unittest requires test cases to be methods inside unittest.TestCase subclasses.
  2. Step 2: Analyze code

    test_func is a plain function, not a TestCase instance, so addTest fails.
  3. Final Answer:

    addTest requires unittest.TestCase instances, not plain functions -> Option A
  4. Quick Check:

    unittest needs TestCase instances [OK]
Quick Trick: Only TestCase instances can be added to suites [OK]
Common Mistakes:
  • Adding plain functions to unittest suites
  • Thinking assert statements are invalid in tests
  • Assuming TextTestRunner can't run suites

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Testing Fundamentals Quizzes