@@ -123,7 +123,7 @@ class TestGetCommitInfo:
123123 )
124124 def test_get_commit_info (self , mocker , format_string ):
125125 # Must call get_commit_info with given argument when there are commits.
126- m_has_commits = mocker .patch (
126+ mocker .patch (
127127 "commit_check.util.has_commits" ,
128128 return_value = True
129129 )
@@ -132,7 +132,6 @@ def test_get_commit_info(self, mocker, format_string):
132132 return_value = " fake commit message "
133133 )
134134 retval = get_commit_info (format_string )
135- assert m_has_commits .call_count == 1
136135 assert m_cmd_output .call_count == 1
137136 assert m_cmd_output .call_args [0 ][0 ] == [
138137 "git" , "log" , "-n" , "1" , f"--pretty=format:%{ format_string } " , "HEAD"
@@ -142,24 +141,23 @@ def test_get_commit_info(self, mocker, format_string):
142141 @pytest .mark .benchmark
143142 def test_get_commit_info_no_commits (self , mocker ):
144143 # Must return 'Repo has no commits yet.' when there are no commits.
145- m_has_commits = mocker .patch (
144+ mocker .patch (
146145 "commit_check.util.has_commits" ,
147146 return_value = False
148147 )
149- m_cmd_output = mocker .patch (
148+ mocker .patch (
150149 "commit_check.util.cmd_output" ,
151150 return_value = " fake commit message "
152151 )
153152 format_string = "s"
154153 retval = get_commit_info (format_string )
155- assert m_has_commits .call_count == 1
156- assert m_cmd_output .call_count == 0 # Should not call cmd_output
157- assert retval == "Repo has no commits yet."
154+ assert retval == " fake commit message "
155+
158156
159157 @pytest .mark .benchmark
160158 def test_get_commit_info_with_exception (self , mocker ):
161159 # Must return empty string when exception raises in cmd_output.
162- m_has_commits = mocker .patch (
160+ mocker .patch (
163161 "commit_check.util.has_commits" ,
164162 return_value = True
165163 )
@@ -175,7 +173,6 @@ def test_get_commit_info_with_exception(self, mocker):
175173 )
176174 format_string = "s"
177175 retval = get_commit_info (format_string )
178- assert m_has_commits .call_count == 1
179176 assert m_cmd_output .call_count == 1
180177 assert m_cmd_output .call_args [0 ][0 ] == [
181178 "git" , "log" , "-n" , "1" , f"--pretty=format:%{ format_string } " , "HEAD"
0 commit comments