Skip to content

Commit

Permalink
mock
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed May 28, 2022
1 parent fd8c554 commit 6d2ddac
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/test_config.py
Expand Up @@ -398,23 +398,22 @@ def test_conf_py_language_none(tempdir):
assert cfg.language == "en"


def test_conf_py_language_none_warning(tempdir, caplog):
@mock.patch("sphinx.config.logger")
def test_conf_py_language_none_warning(logger, tempdir):
"""Regression test for #10474."""

# Given a conf.py file with language = None
(tempdir / 'conf.py').write_text("language = None", encoding='utf-8')

# When we load conf.py into a Config object
with caplog.at_level(logging.DEBUG):
Config.read(tempdir, {}, None)
Config.read(tempdir, {}, None)

# Then a warning is raised
assert len(caplog.records) == 1
assert caplog.records[0].getMessage() == (
assert logger.warning.called
assert logger.warning.call_args[0][0] == (
"Invalid configuration value found: 'language = None'. "
"Update your configuration to a valid langauge code. "
"Falling back to 'en' (English).")
assert caplog.records[0].levelname == "WARNING"


def test_conf_py_no_language(tempdir):
Expand Down

0 comments on commit 6d2ddac

Please sign in to comment.