GH-70647: Deprecate strptime day of month parsing without a year present to avoid leap-year bugs (GH-117107)

This commit is contained in:
Gregory P. Smith 2024-04-03 05:19:49 -07:00 committed by GitHub
parent 595bb496b0
commit 33ee5cb3e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 117 additions and 1 deletions

View file

@ -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