@@ -105,18 +105,27 @@ def test_merge_conflicts_git(capsys):
105105 assert main (['f1' ]) == 1
106106 out , _ = capsys .readouterr ()
107107 assert out == (
108- "f1:1: Merge conflict string '<<<<<<<' found\n "
109- "f1:3: Merge conflict string '=======' found\n "
110108 "f1:5: Merge conflict string '>>>>>>>' found\n "
111109 )
112110
113111
114112@pytest .mark .parametrize (
115- 'contents' , (b'<<<<<<< HEAD\n ' , b'=======\n ' , b'>>>>>>> main\n ' ),
113+ # Individual markers are not actually merge conflicts, need 3 markers
114+ # to mark a real conflict
115+ 'contents, expected_retcode' ,
116+ ((b'<<<<<<< ' , 0 ),
117+ (b'=======' , 0 ),
118+ (b'>>>>>>> ' ,0 ),
119+ # Real conflict marker
120+ (b'<<<<<<< HEAD\n =======\n >>>>>>> branch\n ' , 1 ),
121+ # Allow for the possibility of an .rst file with a =======
122+ # inside a conflict marker
123+ (b'<<<<<<< HEAD\n =======\n =======\n >>>>>>> branch\n ' , 1 ),
124+ )
116125)
117- def test_merge_conflicts_failing (contents , repository_pending_merge ):
118- repository_pending_merge .join ('f2' ).write_binary (contents )
119- assert main (['f2' ]) == 1
126+ def test_merge_conflicts_with_rst (contents , expected_retcode , repository_pending_merge ):
127+ repository_pending_merge .join ('f2.rst ' ).write_binary (contents )
128+ assert main (['f2.rst ' ]) == expected_retcode
120129
121130
122131@pytest .mark .parametrize (
@@ -138,11 +147,19 @@ def test_does_not_care_when_not_in_a_merge(tmpdir):
138147 f .write_binary (b'problem\n =======\n ' )
139148 assert main ([str (f .realpath ())]) == 0
140149
141-
142- def test_care_when_assumed_merge (tmpdir ):
150+ @pytest .mark .parametrize (
151+ 'contents, expected_retcode' ,
152+ (
153+ # Not a complete conflict marker
154+ (b'=======' , 0 ),
155+ # Complete conflict marker
156+ (b'<<<<<<< HEAD\n problem\n =======\n >>>>>>> branch\n ' , 1 ),
157+ )
158+ )
159+ def test_care_when_assumed_merge (contents , expected_retcode , tmpdir ):
143160 f = tmpdir .join ('README.md' )
144- f .write_binary (b'problem \n ======= \n ' )
145- assert main ([str (f .realpath ()), '--assume-in-merge' ]) == 1
161+ f .write_binary (contents )
162+ assert main ([str (f .realpath ()), '--assume-in-merge' ]) == expected_retcode
146163
147164
148165def test_worktree_merge_conflicts (f1_is_a_conflict_file , tmpdir , capsys ):
0 commit comments