-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for crash file and add a class attribute for pylinter
- Loading branch information
1 parent
fdcc9d2
commit 058ebda
Showing
2 changed files
with
29 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from unittest.mock import patch | ||
|
||
from astroid import AstroidBuildingError | ||
|
||
from pylint.utils import FileState | ||
|
||
|
||
def raise_exception(*args, **kwargs): | ||
raise AstroidBuildingError(modname="spam") | ||
|
||
|
||
@patch.object(FileState, "iter_spurious_suppression_messages", raise_exception) | ||
def test_crash_in_file(linter, capsys, tmpdir): | ||
args = linter.load_command_line_configuration([__file__]) | ||
linter.crash_file_prefix = tmpdir / "pylint-crash-" | ||
linter.check(args) | ||
out, err = capsys.readouterr() | ||
assert not out | ||
assert not err | ||
files = tmpdir.listdir() | ||
assert len(files) == 1 | ||
assert "pylint-crash" in str(files[0]) | ||
with open(files[0], encoding="utf8") as f: | ||
content = f.read() | ||
assert "Failed to import module spam." in content |