mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 04:36:52 +00:00
Change how we apply lazy to the git hook
This commit is contained in:
parent
0285359a14
commit
941896218d
2 changed files with 36 additions and 4 deletions
29
tests/unit/test_git.py
Normal file
29
tests/unit/test_git.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"""Tests around functionality in the git integration."""
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
from flake8.main import git
|
||||
|
||||
|
||||
@pytest.mark.parametrize('lazy', [True, False])
|
||||
def test_find_modified_files(lazy):
|
||||
"""Confirm our logic for listing modified files."""
|
||||
if lazy:
|
||||
# Here --cached is missing
|
||||
call = [
|
||||
'git', 'diff-index', '--name-only', '--diff-filter=ACMRTUXB',
|
||||
'HEAD'
|
||||
]
|
||||
else:
|
||||
call = [
|
||||
'git', 'diff-index', '--cached', '--name-only',
|
||||
'--diff-filter=ACMRTUXB', 'HEAD'
|
||||
]
|
||||
mocked_popen = mock.Mock()
|
||||
mocked_popen.communicate.return_value = ('', '')
|
||||
|
||||
with mock.patch('flake8.main.git.piped_process') as piped_process:
|
||||
piped_process.return_value = mocked_popen
|
||||
git.find_modified_files(lazy)
|
||||
|
||||
piped_process.assert_called_once_with(call)
|
||||
Loading…
Add table
Add a link
Reference in a new issue