@@ -52,6 +52,7 @@ def testMultiply(self):
52
52
'addModuleCleanup' ]
53
53
54
54
# Expose obsolete functions for backwards compatibility
55
+ # bpo-5846: Deprecated in Python 3.11, scheduled for removal in Python 3.13.
55
56
__all__ .extend (['getTestCaseNames' , 'makeSuite' , 'findTestCases' ])
56
57
57
58
__unittest = True
@@ -60,8 +61,7 @@ def testMultiply(self):
60
61
from .case import (addModuleCleanup , TestCase , FunctionTestCase , SkipTest , skip ,
61
62
skipIf , skipUnless , expectedFailure )
62
63
from .suite import BaseTestSuite , TestSuite
63
- from .loader import (TestLoader , defaultTestLoader , makeSuite , getTestCaseNames ,
64
- findTestCases )
64
+ from .loader import TestLoader , defaultTestLoader
65
65
from .main import TestProgram , main
66
66
from .runner import TextTestRunner , TextTestResult
67
67
from .signals import installHandler , registerResult , removeResult , removeHandler
@@ -70,6 +70,37 @@ def testMultiply(self):
70
70
# deprecated
71
71
_TextTestResult = TextTestResult
72
72
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
+
73
104
# There are no tests here, so don't try to run anything discovered from
74
105
# introspecting the symbols (e.g. FunctionTestCase). Instead, all our
75
106
# tests come from within unittest.test.
0 commit comments