Red-DiscordBot/tests/cogs/test_trivia.py
Jakub Kuczys 43ab6e2ef5
Add missing empty line in error output of Trivia unit test (#5659)
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2022-12-27 14:42:20 +01:00

28 lines
801 B
Python

import textwrap
import yaml
from schema import SchemaError
def test_trivia_lists():
from redbot.cogs.trivia import InvalidListError, get_core_lists, get_list
list_names = get_core_lists()
assert list_names
problem_lists = []
for l in list_names:
try:
get_list(l)
except InvalidListError as exc:
e = exc.__cause__
if isinstance(e, SchemaError):
problem_lists.append((l.stem, f"SCHEMA error:\n{e!s}"))
else:
problem_lists.append((l.stem, f"YAML error:\n{e!s}"))
if problem_lists:
msg = "\n".join(
f"- {name}:\n{textwrap.indent(error, ' ')}" for name, error in problem_lists
)
raise TypeError("The following lists contain errors:\n" + msg)