mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-14 08:24:46 +00:00
Write a test checking plugin failure exception handling
This commit is contained in:
parent
c68e7a8d3e
commit
b64421c5e8
2 changed files with 35 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
|||
"""Unit tests for the FileChecker class."""
|
||||
import mock
|
||||
import pytest
|
||||
import flake8
|
||||
|
||||
from flake8 import checker
|
||||
|
||||
|
|
@ -43,3 +45,19 @@ def test_nonexistent_file():
|
|||
assert len(c.results) == 1
|
||||
error = c.results[0]
|
||||
assert error[0] == "E902"
|
||||
|
||||
|
||||
def test_raises_proper_exception_on_failed_plugin_run(tmp_path, default_options):
|
||||
foobar = tmp_path / 'foobar.py'
|
||||
foobar.write_text("I exist")
|
||||
plugin = {
|
||||
"name": "failure",
|
||||
"plugin_name": "failure", # Both are necessary
|
||||
"parameters": dict(),
|
||||
"plugin": mock.MagicMock(side_effect=ValueError),
|
||||
}
|
||||
"""Verify a failing plugin results in an plugin error"""
|
||||
fchecker = checker.FileChecker(
|
||||
str(foobar), checks=[], options=default_options)
|
||||
with pytest.raises(flake8.exceptions.PluginExecutionFailed):
|
||||
fchecker.run_check(plugin)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue