From 200414982c768c213ca66f41fa331a5b4d129d94 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sat, 28 May 2022 19:26:13 +0100 Subject: [PATCH] Update test --- sphinx/config.py | 1 - tests/test_config.py | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sphinx/config.py b/sphinx/config.py index 1cd0632ed9..15337e924d 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -3,7 +3,6 @@ import re import traceback import types -import warnings from collections import OrderedDict from os import getenv, path from typing import (TYPE_CHECKING, Any, Callable, Dict, Generator, Iterator, List, NamedTuple, diff --git a/tests/test_config.py b/tests/test_config.py index ec8194af11..c0b8864e00 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -397,7 +397,8 @@ 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 @@ -407,12 +408,11 @@ def test_conf_py_language_none_warning(tempdir, caplog): Config.read(tempdir, {}, None) # Then a warning is raised - assert len(caplog.messages) == 1 - assert caplog.messages[0] == ( + 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):