diff --git a/tests/test_config.py b/tests/test_config.py index b5aa0c4c61..ede15c5010 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -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):