summaryrefslogtreecommitdiff
path: root/tests/reporters
diff options
context:
space:
mode:
authorDani Alcala <112832187+clavedeluna@users.noreply.github.com>2022-12-27 09:11:04 -0300
committerGitHub <noreply@github.com>2022-12-27 13:11:04 +0100
commit03bd452620558a2159715ce7f5aad9071910e1a4 (patch)
tree1a27df5b4de0e99882adf753025d207668f56b18 /tests/reporters
parent3a257f56630929974f0a5a9f3b39908342095433 (diff)
downloadpylint-git-03bd452620558a2159715ce7f5aad9071910e1a4.tar.gz
Fixes custom braces in user-provided msg-template. (#7976)
Closes #5636 Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/reporters')
-rw-r--r--tests/reporters/unittest_reporting.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/tests/reporters/unittest_reporting.py b/tests/reporters/unittest_reporting.py
index 7b8139119..40a18036a 100644
--- a/tests/reporters/unittest_reporting.py
+++ b/tests/reporters/unittest_reporting.py
@@ -90,16 +90,12 @@ def test_template_option_non_existing(linter: PyLinter) -> None:
"""
output = StringIO()
linter.reporter.out = output
- linter.config.msg_template = (
- "{path}:{line}:{a_new_option}:({a_second_new_option:03d})"
- )
+ linter.config.msg_template = "{path}:{line}:{categ}:({a_second_new_option:03d})"
linter.open()
with pytest.warns(UserWarning) as records:
linter.set_current_module("my_mod")
assert len(records) == 2
- assert (
- "Don't recognize the argument 'a_new_option'" in records[0].message.args[0]
- )
+ assert "Don't recognize the argument 'categ'" in records[0].message.args[0]
assert (
"Don't recognize the argument 'a_second_new_option'"
in records[1].message.args[0]
@@ -115,6 +111,23 @@ def test_template_option_non_existing(linter: PyLinter) -> None:
assert out_lines[2] == "my_mod:2::()"
+def test_template_option_with_header(linter: PyLinter) -> None:
+ output = StringIO()
+ linter.reporter.out = output
+ linter.config.msg_template = '{{ "Category": "{category}" }}'
+ linter.open()
+ linter.set_current_module("my_mod")
+
+ linter.add_message("C0301", line=1, args=(1, 2))
+ linter.add_message(
+ "line-too-long", line=2, end_lineno=2, end_col_offset=4, args=(3, 4)
+ )
+
+ out_lines = output.getvalue().split("\n")
+ assert out_lines[1] == '{ "Category": "convention" }'
+ assert out_lines[2] == '{ "Category": "convention" }'
+
+
def test_deprecation_set_output(recwarn: WarningsRecorder) -> None:
"""TODO remove in 3.0."""
reporter = BaseReporter()