mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-11-02 20:30:30 -06:00
Improve error message when config fails type check
The old message printed wrapped brackets around the type name, which would make you think it required an array.
This commit is contained in:
1 parent
c206c02a57
commit
e792279791
2 files changed
+31
-5
No files matched your search
@@ -247,6 +247,27 @@ def test_check_types(logger, name, default, annotation, actual, warned):
|
||||
assert logger.warning.called == warned
|
||||
|
||||
|
||||
TYPECHECK_WARNING_MESSAGES = [
|
||||
('value1', 'string', [str], ['foo', 'bar'],
|
||||
"The config value `value1' has type `list'; expected `str'."),
|
||||
('value1', 'string', [str, int], ['foo', 'bar'],
|
||||
"The config value `value1' has type `list'; expected `str' or `int'."),
|
||||
('value1', 'string', [str, int, tuple], ['foo', 'bar'],
|
||||
"The config value `value1' has type `list'; expected `str', `int', or `tuple'."),
|
||||
]
|
||||
|
||||
|
||||
@mock.patch("sphinx.config.logger")
|
||||
@pytest.mark.parametrize("name,default,annotation,actual,message", TYPECHECK_WARNING_MESSAGES)
|
||||
def test_conf_warning_message(logger, name, default, annotation, actual, message):
|
||||
config = Config({name: actual})
|
||||
config.add(name, default, False, annotation or ())
|
||||
config.init_values()
|
||||
check_confval_types(None, config)
|
||||
logger.warning.assert_called()
|
||||
assert logger.warning.call_args[0][0] == message
|
||||
|
||||
|
||||
@mock.patch("sphinx.config.logger")
|
||||
def test_check_enum(logger):
|
||||
config = Config()
|
||||
|
||||
Reference in new issue
Block a user