summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/runner.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2022-01-27 04:39:15 (GMT)
committerGitHub <noreply@github.com>2022-01-27 04:39:15 (GMT)
commitb50322d20337ca468f2070eedb051a16ee1eba94 (patch)
treeba478b8fe2b91b583cec640d518f9643fb5b6f7d /Lib/unittest/runner.py
parent9f0881476e0113d3a35e0ffa96649b9276dd75c5 (diff)
downloadcpython-b50322d20337ca468f2070eedb051a16ee1eba94.zip
cpython-b50322d20337ca468f2070eedb051a16ee1eba94.tar.gz
cpython-b50322d20337ca468f2070eedb051a16ee1eba94.tar.bz2
bpo-45162: Revert "Remove many old deprecated unittest features" (GH-30935)
Revert "bpo-45162: Remove many old deprecated unittest features (GH-28268)" This reverts commit b0a6ede3d0bd6fa4ffe413ab4dfc1059201df25b. We're deferring this change until 3.12 while upstream projects that use the legacy assertion method names are fixed. See the issue for links to the discussion. Many upstream projects now have issues and PRs filed.
Diffstat (limited to 'Lib/unittest/runner.py')
-rw-r--r--Lib/unittest/runner.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/unittest/runner.py b/Lib/unittest/runner.py
index 6678adb..cb452c7 100644
--- a/Lib/unittest/runner.py
+++ b/Lib/unittest/runner.py
@@ -200,6 +200,15 @@ 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: