summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-10-24 18:29:45 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2016-10-25 05:25:44 -0500
commit941896218d477c3ec117d21dc9da45d4265269b8 (patch)
tree83c3b3e660316246eb6187ac9e7eb113b9e9f338 /tests
parent0285359a1418def10b4dbd3c94af7855bad54eca (diff)
downloadflake8-941896218d477c3ec117d21dc9da45d4265269b8.tar.gz
Change how we apply lazy to the git hook
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_git.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/unit/test_git.py b/tests/unit/test_git.py
new file mode 100644
index 0000000..24d4b5b
--- /dev/null
+++ b/tests/unit/test_git.py
@@ -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)