mirror of
https://fuchsia.googlesource.com/third_party/github.com/pylint-dev/pylint
synced 2024-09-21 07:58:04 +00:00
Pass quote=False
to html.escape
in the JSON reporter
Close PyCQA/pylint#2769
This commit is contained in:
parent
66f36eec1e
commit
6b1adc6687
|
@ -39,8 +39,7 @@ class JSONReporter(BaseReporter):
|
|||
"column": msg.column,
|
||||
"path": msg.path,
|
||||
"symbol": msg.symbol,
|
||||
# pylint: disable=deprecated-method; deprecated since 3.2.
|
||||
"message": html.escape(msg.msg or ""),
|
||||
"message": html.escape(msg.msg or "", quote=False),
|
||||
"message-id": msg.msg_id,
|
||||
}
|
||||
)
|
||||
|
|
6
pylint/test/regrtest_data/unused_variable.py
Normal file
6
pylint/test/regrtest_data/unused_variable.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
# pylint: disable=missing-docstring
|
||||
|
||||
def test():
|
||||
variable = ''
|
||||
variable2 = None
|
||||
return variable2
|
|
@ -433,6 +433,28 @@ class TestRunTC(object):
|
|||
assert message[key] == value
|
||||
assert message["message"].startswith("No module named")
|
||||
|
||||
def test_json_report_does_not_escape_quotes(self):
|
||||
out = StringIO()
|
||||
module = join(HERE, "regrtest_data", "unused_variable.py")
|
||||
self._runtest([module], code=4, reporter=JSONReporter(out))
|
||||
output = json.loads(out.getvalue())
|
||||
assert isinstance(output, list)
|
||||
assert len(output) == 1
|
||||
assert isinstance(output[0], dict)
|
||||
expected = {
|
||||
"symbol": "unused-variable",
|
||||
"module": "unused_variable",
|
||||
"column": 4,
|
||||
"message": "Unused variable 'variable'",
|
||||
"message-id": "W0612",
|
||||
"line": 4,
|
||||
"type": "warning",
|
||||
}
|
||||
message = output[0]
|
||||
for key, value in expected.items():
|
||||
assert key in message
|
||||
assert message[key] == value
|
||||
|
||||
def test_information_category_disabled_by_default(self):
|
||||
expected = "Your code has been rated at 10.00/10"
|
||||
path = join(HERE, "regrtest_data", "meta.py")
|
||||
|
|
Loading…
Reference in New Issue
Block a user