Python Glossary Русский

all Python 3until 3.13unittestfunction

unittest.makeSuite()

removed

Built a test suite from a TestCase class. Removed in Python 3.13 — use TestLoader().loadTestsFromTestCase().

Syntax

unittest.makeSuite(MyTest)  # до 3.13

The old helper makeSuite(MyTest) collected the test_* methods of a class into a TestSuite. It was removed because it duplicated TestLoader and ignored its newer settings. To migrate, replace unittest.makeSuite(MyTest) with unittest.TestLoader().loadTestsFromTestCase(MyTest); if you passed prefix='check', set loader.testMethodPrefix = 'check' first. Run the suite as before with unittest.TextTestRunner().run(suite).

Examples

# Python 3.13+
import unittest
try:
    unittest.makeSuite
except AttributeError as e:
    print(type(e).__name__)  # → AttributeError
# Python 3.13+
import unittest
class MathTest(unittest.TestCase):
    def test_add(self):
        self.assertEqual(1 + 1, 2)
    def test_mul(self):
        self.assertEqual(2 * 3, 6)
suite = unittest.TestLoader().loadTestsFromTestCase(MathTest)
print(suite.countTestCases())  # → 2
import unittest
class MathTest(unittest.TestCase):
    def test_add(self):
        self.assertEqual(1 + 1, 2)
    def test_mul(self):
        self.assertEqual(2 * 3, 6)
suite = unittest.makeSuite(MathTest)
print(suite.countTestCases())  # → 2

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy