diff options
Diffstat (limited to 'Lib/unittest/case.py')
| -rw-r--r-- | Lib/unittest/case.py | 12 | 
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index 52eb7d05ed..872f121127 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -295,7 +295,6 @@ class _AssertWarnsContext(_AssertRaisesBaseContext):              self._raiseFailure("{} not triggered".format(exc_name)) -  class _OrderedChainMap(collections.ChainMap):      def __iter__(self):          seen = set() @@ -788,7 +787,16 @@ class TestCase(object):          """          # Lazy import to avoid importing logging if it is not needed.          from ._log import _AssertLogsContext -        return _AssertLogsContext(self, logger, level) +        return _AssertLogsContext(self, logger, level, no_logs=False) + +    def assertNoLogs(self, logger=None, level=None): +        """ Fail unless no log messages of level *level* or higher are emitted +        on *logger_name* or its children. + +        This method must be used as a context manager. +        """ +        from ._log import _AssertLogsContext +        return _AssertLogsContext(self, logger, level, no_logs=True)      def _getAssertEqualityFunc(self, first, second):          """Get a detailed comparison function for the types of the two args.  | 
