mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Skip sphinx.locale.init_console when running tests (#11159)
Tests for Sphinx's CLIs, like test_apidoc, indirectly init_console to initialize translations for Sphinx's console domain, the one with Sphinx's log messages. This bleeds over subsequent tests by making warnings translated. Fix this by skipping init_console when running Sphinx's test suite.
This commit is contained in:
parent
4c4745af9c
commit
ecfd08d325
@ -5,9 +5,23 @@ import docutils
|
||||
import pytest
|
||||
|
||||
import sphinx
|
||||
import sphinx.locale
|
||||
from sphinx.testing import comparer
|
||||
from sphinx.testing.path import path
|
||||
|
||||
|
||||
def _init_console(locale_dir=sphinx.locale._LOCALE_DIR, catalog='sphinx'):
|
||||
"""Monkeypatch ``init_console`` to skip its action.
|
||||
|
||||
Some tests rely on warning messages in English. We don't want
|
||||
CLI tests to bleed over those tests and make their warnings
|
||||
translated.
|
||||
"""
|
||||
return sphinx.locale.NullTranslations(), False
|
||||
|
||||
|
||||
sphinx.locale.init_console = _init_console
|
||||
|
||||
pytest_plugins = 'sphinx.testing.fixtures'
|
||||
|
||||
# Exclude 'roots' dirs for pytest test collector
|
||||
|
Loading…
Reference in New Issue
Block a user