From b3ac99af03a477183fb43d6bb412d46a99aab796 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Thu, 19 Oct 2017 15:31:46 -0700 Subject: [PATCH] Realized the log/warn/etc stuff really just wanted to be 'use logging, stupid' higher up. It's possible this fixes my other issues too, and that they are purely a visibility problem. --- integration/util.py | 4 ---- releases/util.py | 6 ++++++ tests/_util.py | 8 -------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/integration/util.py b/integration/util.py index 46bbf8f..dfc512a 100644 --- a/integration/util.py +++ b/integration/util.py @@ -4,7 +4,6 @@ Tests for the ``releases.util`` module. These are in the integration suite because they deal with on-disk files. """ -import logging import os from docutils.nodes import document @@ -15,9 +14,6 @@ from releases.models import Release, Issue from releases.util import get_doctree, parse_changelog -# Mute Sphinx's own logging, as it makes test output quite verbose -logging.getLogger('sphinx').setLevel(logging.ERROR) - support = os.path.join(os.path.dirname(__file__), '_support') vanilla = os.path.join(support, 'vanilla', 'changelog.rst') unreleased_bugs = os.path.join(support, 'unreleased_bugs', 'changelog.rst') diff --git a/releases/util.py b/releases/util.py index 7fee253..66a9999 100644 --- a/releases/util.py +++ b/releases/util.py @@ -2,6 +2,7 @@ Utility functions, such as helpers for standalone changelog parsing. """ +import logging import os from tempfile import mkdtemp @@ -191,7 +192,12 @@ def make_app(**kwargs): dstdir = kwargs.pop('dstdir', mkdtemp()) doctreedir = kwargs.pop('doctreedir', mkdtemp()) try: + # Sphinx <1.6ish Sphinx._log = lambda self, message, wfile, nonl=False: None + # Sphinx >=1.6ish. Technically still lets Very Bad Things through, + # unlike the total muting above, but probably OK. + logging.getLogger('sphinx').setLevel(logging.ERROR) + # App API seems to work on all versions so far. app = Sphinx( srcdir=srcdir, confdir=None, diff --git a/tests/_util.py b/tests/_util.py index 592036b..d39a6bd 100644 --- a/tests/_util.py +++ b/tests/_util.py @@ -1,5 +1,3 @@ -import logging - from docutils.nodes import ( list_item, paragraph, ) @@ -17,12 +15,6 @@ from releases import ( from releases.util import make_app, changelog2dict -# Mute Sphinx's own logging, as it makes test output quite verbose (many -# 'Running Sphinx' / 'loading pickled environment' messages since we recreate -# new app objects each time for a clean context.) -logging.getLogger('sphinx').setLevel(logging.ERROR) - - def inliner(app=None): app = app or make_app() return Mock(document=Mock(settings=Mock(env=Mock(app=app))))