aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/unittest/loader.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2023-10-03 23:32:21 +0300
committershadchin <shadchin@yandex-team.com>2023-10-03 23:48:51 +0300
commit01ffd024041ac933854c367fb8d1b5682d19883f (patch)
treeb70aa497ba132a133ccece49f7763427dcd0743f /contrib/tools/python3/src/Lib/unittest/loader.py
parenta33fdb9a34581fd124e92535153b1f1fdeca6aaf (diff)
downloadydb-01ffd024041ac933854c367fb8d1b5682d19883f.tar.gz
Update Python 3 to 3.11.6
Diffstat (limited to 'contrib/tools/python3/src/Lib/unittest/loader.py')
-rw-r--r--contrib/tools/python3/src/Lib/unittest/loader.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/contrib/tools/python3/src/Lib/unittest/loader.py b/contrib/tools/python3/src/Lib/unittest/loader.py
index 7e6ce2f224b..f4e3d6e8f27 100644
--- a/contrib/tools/python3/src/Lib/unittest/loader.py
+++ b/contrib/tools/python3/src/Lib/unittest/loader.py
@@ -87,9 +87,13 @@ class TestLoader(object):
raise TypeError("Test cases should not be derived from "
"TestSuite. Maybe you meant to derive from "
"TestCase?")
- testCaseNames = self.getTestCaseNames(testCaseClass)
- if not testCaseNames and hasattr(testCaseClass, 'runTest'):
- testCaseNames = ['runTest']
+ if testCaseClass in (case.TestCase, case.FunctionTestCase):
+ # We don't load any tests from base types that should not be loaded.
+ testCaseNames = []
+ else:
+ testCaseNames = self.getTestCaseNames(testCaseClass)
+ if not testCaseNames and hasattr(testCaseClass, 'runTest'):
+ testCaseNames = ['runTest']
loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
return loaded_suite
@@ -120,7 +124,11 @@ class TestLoader(object):
tests = []
for name in dir(module):
obj = getattr(module, name)
- if isinstance(obj, type) and issubclass(obj, case.TestCase):
+ if (
+ isinstance(obj, type)
+ and issubclass(obj, case.TestCase)
+ and obj not in (case.TestCase, case.FunctionTestCase)
+ ):
tests.append(self.loadTestsFromTestCase(obj))
load_tests = getattr(module, 'load_tests', None)
@@ -189,7 +197,11 @@ class TestLoader(object):
if isinstance(obj, types.ModuleType):
return self.loadTestsFromModule(obj)
- elif isinstance(obj, type) and issubclass(obj, case.TestCase):
+ elif (
+ isinstance(obj, type)
+ and issubclass(obj, case.TestCase)
+ and obj not in (case.TestCase, case.FunctionTestCase)
+ ):
return self.loadTestsFromTestCase(obj)
elif (isinstance(obj, types.FunctionType) and
isinstance(parent, type) and