mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-07 21:44:18 +00:00
Fix git hook checks all the staged files
I think because of this commit:
78e8165b06
The git hook will check all the staged files even it is not a Python source files.
This commit try to fix this and issue #271.
This commit is contained in:
parent
a52aedc0a0
commit
23be44ea50
2 changed files with 20 additions and 1 deletions
|
|
@ -27,3 +27,20 @@ def test_find_modified_files(lazy):
|
|||
git.find_modified_files(lazy)
|
||||
|
||||
piped_process.assert_called_once_with(call)
|
||||
|
||||
|
||||
@mock.patch("flake8.main.git.copy_indexed_files_to")
|
||||
def test_only_py_files(mock_files):
|
||||
"""Confirm only run checks on Python source file."""
|
||||
mock_files.return_value = [
|
||||
"/tmp/xxx/test.py",
|
||||
"/tmp/xxx/test.html",
|
||||
"/tmp/xxx/test.txt",
|
||||
]
|
||||
|
||||
spec = "flake8.main.application.Application.run_checks"
|
||||
with mock.patch(spec) as mock_run:
|
||||
git.hook(lazy=False)
|
||||
mock_run.assert_called_once_with([
|
||||
"/tmp/xxx/test.py"
|
||||
])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue