@@ -640,7 +640,7 @@ def test_fail_hooks(store):
640640 )
641641
642642
643- def test_unknown_keys (store , fake_log_handler ):
643+ def test_unknown_keys (store , caplog ):
644644 config = {
645645 'repo' : 'local' ,
646646 'hooks' : [{
@@ -653,8 +653,8 @@ def test_unknown_keys(store, fake_log_handler):
653653 }],
654654 }
655655 _get_hook (config , store , 'too-much' )
656- expected = 'Unexpected key(s) present on local => too-much: foo, hello'
657- assert fake_log_handler . handle . call_args [ 0 ][ 0 ]. msg == expected
656+ msg , = caplog . messages
657+ assert msg == 'Unexpected key(s) present on local => too-much: foo, hello'
658658
659659
660660def test_reinstall (tempdir_factory , store , log_info_mock ):
@@ -832,27 +832,28 @@ def test_default_stages(store, local_python_config):
832832 assert hook .stages == ['push' ]
833833
834834
835- def test_hook_id_not_present (tempdir_factory , store , fake_log_handler ):
835+ def test_hook_id_not_present (tempdir_factory , store , caplog ):
836836 path = make_repo (tempdir_factory , 'script_hooks_repo' )
837837 config = make_config_from_repo (path )
838838 config ['hooks' ][0 ]['id' ] = 'i-dont-exist'
839839 with pytest .raises (SystemExit ):
840840 _get_hook (config , store , 'i-dont-exist' )
841- assert fake_log_handler .handle .call_args [0 ][0 ].msg == (
841+ _ , msg = caplog .messages
842+ assert msg == (
842843 f'`i-dont-exist` is not present in repository file://{ path } . '
843844 f'Typo? Perhaps it is introduced in a newer version? '
844845 f'Often `pre-commit autoupdate` fixes this.'
845846 )
846847
847848
848- def test_too_new_version (tempdir_factory , store , fake_log_handler ):
849+ def test_too_new_version (tempdir_factory , store , caplog ):
849850 path = make_repo (tempdir_factory , 'script_hooks_repo' )
850851 with modify_manifest (path ) as manifest :
851852 manifest [0 ]['minimum_pre_commit_version' ] = '999.0.0'
852853 config = make_config_from_repo (path )
853854 with pytest .raises (SystemExit ):
854855 _get_hook (config , store , 'bash_hook' )
855- msg = fake_log_handler . handle . call_args [ 0 ][ 0 ]. msg
856+ _ , msg = caplog . messages
856857 pattern = re_assert .Matches (
857858 r'^The hook `bash_hook` requires pre-commit version 999\.0\.0 but '
858859 r'version \d+\.\d+\.\d+ is installed. '
0 commit comments