@@ -30,31 +30,27 @@ def up_to_date_repo(tempdir_factory):
3030 yield make_repo (tempdir_factory , 'python_hooks_repo' )
3131
3232
33- def test_up_to_date_repo (up_to_date_repo , runner_with_mocked_store ):
33+ def test_up_to_date_repo (up_to_date_repo , store ):
3434 config = make_config_from_repo (up_to_date_repo )
3535 input_rev = config ['rev' ]
36- ret = _update_repo (config , runner_with_mocked_store , tags_only = False )
36+ ret = _update_repo (config , store , tags_only = False )
3737 assert ret ['rev' ] == input_rev
3838
3939
40- def test_autoupdate_up_to_date_repo (
41- up_to_date_repo , in_tmpdir , mock_out_store_directory ,
42- ):
40+ def test_autoupdate_up_to_date_repo (up_to_date_repo , in_tmpdir , store ):
4341 # Write out the config
4442 config = make_config_from_repo (up_to_date_repo , check = False )
4543 write_config ('.' , config )
4644
4745 before = open (C .CONFIG_FILE ).read ()
4846 assert '^$' not in before
49- ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), tags_only = False )
47+ ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), store , tags_only = False )
5048 after = open (C .CONFIG_FILE ).read ()
5149 assert ret == 0
5250 assert before == after
5351
5452
55- def test_autoupdate_old_revision_broken (
56- tempdir_factory , in_tmpdir , mock_out_store_directory ,
57- ):
53+ def test_autoupdate_old_revision_broken (tempdir_factory , in_tmpdir , store ):
5854 """In $FUTURE_VERSION, hooks.yaml will no longer be supported. This
5955 asserts that when that day comes, pre-commit will be able to autoupdate
6056 despite not being able to read hooks.yaml in that repository.
@@ -73,7 +69,7 @@ def test_autoupdate_old_revision_broken(
7369 config ['rev' ] = rev
7470 write_config ('.' , config )
7571 before = open (C .CONFIG_FILE ).read ()
76- ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), tags_only = False )
72+ ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), store , tags_only = False )
7773 after = open (C .CONFIG_FILE ).read ()
7874 assert ret == 0
7975 assert before != after
@@ -94,26 +90,24 @@ def out_of_date_repo(tempdir_factory):
9490 )
9591
9692
97- def test_out_of_date_repo (out_of_date_repo , runner_with_mocked_store ):
93+ def test_out_of_date_repo (out_of_date_repo , store ):
9894 config = make_config_from_repo (
9995 out_of_date_repo .path , rev = out_of_date_repo .original_rev ,
10096 )
101- ret = _update_repo (config , runner_with_mocked_store , tags_only = False )
97+ ret = _update_repo (config , store , tags_only = False )
10298 assert ret ['rev' ] != out_of_date_repo .original_rev
10399 assert ret ['rev' ] == out_of_date_repo .head_rev
104100
105101
106- def test_autoupdate_out_of_date_repo (
107- out_of_date_repo , in_tmpdir , mock_out_store_directory ,
108- ):
102+ def test_autoupdate_out_of_date_repo (out_of_date_repo , in_tmpdir , store ):
109103 # Write out the config
110104 config = make_config_from_repo (
111105 out_of_date_repo .path , rev = out_of_date_repo .original_rev , check = False ,
112106 )
113107 write_config ('.' , config )
114108
115109 before = open (C .CONFIG_FILE ).read ()
116- ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), tags_only = False )
110+ ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), store , tags_only = False )
117111 after = open (C .CONFIG_FILE ).read ()
118112 assert ret == 0
119113 assert before != after
@@ -123,7 +117,7 @@ def test_autoupdate_out_of_date_repo(
123117
124118
125119def test_autoupdate_out_of_date_repo_with_correct_repo_name (
126- out_of_date_repo , in_tmpdir , mock_out_store_directory ,
120+ out_of_date_repo , in_tmpdir , store ,
127121):
128122 stale_config = make_config_from_repo (
129123 out_of_date_repo .path , rev = out_of_date_repo .original_rev , check = False ,
@@ -136,7 +130,7 @@ def test_autoupdate_out_of_date_repo_with_correct_repo_name(
136130 runner = Runner ('.' , C .CONFIG_FILE )
137131 before = open (C .CONFIG_FILE ).read ()
138132 repo_name = 'file://{}' .format (out_of_date_repo .path )
139- ret = autoupdate (runner , tags_only = False , repos = (repo_name ,))
133+ ret = autoupdate (runner , store , tags_only = False , repos = (repo_name ,))
140134 after = open (C .CONFIG_FILE ).read ()
141135 assert ret == 0
142136 assert before != after
@@ -145,7 +139,7 @@ def test_autoupdate_out_of_date_repo_with_correct_repo_name(
145139
146140
147141def test_autoupdate_out_of_date_repo_with_wrong_repo_name (
148- out_of_date_repo , in_tmpdir , mock_out_store_directory ,
142+ out_of_date_repo , in_tmpdir , store ,
149143):
150144 # Write out the config
151145 config = make_config_from_repo (
@@ -156,15 +150,13 @@ def test_autoupdate_out_of_date_repo_with_wrong_repo_name(
156150 runner = Runner ('.' , C .CONFIG_FILE )
157151 before = open (C .CONFIG_FILE ).read ()
158152 # It will not update it, because the name doesn't match
159- ret = autoupdate (runner , tags_only = False , repos = ('wrong_repo_name ' ,))
153+ ret = autoupdate (runner , store , tags_only = False , repos = ('dne ' ,))
160154 after = open (C .CONFIG_FILE ).read ()
161155 assert ret == 0
162156 assert before == after
163157
164158
165- def test_does_not_reformat (
166- out_of_date_repo , mock_out_store_directory , in_tmpdir ,
167- ):
159+ def test_does_not_reformat (in_tmpdir , out_of_date_repo , store ):
168160 fmt = (
169161 'repos:\n '
170162 '- repo: {}\n '
@@ -178,14 +170,14 @@ def test_does_not_reformat(
178170 with open (C .CONFIG_FILE , 'w' ) as f :
179171 f .write (config )
180172
181- autoupdate (Runner ('.' , C .CONFIG_FILE ), tags_only = False )
173+ autoupdate (Runner ('.' , C .CONFIG_FILE ), store , tags_only = False )
182174 after = open (C .CONFIG_FILE ).read ()
183175 expected = fmt .format (out_of_date_repo .path , out_of_date_repo .head_rev )
184176 assert after == expected
185177
186178
187179def test_loses_formatting_when_not_detectable (
188- out_of_date_repo , mock_out_store_directory , in_tmpdir ,
180+ out_of_date_repo , store , in_tmpdir ,
189181):
190182 """A best-effort attempt is made at updating rev without rewriting
191183 formatting. When the original formatting cannot be detected, this
@@ -207,7 +199,7 @@ def test_loses_formatting_when_not_detectable(
207199 with open (C .CONFIG_FILE , 'w' ) as f :
208200 f .write (config )
209201
210- autoupdate (Runner ('.' , C .CONFIG_FILE ), tags_only = False )
202+ autoupdate (Runner ('.' , C .CONFIG_FILE ), store , tags_only = False )
211203 after = open (C .CONFIG_FILE ).read ()
212204 expected = (
213205 'repos:\n '
@@ -225,15 +217,13 @@ def tagged_repo(out_of_date_repo):
225217 yield out_of_date_repo
226218
227219
228- def test_autoupdate_tagged_repo (
229- tagged_repo , in_tmpdir , mock_out_store_directory ,
230- ):
220+ def test_autoupdate_tagged_repo (tagged_repo , in_tmpdir , store ):
231221 config = make_config_from_repo (
232222 tagged_repo .path , rev = tagged_repo .original_rev ,
233223 )
234224 write_config ('.' , config )
235225
236- ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), tags_only = False )
226+ ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), store , tags_only = False )
237227 assert ret == 0
238228 assert 'v1.2.3' in open (C .CONFIG_FILE ).read ()
239229
@@ -244,16 +234,14 @@ def tagged_repo_with_more_commits(tagged_repo):
244234 yield tagged_repo
245235
246236
247- def test_autoupdate_tags_only (
248- tagged_repo_with_more_commits , in_tmpdir , mock_out_store_directory ,
249- ):
237+ def test_autoupdate_tags_only (tagged_repo_with_more_commits , in_tmpdir , store ):
250238 config = make_config_from_repo (
251239 tagged_repo_with_more_commits .path ,
252240 rev = tagged_repo_with_more_commits .original_rev ,
253241 )
254242 write_config ('.' , config )
255243
256- ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), tags_only = True )
244+ ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), store , tags_only = True )
257245 assert ret == 0
258246 assert 'v1.2.3' in open (C .CONFIG_FILE ).read ()
259247
@@ -273,20 +261,18 @@ def hook_disappearing_repo(tempdir_factory):
273261 yield auto_namedtuple (path = path , original_rev = original_rev )
274262
275263
276- def test_hook_disppearing_repo_raises (
277- hook_disappearing_repo , runner_with_mocked_store ,
278- ):
264+ def test_hook_disppearing_repo_raises (hook_disappearing_repo , store ):
279265 config = make_config_from_repo (
280266 hook_disappearing_repo .path ,
281267 rev = hook_disappearing_repo .original_rev ,
282268 hooks = [OrderedDict ((('id' , 'foo' ),))],
283269 )
284270 with pytest .raises (RepositoryCannotBeUpdatedError ):
285- _update_repo (config , runner_with_mocked_store , tags_only = False )
271+ _update_repo (config , store , tags_only = False )
286272
287273
288274def test_autoupdate_hook_disappearing_repo (
289- hook_disappearing_repo , in_tmpdir , mock_out_store_directory ,
275+ hook_disappearing_repo , in_tmpdir , store ,
290276):
291277 config = make_config_from_repo (
292278 hook_disappearing_repo .path ,
@@ -297,25 +283,25 @@ def test_autoupdate_hook_disappearing_repo(
297283 write_config ('.' , config )
298284
299285 before = open (C .CONFIG_FILE ).read ()
300- ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), tags_only = False )
286+ ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), store , tags_only = False )
301287 after = open (C .CONFIG_FILE ).read ()
302288 assert ret == 1
303289 assert before == after
304290
305291
306- def test_autoupdate_local_hooks (tempdir_factory ):
292+ def test_autoupdate_local_hooks (tempdir_factory , store ):
307293 git_path = git_dir (tempdir_factory )
308294 config = config_with_local_hooks ()
309295 path = add_config_to_repo (git_path , config )
310296 runner = Runner (path , C .CONFIG_FILE )
311- assert autoupdate (runner , tags_only = False ) == 0
297+ assert autoupdate (runner , store , tags_only = False ) == 0
312298 new_config_writen = load_config (runner .config_file_path )
313299 assert len (new_config_writen ['repos' ]) == 1
314300 assert new_config_writen ['repos' ][0 ] == config
315301
316302
317303def test_autoupdate_local_hooks_with_out_of_date_repo (
318- out_of_date_repo , in_tmpdir , mock_out_store_directory ,
304+ out_of_date_repo , in_tmpdir , store ,
319305):
320306 stale_config = make_config_from_repo (
321307 out_of_date_repo .path , rev = out_of_date_repo .original_rev , check = False ,
@@ -324,21 +310,22 @@ def test_autoupdate_local_hooks_with_out_of_date_repo(
324310 config = {'repos' : [local_config , stale_config ]}
325311 write_config ('.' , config )
326312 runner = Runner ('.' , C .CONFIG_FILE )
327- assert autoupdate (runner , tags_only = False ) == 0
313+ assert autoupdate (runner , store , tags_only = False ) == 0
328314 new_config_writen = load_config (runner .config_file_path )
329315 assert len (new_config_writen ['repos' ]) == 2
330316 assert new_config_writen ['repos' ][0 ] == local_config
331317
332318
333- def test_autoupdate_meta_hooks (tmpdir , capsys ):
319+ def test_autoupdate_meta_hooks (tmpdir , capsys , store ):
334320 cfg = tmpdir .join (C .CONFIG_FILE )
335321 cfg .write (
336322 'repos:\n '
337323 '- repo: meta\n '
338324 ' hooks:\n '
339325 ' - id: check-useless-excludes\n ' ,
340326 )
341- ret = autoupdate (Runner (tmpdir .strpath , C .CONFIG_FILE ), tags_only = True )
327+ runner = Runner (tmpdir .strpath , C .CONFIG_FILE )
328+ ret = autoupdate (runner , store , tags_only = True )
342329 assert ret == 0
343330 assert cfg .read () == (
344331 'repos:\n '
@@ -348,7 +335,7 @@ def test_autoupdate_meta_hooks(tmpdir, capsys):
348335 )
349336
350337
351- def test_updates_old_format_to_new_format (tmpdir , capsys ):
338+ def test_updates_old_format_to_new_format (tmpdir , capsys , store ):
352339 cfg = tmpdir .join (C .CONFIG_FILE )
353340 cfg .write (
354341 '- repo: local\n '
@@ -358,7 +345,8 @@ def test_updates_old_format_to_new_format(tmpdir, capsys):
358345 ' entry: ./bin/foo.sh\n '
359346 ' language: script\n ' ,
360347 )
361- ret = autoupdate (Runner (tmpdir .strpath , C .CONFIG_FILE ), tags_only = True )
348+ runner = Runner (tmpdir .strpath , C .CONFIG_FILE )
349+ ret = autoupdate (runner , store , tags_only = True )
362350 assert ret == 0
363351 contents = cfg .read ()
364352 assert contents == (
0 commit comments