Skip to content

Commit

Permalink
Skip sphinx.locale.init_console when running tests (#11159)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jeanas committed Jan 31, 2023
1 parent 4c4745a commit ecfd08d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/conftest.py
Expand Up @@ -5,9 +5,23 @@
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
Expand Down

0 comments on commit ecfd08d

Please sign in to comment.