@@ -157,6 +157,54 @@ def test_commit_retry_after_failure_works(config, mocker: MockFixture):
157157 assert not os .path .isfile (temp_file )
158158
159159
160+ @pytest .mark .usefixtures ("staging_is_clean" )
161+ def test_commit_retry_after_failure_with_no_retry_works (config , mocker : MockFixture ):
162+ prompt_mock = mocker .patch ("questionary.prompt" )
163+ prompt_mock .return_value = {
164+ "prefix" : "feat" ,
165+ "subject" : "user created" ,
166+ "scope" : "" ,
167+ "is_breaking_change" : False ,
168+ "body" : "closes #21" ,
169+ "footer" : "" ,
170+ }
171+
172+ commit_mock = mocker .patch ("commitizen.git.commit" )
173+ commit_mock .return_value = cmd .Command ("" , "error" , b"" , b"" , 9 )
174+ error_mock = mocker .patch ("commitizen.out.error" )
175+
176+ with pytest .raises (CommitError ):
177+ commit_cmd = commands .Commit (config , {})
178+ temp_file = commit_cmd .temp_file
179+ commit_cmd ()
180+
181+ prompt_mock .assert_called_once ()
182+ error_mock .assert_called_once ()
183+ assert os .path .isfile (temp_file )
184+
185+ # provide different prompt to test that --no-retry ignore backup file
186+ prompt_mock = mocker .patch ("questionary.prompt" )
187+ prompt_mock .return_value = {
188+ "prefix" : "feat" ,
189+ "subject" : "user created" ,
190+ "scope" : "" ,
191+ "is_breaking_change" : False ,
192+ "body" : "closes #22" ,
193+ "footer" : "" ,
194+ }
195+
196+ commit_mock .return_value = cmd .Command ("success" , "" , b"" , b"" , 0 )
197+ success_mock = mocker .patch ("commitizen.out.success" )
198+
199+ config .settings ["retry_after_failure" ] = True
200+ commands .Commit (config , {"no_retry" : True })()
201+
202+ commit_mock .assert_called_with ("feat: user created\n \n closes #22" , args = "" )
203+ prompt_mock .assert_called ()
204+ success_mock .assert_called_once ()
205+ assert not os .path .isfile (temp_file )
206+
207+
160208@pytest .mark .usefixtures ("staging_is_clean" )
161209def test_commit_command_with_dry_run_option (config , mocker : MockFixture ):
162210 prompt_mock = mocker = mocker .patch ("questionary.prompt" )
0 commit comments