mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-11 07:14:18 +00:00
extend black formatting to tests as well
This commit is contained in:
parent
a7174759e9
commit
af1668bf04
45 changed files with 1644 additions and 1307 deletions
|
|
@ -7,7 +7,7 @@ import flake8
|
|||
from flake8 import checker
|
||||
|
||||
|
||||
@mock.patch('flake8.processor.FileProcessor')
|
||||
@mock.patch("flake8.processor.FileProcessor")
|
||||
def test_run_ast_checks_handles_SyntaxErrors(FileProcessor): # noqa: N802,N803
|
||||
"""Stress our SyntaxError handling.
|
||||
|
||||
|
|
@ -15,26 +15,31 @@ def test_run_ast_checks_handles_SyntaxErrors(FileProcessor): # noqa: N802,N803
|
|||
"""
|
||||
processor = mock.Mock(lines=[])
|
||||
FileProcessor.return_value = processor
|
||||
processor.build_ast.side_effect = SyntaxError('Failed to build ast',
|
||||
('', 1, 5, 'foo(\n'))
|
||||
processor.build_ast.side_effect = SyntaxError(
|
||||
"Failed to build ast", ("", 1, 5, "foo(\n")
|
||||
)
|
||||
file_checker = checker.FileChecker(__file__, checks={}, options=object())
|
||||
|
||||
with mock.patch.object(file_checker, 'report') as report:
|
||||
with mock.patch.object(file_checker, "report") as report:
|
||||
file_checker.run_ast_checks()
|
||||
|
||||
report.assert_called_once_with(
|
||||
'E999', 1, 3,
|
||||
'SyntaxError: Failed to build ast',
|
||||
"E999",
|
||||
1,
|
||||
3,
|
||||
"SyntaxError: Failed to build ast",
|
||||
)
|
||||
|
||||
|
||||
@mock.patch('flake8.checker.FileChecker._make_processor', return_value=None)
|
||||
@mock.patch("flake8.checker.FileChecker._make_processor", return_value=None)
|
||||
def test_repr(*args):
|
||||
"""Verify we generate a correct repr."""
|
||||
file_checker = checker.FileChecker(
|
||||
'example.py', checks={}, options=object(),
|
||||
"example.py",
|
||||
checks={},
|
||||
options=object(),
|
||||
)
|
||||
assert repr(file_checker) == 'FileChecker for example.py'
|
||||
assert repr(file_checker) == "FileChecker for example.py"
|
||||
|
||||
|
||||
def test_nonexistent_file():
|
||||
|
|
@ -50,7 +55,7 @@ def test_nonexistent_file():
|
|||
|
||||
def test_raises_exception_on_failed_plugin(tmp_path, default_options):
|
||||
"""Checks that a failing plugin results in PluginExecutionFailed."""
|
||||
foobar = tmp_path / 'foobar.py'
|
||||
foobar = tmp_path / "foobar.py"
|
||||
foobar.write_text("I exist!") # Create temp file
|
||||
plugin = {
|
||||
"name": "failure",
|
||||
|
|
@ -60,6 +65,7 @@ def test_raises_exception_on_failed_plugin(tmp_path, default_options):
|
|||
}
|
||||
"""Verify a failing plugin results in an plugin error"""
|
||||
fchecker = checker.FileChecker(
|
||||
str(foobar), checks=[], options=default_options)
|
||||
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