mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 19:26:52 +00:00
Add check-merge-conflict hook
This commit is contained in:
parent
70a319aea3
commit
779a42919a
5 changed files with 66 additions and 0 deletions
26
tests/check_merge_conflict_test.py
Normal file
26
tests/check_merge_conflict_test.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import os.path
|
||||
|
||||
import pytest
|
||||
|
||||
from pre_commit_hooks.check_merge_conflict import detect_merge_conflict
|
||||
|
||||
# Input, expected return value
|
||||
TESTS = (
|
||||
(b'<<<<<<< HEAD', 1),
|
||||
(b'=======', 1),
|
||||
(b'>>>>>>> master', 1),
|
||||
(b'# <<<<<<< HEAD', 0),
|
||||
(b'# =======', 0),
|
||||
(b'import my_module', 0),
|
||||
(b'', 0),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('input_s', 'expected_retval'), TESTS)
|
||||
def test_detect_merge_conflict(input_s, expected_retval, tmpdir):
|
||||
path = os.path.join(tmpdir.strpath, 'file.txt')
|
||||
|
||||
with open(path, 'wb') as file_obj:
|
||||
file_obj.write(input_s)
|
||||
|
||||
assert detect_merge_conflict([path]) == expected_retval
|
||||
Loading…
Add table
Add a link
Reference in a new issue