Skip to content

Commit

Permalink
Fix the Windows's bug with \r\n instead of \n
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Nov 8, 2020
1 parent ccca0a5 commit 2a41113
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pylint/reporters/json_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def display_messages(self, layout):
def display_reports(self, layout):
output = io.StringIO()
TextWriter().format(layout, output)
score = output.getvalue().split("\n")[1]
self.messages.append({"score": score})
score = output.getvalue().split("Your")[1]
score = score.split(r"/10")[0]
self.messages.append({"score": "Your{}/10".format(score)})

def _display(self, layout):
"""Do nothing."""
Expand Down
7 changes: 5 additions & 2 deletions tests/unittest_reporters_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pylint.reporters import JSONReporter
from pylint.reporters.ureports.nodes import EvaluationSection

expected_score_message = "Expected score message"
expected_score_message = "Your code has been rated at 7.50/10"
expected_result = [
[
("column", 0),
Expand Down Expand Up @@ -63,7 +63,10 @@ def get_linter_result(score):
linter.add_message("line-too-long", line=1, args=(1, 2))
# we call those methods because we didn't actually run the checkers
if score:
reporter.display_reports(EvaluationSection(expected_score_message))
generated_msg = "-------------------------------------\r\n{}\r\n".format(
expected_score_message
)
reporter.display_reports(EvaluationSection(generated_msg))
reporter.display_messages(None)
report_result = json.loads(output.getvalue())
return report_result

0 comments on commit 2a41113

Please sign in to comment.