diff options
Diffstat (limited to 'logutils/testing.py')
-rw-r--r-- | logutils/testing.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/logutils/testing.py b/logutils/testing.py index dfc8d21..3c61217 100644 --- a/logutils/testing.py +++ b/logutils/testing.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details. +# Copyright (C) 2010-2017 Vinay Sajip. See LICENSE.txt for details. # import logging from logging.handlers import BufferingHandler @@ -8,7 +8,7 @@ class TestHandler(BufferingHandler): """ This handler collects records in a buffer for later inspection by your unit test code. - + :param matcher: The :class:`~logutils.testing.Matcher` instance to use for matching. """ @@ -54,9 +54,9 @@ class TestHandler(BufferingHandler): Look for a saved dict whose keys/values match the supplied arguments. Return `True` if found, else `False`. - + :param kwargs: A set of keyword arguments whose names are LogRecord - attributes and whose values are what you want to + attributes and whose values are what you want to match in a stored LogRecord. """ result = False @@ -74,7 +74,7 @@ class TestHandler(BufferingHandler): buffer of stored records matches the list one-for-one. Return `True` if exactly matched, else `False`. - + :param kwarglist: A list of keyword-argument dictionaries, each of which will be passed to :meth:`matches` with the corresponding record from the buffer. @@ -102,14 +102,14 @@ class Matcher(object): :class:`logging.LogRecord` attributes with keyword arguments passed to its :meth:`~logutils.testing.Matcher.matches` method. """ - + _partial_matches = ('msg', 'message') """ A list of :class:`logging.LogRecord` attribute names which will be checked for partial matches. If not in this list, an exact match will be attempted. """ - + def matches(self, d, **kwargs): """ Try to match a single dict with the supplied arguments. @@ -117,11 +117,11 @@ class Matcher(object): Keys whose values are strings and which are in self._partial_matches will be checked for partial (i.e. substring) matches. You can extend this scheme to (for example) do regular expression matching, etc. - + Return `True` if found, else `False`. :param kwargs: A set of keyword arguments whose names are LogRecord - attributes and whose values are what you want to + attributes and whose values are what you want to match in a stored LogRecord. """ result = True @@ -153,4 +153,3 @@ class Matcher(object): #if not result: # print('*** matcher failed on %s: %r vs. %r' % (k, dv, v)) return result - |