diff options
Diffstat (limited to 'tests/test_util_logging.py')
-rw-r--r-- | tests/test_util_logging.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/test_util_logging.py b/tests/test_util_logging.py index 98affa886..41983c62f 100644 --- a/tests/test_util_logging.py +++ b/tests/test_util_logging.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ test_util_logging ~~~~~~~~~~~~~~~~~ @@ -8,7 +7,6 @@ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ -from __future__ import print_function import codecs import os @@ -20,7 +18,7 @@ from sphinx.errors import SphinxWarning from sphinx.testing.util import strip_escseq from sphinx.util import logging from sphinx.util.console import colorize -from sphinx.util.logging import is_suppressed_warning +from sphinx.util.logging import is_suppressed_warning, prefixed_warnings from sphinx.util.parallel import ParallelTasks @@ -304,7 +302,7 @@ def test_output_with_unencodable_char(app, status, warning): # info with UnicodeEncodeError status.truncate(0) status.seek(0) - logger.info(u"unicode \u206d...") + logger.info("unicode \u206d...") assert status.getvalue() == "unicode ?...\n" @@ -330,3 +328,22 @@ def test_skip_warningiserror(app, status, warning): with logging.pending_warnings(): with logging.skip_warningiserror(False): logger.warning('message') + + +def test_prefixed_warnings(app, status, warning): + logging.setup(app, status, warning) + logger = logging.getLogger(__name__) + + logger.warning('message1') + with prefixed_warnings('PREFIX:'): + logger.warning('message2') + with prefixed_warnings('Another PREFIX:'): + logger.warning('message3') + logger.warning('message4') + logger.warning('message5') + + assert 'WARNING: message1' in warning.getvalue() + assert 'WARNING: PREFIX: message2' in warning.getvalue() + assert 'WARNING: Another PREFIX: message3' in warning.getvalue() + assert 'WARNING: PREFIX: message4' in warning.getvalue() + assert 'WARNING: message5' in warning.getvalue() |