-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
169 additions
and
19 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import unittest | ||
from pathlib import Path | ||
|
||
from prospector.message import Location, Message | ||
from prospector.suppression import Ignore, get_suppressions | ||
from prospector.tools.mypy import MypyTool | ||
from prospector.tools.pylint import PylintTool | ||
|
||
|
||
class BlenderSuppressionsTest(unittest.TestCase): | ||
def test_blender_suppressions_pylint(self): | ||
path = Path(__file__).parent / "testdata" / "test_blender_suppressions" / "test.py" | ||
messages = [ | ||
Message("pylint", "n2", Location(path, None, None, 2, 0), "message1"), | ||
Message("other", "o2", Location(path, None, None, 2, 0), "message1"), | ||
] | ||
tools = {"pylint": PylintTool()} | ||
blend_combos = [[("pylint", "n2"), ("other", "o2")]] | ||
|
||
_, _, messages_to_ignore = get_suppressions([path], messages, tools, blending=False, blend_combos=blend_combos) | ||
assert messages_to_ignore == {path: {1: {Ignore(None, "n1")}}} | ||
|
||
_, _, messages_to_ignore = get_suppressions([path], messages, tools, blending=True, blend_combos=blend_combos) | ||
assert path in messages_to_ignore | ||
assert 2 in messages_to_ignore[path] | ||
assert messages_to_ignore[path][2] == {Ignore("pylint", "n2"), Ignore("other", "o2")} | ||
|
||
def test_blender_suppressions_mypy(self): | ||
path = Path(__file__).parent / "testdata" / "test_blender_suppressions" / "test.py" | ||
messages = [ | ||
Message("mypy", "n3", Location(path, None, None, 3, 0), "message1"), | ||
Message("other", "o3", Location(path, None, None, 3, 0), "message1"), | ||
] | ||
tools = {"mypy": MypyTool()} | ||
blend_combos = [[("mypy", "n3"), ("other", "o3")]] | ||
|
||
_, _, messages_to_ignore = get_suppressions([path], messages, tools, blending=False, blend_combos=blend_combos) | ||
assert messages_to_ignore == {path: {1: {Ignore(None, "n1")}}} | ||
|
||
_, _, messages_to_ignore = get_suppressions([path], messages, tools, blending=True, blend_combos=blend_combos) | ||
assert path in messages_to_ignore | ||
assert 3 in messages_to_ignore[path] | ||
assert messages_to_ignore[path][3] == {Ignore("mypy", "n3"), Ignore("other", "o3")} | ||
|
||
def test_blender_suppressions_ruff(self): | ||
path = Path(__file__).parent / "testdata" / "test_blender_suppressions" / "test.py" | ||
messages = [ | ||
Message("ruff", "n1", Location(path, None, None, 1, 0), "message1"), | ||
Message("other", "o1", Location(path, None, None, 1, 0), "message1"), | ||
] | ||
tools = {"ruff": MypyTool()} | ||
blend_combos = [[("ruff", "n1"), ("other", "o1")]] | ||
|
||
_, _, messages_to_ignore = get_suppressions([path], messages, tools, blending=False, blend_combos=blend_combos) | ||
assert messages_to_ignore == {path: {1: {Ignore(None, "n1")}}} | ||
|
||
_, _, messages_to_ignore = get_suppressions([path], messages, tools, blending=True, blend_combos=blend_combos) | ||
assert path in messages_to_ignore | ||
assert 4 in messages_to_ignore[path] | ||
assert messages_to_ignore[path][4] == {Ignore("ruff", "n1"), Ignore("other", "o1"), Ignore(None, "n1")} |
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,3 @@ | ||
import test # noqa: n1 | ||
import test # pylint: disable=n2 | ||
import test # type: ignore[n3] |