File: test_git.py

package info (click to toggle)
python-flake8 3.2.1-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 1,076 kB
  • sloc: python: 5,037; sh: 20; makefile: 18
file content (29 lines) | stat: -rw-r--r-- 857 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)