99from pre_commit_hooks .check_merge_conflict import detect_merge_conflict
1010from pre_commit_hooks .util import cmd_output
1111from testing .util import get_resource_path
12- from testing .util import write_file
1312
1413
1514@pytest .fixture
@@ -64,11 +63,11 @@ def f1_is_a_conflict_file(tmpdir):
6463 '>>>>>>>' ,
6564 )
6665 assert os .path .exists (os .path .join ('.git' , 'MERGE_MSG' ))
67- yield
66+ yield repo2
6867
6968
7069@pytest .fixture
71- def repository_is_pending_merge (tmpdir ):
70+ def repository_pending_merge (tmpdir ):
7271 # Make a (non-conflicting) merge
7372 repo1 = tmpdir .join ('repo1' )
7473 repo1_f1 = repo1 .join ('f1' )
@@ -98,7 +97,7 @@ def repository_is_pending_merge(tmpdir):
9897 assert repo2_f1 .read () == 'parent\n '
9998 assert repo2_f2 .read () == 'child\n '
10099 assert os .path .exists (os .path .join ('.git' , 'MERGE_HEAD' ))
101- yield
100+ yield repo2
102101
103102
104103@pytest .mark .usefixtures ('f1_is_a_conflict_file' )
@@ -107,20 +106,18 @@ def test_merge_conflicts_git():
107106
108107
109108@pytest .mark .parametrize (
110- 'failing_contents ' , ('<<<<<<< HEAD\n ' , '=======\n ' , '>>>>>>> master\n ' ),
109+ 'contents ' , (b '<<<<<<< HEAD\n ' , b '=======\n ' , b '>>>>>>> master\n ' ),
111110)
112- @pytest .mark .usefixtures ('repository_is_pending_merge' )
113- def test_merge_conflicts_failing (failing_contents ):
114- write_file ('f2' , failing_contents )
111+ def test_merge_conflicts_failing (contents , repository_pending_merge ):
112+ repository_pending_merge .join ('f2' ).write_binary (contents )
115113 assert detect_merge_conflict (['f2' ]) == 1
116114
117115
118116@pytest .mark .parametrize (
119- 'ok_contents ' , ('# <<<<<<< HEAD\n ' , '# =======\n ' , 'import my_module ' , '' ),
117+ 'contents ' , (b '# <<<<<<< HEAD\n ' , b '# =======\n ' , b 'import mod ' , b '' ),
120118)
121- @pytest .mark .usefixtures ('f1_is_a_conflict_file' )
122- def test_merge_conflicts_ok (ok_contents ):
123- write_file ('f1' , ok_contents )
119+ def test_merge_conflicts_ok (contents , f1_is_a_conflict_file ):
120+ f1_is_a_conflict_file .join ('f1' ).write_binary (contents )
124121 assert detect_merge_conflict (['f1' ]) == 0
125122
126123
0 commit comments