-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracts a `format_message` to help unit testing fix #339
- Loading branch information
Showing
4 changed files
with
63 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
from unittest import TestCase | ||
|
||
from prospector.message import Location, Message | ||
from prospector.tools.mypy import format_message | ||
|
||
|
||
class TestMypyTool(TestCase): | ||
def test_format_message_with_character(self): | ||
location = Location( | ||
path="file.py", module=None, function=None, line=17, character=2 | ||
) | ||
expected = Message( | ||
source="mypy", code="error", location=location, message="Important error" | ||
) | ||
self.assertEqual( | ||
format_message("file.py:17:2: error: Important error"), expected | ||
) | ||
|
||
def test_format_message_without_character_and_columns_in_message(self): | ||
location = Location( | ||
path="file.py", module=None, function=None, line=17, character=None | ||
) | ||
expected = Message( | ||
source="mypy", code="note", location=location, message="Important error" | ||
) | ||
self.assertEqual( | ||
format_message('file.py:17: note: unused "type: ignore" comment'), expected | ||
) | ||
|
||
def test_format_message_without_character(self): | ||
location = Location( | ||
path="file.py", module=None, function=None, line=17, character=None | ||
) | ||
expected = Message( | ||
source="mypy", code="error", location=location, message="Important error" | ||
) | ||
self.assertEqual(format_message("file.py:17: error: Important error"), expected) |