summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-06-26 07:18:06 (GMT)
committerGitHub <noreply@github.com>2022-06-26 07:18:06 (GMT)
commitc834c025695f598a0df3aba980257326a088044a (patch)
tree809a7f263324d9f15983e571d32e54fe6ebb8e0f /Lib/unittest
parent38612a05b5de33fde82d7960418527b7cfaa2e7c (diff)
downloadcpython-c834c025695f598a0df3aba980257326a088044a.zip
cpython-c834c025695f598a0df3aba980257326a088044a.tar.gz
cpython-c834c025695f598a0df3aba980257326a088044a.tar.bz2
Revert "bpo-45162: Revert "Remove many old deprecated unittest features"" (GH-92556)
This reverts commit b50322d20337ca468f2070eedb051a16ee1eba94.
Diffstat (limited to 'Lib/unittest')
-rw-r--r--Lib/unittest/__init__.py3
-rw-r--r--Lib/unittest/case.py50
-rw-r--r--Lib/unittest/loader.py24
-rw-r--r--Lib/unittest/runner.py9
4 files changed, 1 insertions, 85 deletions
diff --git a/Lib/unittest/__init__.py b/Lib/unittest/__init__.py
index b8de8c9..5bcbf83 100644
--- a/Lib/unittest/__init__.py
+++ b/Lib/unittest/__init__.py
@@ -69,9 +69,6 @@ from .signals import installHandler, registerResult, removeResult, removeHandler
# IsolatedAsyncioTestCase will be imported lazily.
from .loader import makeSuite, getTestCaseNames, findTestCases
-# deprecated
-_TextTestResult = TextTestResult
-
# Lazy import of IsolatedAsyncioTestCase from .async_case
# It imports asyncio, which is relatively heavy, but most tests
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index ffc8f19..af83033 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -1171,35 +1171,6 @@ class TestCase(object):
standardMsg = self._truncateMessage(standardMsg, diff)
self.fail(self._formatMessage(msg, standardMsg))
- def assertDictContainsSubset(self, subset, dictionary, msg=None):
- """Checks whether dictionary is a superset of subset."""
- warnings.warn('assertDictContainsSubset is deprecated',
- DeprecationWarning)
- missing = []
- mismatched = []
- for key, value in subset.items():
- if key not in dictionary:
- missing.append(key)
- elif value != dictionary[key]:
- mismatched.append('%s, expected: %s, actual: %s' %
- (safe_repr(key), safe_repr(value),
- safe_repr(dictionary[key])))
-
- if not (missing or mismatched):
- return
-
- standardMsg = ''
- if missing:
- standardMsg = 'Missing: %s' % ','.join(safe_repr(m) for m in
- missing)
- if mismatched:
- if standardMsg:
- standardMsg += '; '
- standardMsg += 'Mismatched values: %s' % ','.join(mismatched)
-
- self.fail(self._formatMessage(msg, standardMsg))
-
-
def assertCountEqual(self, first, second, msg=None):
"""Asserts that two iterables have the same elements, the same number of
times, without regard to order.
@@ -1363,27 +1334,6 @@ class TestCase(object):
raise self.failureException(msg)
- def _deprecate(original_func):
- def deprecated_func(*args, **kwargs):
- warnings.warn(
- 'Please use {0} instead.'.format(original_func.__name__),
- DeprecationWarning, 2)
- return original_func(*args, **kwargs)
- return deprecated_func
-
- # see #9424
- failUnlessEqual = assertEquals = _deprecate(assertEqual)
- failIfEqual = assertNotEquals = _deprecate(assertNotEqual)
- failUnlessAlmostEqual = assertAlmostEquals = _deprecate(assertAlmostEqual)
- failIfAlmostEqual = assertNotAlmostEquals = _deprecate(assertNotAlmostEqual)
- failUnless = assert_ = _deprecate(assertTrue)
- failUnlessRaises = _deprecate(assertRaises)
- failIf = _deprecate(assertFalse)
- assertRaisesRegexp = _deprecate(assertRaisesRegex)
- assertRegexpMatches = _deprecate(assertRegex)
- assertNotRegexpMatches = _deprecate(assertNotRegex)
-
-
class FunctionTestCase(TestCase):
"""A test case that wraps a test function.
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py
index 7e6ce2f..eb18cd0 100644
--- a/Lib/unittest/loader.py
+++ b/Lib/unittest/loader.py
@@ -93,30 +93,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)
diff --git a/Lib/unittest/runner.py b/Lib/unittest/runner.py
index cb452c7..6678adb 100644
--- a/Lib/unittest/runner.py
+++ b/Lib/unittest/runner.py
@@ -200,15 +200,6 @@ class TextTestRunner(object):
if self.warnings:
# if self.warnings is set, use it to filter all the warnings
warnings.simplefilter(self.warnings)
- # if the filter is 'default' or 'always', special-case the
- # warnings from the deprecated unittest methods to show them
- # no more than once per module, because they can be fairly
- # noisy. The -Wd and -Wa flags can be used to bypass this
- # only when self.warnings is None.
- if self.warnings in ['default', 'always']:
- warnings.filterwarnings('module',
- category=DeprecationWarning,
- message=r'Please use assert\w+ instead.')
startTime = time.perf_counter()
startTestRun = getattr(result, 'startTestRun', None)
if startTestRun is not None: