mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
GH-70647: Deprecate strptime day of month parsing without a year present to avoid leap-year bugs (GH-117107)
This commit is contained in:
parent
595bb496b0
commit
33ee5cb3e9
7 changed files with 117 additions and 1 deletions
|
@ -332,6 +332,23 @@ class _AssertWarnsContext(_AssertRaisesBaseContext):
|
|||
self._raiseFailure("{} not triggered".format(exc_name))
|
||||
|
||||
|
||||
class _AssertNotWarnsContext(_AssertWarnsContext):
|
||||
|
||||
def __exit__(self, exc_type, exc_value, tb):
|
||||
self.warnings_manager.__exit__(exc_type, exc_value, tb)
|
||||
if exc_type is not None:
|
||||
# let unexpected exceptions pass through
|
||||
return
|
||||
try:
|
||||
exc_name = self.expected.__name__
|
||||
except AttributeError:
|
||||
exc_name = str(self.expected)
|
||||
for m in self.warnings:
|
||||
w = m.message
|
||||
if isinstance(w, self.expected):
|
||||
self._raiseFailure(f"{exc_name} triggered")
|
||||
|
||||
|
||||
class _OrderedChainMap(collections.ChainMap):
|
||||
def __iter__(self):
|
||||
seen = set()
|
||||
|
@ -811,6 +828,11 @@ class TestCase(object):
|
|||
context = _AssertWarnsContext(expected_warning, self)
|
||||
return context.handle('assertWarns', args, kwargs)
|
||||
|
||||
def _assertNotWarns(self, expected_warning, *args, **kwargs):
|
||||
"""The opposite of assertWarns. Private due to low demand."""
|
||||
context = _AssertNotWarnsContext(expected_warning, self)
|
||||
return context.handle('_assertNotWarns', args, kwargs)
|
||||
|
||||
def assertLogs(self, logger=None, level=None):
|
||||
"""Fail unless a log message of level *level* or higher is emitted
|
||||
on *logger_name* or its children. If omitted, *level* defaults to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue