@@ -52,6 +52,7 @@ def testMultiply(self):
5252 'addModuleCleanup' ]
5353
5454# Expose obsolete functions for backwards compatibility
55+ # bpo-5846: Deprecated in Python 3.11, scheduled for removal in Python 3.13.
5556__all__ .extend (['getTestCaseNames' , 'makeSuite' , 'findTestCases' ])
5657
5758__unittest = True
@@ -60,8 +61,7 @@ def testMultiply(self):
6061from .case import (addModuleCleanup , TestCase , FunctionTestCase , SkipTest , skip ,
6162 skipIf , skipUnless , expectedFailure )
6263from .suite import BaseTestSuite , TestSuite
63- from .loader import (TestLoader , defaultTestLoader , makeSuite , getTestCaseNames ,
64- findTestCases )
64+ from .loader import TestLoader , defaultTestLoader
6565from .main import TestProgram , main
6666from .runner import TextTestRunner , TextTestResult
6767from .signals import installHandler , registerResult , removeResult , removeHandler
@@ -70,6 +70,37 @@ def testMultiply(self):
7070# deprecated
7171_TextTestResult = TextTestResult
7272
73+ from .loader import (
74+ makeSuite as _makeSuite ,
75+ findTestCases as _findTestCases ,
76+ getTestCaseNames as _getTestCaseNames ,
77+ )
78+
79+ import warnings
80+ def makeSuite (* args , ** kwargs ):
81+ warnings .warn (
82+ "unittest.makeSuite() is deprecated and will be removed in Python 3.13. "
83+ "Please use unittest.TestLoader.loadTestsFromTestCase() instead." ,
84+ DeprecationWarning , stacklevel = 2
85+ )
86+ return _makeSuite (* args , ** kwargs )
87+
88+ def getTestCaseNames (* args , ** kwargs ):
89+ warnings .warn (
90+ "unittest.getTestCaseNames() is deprecated and will be removed in Python 3.13. "
91+ "Please use unittest.TestLoader.getTestCaseNames() instead." ,
92+ DeprecationWarning , stacklevel = 2
93+ )
94+ return _getTestCaseNames (* args , ** kwargs )
95+
96+ def findTestCases (* args , ** kwargs ):
97+ warnings .warn (
98+ "unittest.findTestCases() is deprecated and will be removed in Python 3.13. "
99+ "Please use unittest.TestLoader.loadTestsFromModule() instead." ,
100+ DeprecationWarning , stacklevel = 2
101+ )
102+ return _findTestCases (* args , ** kwargs )
103+
73104# There are no tests here, so don't try to run anything discovered from
74105# introspecting the symbols (e.g. FunctionTestCase). Instead, all our
75106# tests come from within unittest.test.
0 commit comments