aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/unittest/loader.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-12 07:53:52 +0300
committershadchin <shadchin@yandex-team.com>2024-02-12 08:07:36 +0300
commitce1b7ca3171f9158180640c6a02a74b4afffedea (patch)
treee47c1e8391b1b0128262c1e9b1e6ed4c8fff2348 /contrib/tools/python3/src/Lib/unittest/loader.py
parent57350d96f030db90f220ce50ee591d5c5d403df7 (diff)
downloadydb-ce1b7ca3171f9158180640c6a02a74b4afffedea.tar.gz
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Lib/unittest/loader.py')
-rw-r--r--contrib/tools/python3/src/Lib/unittest/loader.py37
1 files changed, 6 insertions, 31 deletions
diff --git a/contrib/tools/python3/src/Lib/unittest/loader.py b/contrib/tools/python3/src/Lib/unittest/loader.py
index f4e3d6e8f2..f7c1d61f41 100644
--- a/contrib/tools/python3/src/Lib/unittest/loader.py
+++ b/contrib/tools/python3/src/Lib/unittest/loader.py
@@ -6,7 +6,6 @@ import sys
import traceback
import types
import functools
-import warnings
from fnmatch import fnmatch, fnmatchcase
@@ -57,9 +56,7 @@ def _make_skipped_test(methodname, exception, suiteClass):
TestClass = type("ModuleSkipped", (case.TestCase,), attrs)
return suiteClass((TestClass(methodname),))
-def _jython_aware_splitext(path):
- if path.lower().endswith('$py.class'):
- return path[:-9]
+def _splitext(path):
return os.path.splitext(path)[0]
@@ -97,30 +94,8 @@ class TestLoader(object):
loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
return loaded_suite
- # XXX After Python 3.5, remove backward compatibility hacks for
- # use_load_tests deprecation via *args and **kws. See issue 16662.
- def loadTestsFromModule(self, module, *args, pattern=None, **kws):
+ def loadTestsFromModule(self, module, *, pattern=None):
"""Return a suite of all test cases contained in the given module"""
- # This method used to take an undocumented and unofficial
- # use_load_tests argument. For backward compatibility, we still
- # accept the argument (which can also be the first position) but we
- # ignore it and issue a deprecation warning if it's present.
- if len(args) > 0 or 'use_load_tests' in kws:
- warnings.warn('use_load_tests is deprecated and ignored',
- DeprecationWarning)
- kws.pop('use_load_tests', None)
- if len(args) > 1:
- # Complain about the number of arguments, but don't forget the
- # required `module` argument.
- complaint = len(args) + 1
- raise TypeError('loadTestsFromModule() takes 1 positional argument but {} were given'.format(complaint))
- if len(kws) != 0:
- # Since the keyword arguments are unsorted (see PEP 468), just
- # pick the alphabetically sorted first argument to complain about,
- # if multiple were given. At least the error message will be
- # predictable.
- complaint = sorted(kws)[0]
- raise TypeError("loadTestsFromModule() got an unexpected keyword argument '{}'".format(complaint))
tests = []
for name in dir(module):
obj = getattr(module, name)
@@ -349,7 +324,7 @@ class TestLoader(object):
def _get_name_from_path(self, path):
if path == self._top_level_dir:
return '.'
- path = _jython_aware_splitext(os.path.normpath(path))
+ path = _splitext(os.path.normpath(path))
_relpath = os.path.relpath(path, self._top_level_dir)
assert not os.path.isabs(_relpath), "Path must be within the project"
@@ -427,13 +402,13 @@ class TestLoader(object):
else:
mod_file = os.path.abspath(
getattr(module, '__file__', full_path))
- realpath = _jython_aware_splitext(
+ realpath = _splitext(
os.path.realpath(mod_file))
- fullpath_noext = _jython_aware_splitext(
+ fullpath_noext = _splitext(
os.path.realpath(full_path))
if realpath.lower() != fullpath_noext.lower():
module_dir = os.path.dirname(realpath)
- mod_name = _jython_aware_splitext(
+ mod_name = _splitext(
os.path.basename(full_path))
expected_dir = os.path.dirname(full_path)
msg = ("%r module incorrectly imported from %r. Expected "