@@ -42,6 +42,18 @@ def repo_with_failing_hook(tempdir_factory):
4242 yield git_path
4343
4444
45+ @pytest .fixture
46+ def aliased_repo (tempdir_factory ):
47+ git_path = make_consuming_repo (tempdir_factory , 'script_hooks_repo' )
48+ with cwd (git_path ):
49+ with modify_config () as config :
50+ config ['repos' ][0 ]['hooks' ].append (
51+ {'id' : 'bash_hook' , 'alias' : 'foo_bash' },
52+ )
53+ stage_a_file ()
54+ yield git_path
55+
56+
4557def stage_a_file (filename = 'foo.py' ):
4658 open (filename , 'a' ).close ()
4759 cmd_output ('git' , 'add' , filename )
@@ -388,17 +400,9 @@ def test_skip_hook(cap_out, store, repo_with_passing_hook):
388400 assert msg in printed
389401
390402
391- def test_skip_aliased_hook (cap_out , store , repo_with_passing_hook ):
392- with cwd (repo_with_passing_hook ):
393- # Add bash hook on there again, aliased
394- with modify_config () as config :
395- config ['repos' ][0 ]['hooks' ].append (
396- {'id' : 'bash_hook' , 'alias' : 'foo_bash' },
397- )
398- stage_a_file ()
399-
403+ def test_skip_aliased_hook (cap_out , store , aliased_repo ):
400404 ret , printed = _do_run (
401- cap_out , store , repo_with_passing_hook ,
405+ cap_out , store , aliased_repo ,
402406 run_opts (hook = 'bash_hook' ),
403407 {'SKIP' : 'bash_hook' },
404408 )
@@ -409,7 +413,7 @@ def test_skip_aliased_hook(cap_out, store, repo_with_passing_hook):
409413 assert msg in printed
410414
411415 ret , printed = _do_run (
412- cap_out , store , repo_with_passing_hook ,
416+ cap_out , store , aliased_repo ,
413417 run_opts (hook = 'foo_bash' ),
414418 {'SKIP' : 'foo_bash' },
415419 )
@@ -448,25 +452,17 @@ def test_multiple_hooks_same_id(cap_out, store, repo_with_passing_hook):
448452 assert output .count (b'Bash hook' ) == 2
449453
450454
451- def test_aliased_hook_run (cap_out , store , repo_with_passing_hook ):
452- with cwd (repo_with_passing_hook ):
453- # Add bash hook on there again, aliased
454- with modify_config () as config :
455- config ['repos' ][0 ]['hooks' ].append (
456- {'id' : 'bash_hook' , 'alias' : 'foo_bash' },
457- )
458- stage_a_file ()
459-
455+ def test_aliased_hook_run (cap_out , store , aliased_repo ):
460456 ret , output = _do_run (
461- cap_out , store , repo_with_passing_hook ,
457+ cap_out , store , aliased_repo ,
462458 run_opts (verbose = True , hook = 'bash_hook' ),
463459 )
464460 assert ret == 0
465461 # Both hooks will run since they share the same ID
466462 assert output .count (b'Bash hook' ) == 2
467463
468464 ret , output = _do_run (
469- cap_out , store , repo_with_passing_hook ,
465+ cap_out , store , aliased_repo ,
470466 run_opts (verbose = True , hook = 'foo_bash' ),
471467 )
472468 assert ret == 0
0 commit comments