Codebase list logbook / 514f7c4
New upstream version 1.4.0 IƱaki Malerba 5 years ago
6 changed file(s) with 76 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
1818 env:
1919 - DISABLE_LOGBOOK_CEXT=True
2020 - CYBUILD=True
21
2122 script:
2223 - pip install -e .[all]
24 - if [[ $GEVENT == 'True' ]] ; then pip install gevent; fi
2325 - py.test --cov=logbook -r s tests
26
2427 matrix:
2528 exclude:
2629 - python: pypy
2730 env: CYBUILD=True
2831 - python: pypy3
2932 env: CYBUILD=True
33 include:
34 - python: "3.6"
35 env: GEVENT=True CYBUILD=True
36 - python: "2.7"
37 env: GEVENT=True CYBUILD=True
38
3039 after_success:
3140 - coveralls
41
3242 notifications:
3343 email:
3444 recipients:
11 =================
22
33 Here you can see the full list of changes between each Logbook release.
4
5 Version 1.4.0
6 -------------
7
8 Released on May 15th, 2018
9
10 - Added support for checking if trace logs have been emitted in TestHandler (thanks @thedrow)
11
412
513 Version 1.3.0
614 -------------
0 __version__ = "1.3.0"
0 __version__ = "1.4.0"
2727
2828
2929 if has_gevent:
30 from gevent._threading import (Lock as ThreadLock,
31 RLock as ThreadRLock,
32 get_ident as thread_get_ident,
33 local as thread_local)
30 from gevent.monkey import get_original as _get_original
31 ThreadLock = _get_original('threading', 'Lock')
32 ThreadRLock = _get_original('threading', 'RLock')
33 try:
34 thread_get_ident = _get_original('threading', 'get_ident')
35 except AttributeError:
36 # In 2.7, this is called _get_ident
37 thread_get_ident = _get_original('threading', '_get_ident')
38 thread_local = _get_original('threading', 'local')
39
3440 from gevent.thread import get_ident as greenlet_get_ident
3541 from gevent.local import local as greenlet_local
3642 from gevent.lock import BoundedSemaphore
2727 from textwrap import dedent
2828
2929 from logbook.base import (
30 CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG, NOTSET, level_name_property,
30 CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG, TRACE, NOTSET, level_name_property,
3131 _missing, lookup_level, Flags, ContextObject, ContextStackManager,
3232 _datetime_factory)
3333 from logbook.helpers import (
10531053 def has_debugs(self):
10541054 """`True` if any :data:`DEBUG` records were found."""
10551055 return any(r.level == DEBUG for r in self.records)
1056
1057 @property
1058 def has_traces(self):
1059 """`True` if any :data:`TRACE` records were found."""
1060 return any(r.level == TRACE for r in self.records)
10561061
10571062 def has_critical(self, *args, **kwargs):
10581063 """`True` if a specific :data:`CRITICAL` log record exists.
11001105 See :ref:`probe-log-records` for more information.
11011106 """
11021107 kwargs['level'] = DEBUG
1108 return self._test_for(*args, **kwargs)
1109
1110 def has_trace(self, *args, **kwargs):
1111 """`True` if a specific :data:`TRACE` log record exists.
1112
1113 See :ref:`probe-log-records` for more information.
1114 """
1115 kwargs['level'] = TRACE
11031116 return self._test_for(*args, **kwargs)
11041117
11051118 def _test_for(self, message=None, channel=None, level=None):
00 import re
11
2 import pytest
23
3 def test_regex_matching(active_handler, logger):
4 logger.warn('Hello World!')
5 assert active_handler.has_warning(re.compile('^Hello'))
6 assert (not active_handler.has_warning(re.compile('world$')))
7 assert (not active_handler.has_warning('^Hello World'))
4
5 @pytest.mark.parametrize("level, method", [
6 ("trace", "has_traces"),
7 ("debug", "has_debugs"),
8 ("info", "has_infos"),
9 ("notice", "has_notices"),
10 ("warning", "has_warnings"),
11 ("error", "has_errors"),
12 ("critical", "has_criticals"),
13 ])
14 def test_has_level(active_handler, logger, level, method):
15 log = getattr(logger, level)
16 log('Hello World')
17 assert getattr(active_handler, method)
18
19
20 @pytest.mark.parametrize("level, method", [
21 ("trace", "has_trace"),
22 ("debug", "has_debug"),
23 ("info", "has_info"),
24 ("notice", "has_notice"),
25 ("warning", "has_warning"),
26 ("error", "has_error"),
27 ("critical", "has_critical"),
28 ])
29 def test_regex_matching(active_handler, logger, level, method):
30 log = getattr(logger, level)
31 log('Hello World')
32 has_level_method = getattr(active_handler, method)
33 assert has_level_method(re.compile('^Hello'))
34 assert (not has_level_method(re.compile('world$')))
35 assert (not has_level_method('^Hello World'))
836
937
1038 def test_test_handler_cache(active_handler, logger):