MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / test_local_hook_fails

Function test_local_hook_fails

tests/commands/run_test.py:950–974  ·  view source on GitHub ↗
(cap_out, store, repo_with_passing_hook)

Source from the content-addressed store, hash-verified

948
949
950def test_local_hook_fails(cap_out, store, repo_with_passing_hook):
951 config = {
952 'repo': 'local',
953 'hooks': [{
954 'id': 'no-todo',
955 'name': 'No TODO',
956 'entry': 'sh -c "! grep -iI todo $@" --',
957 'language': 'system',
958 }],
959 }
960 add_config_to_repo(repo_with_passing_hook, config)
961
962 with open('placeholder.py', 'w') as staged_file:
963 staged_file.write('"""TODO: something"""\n')
964 cmd_output('git', 'add', 'placeholder.py')
965
966 _test_run(
967 cap_out,
968 store,
969 repo_with_passing_hook,
970 opts={},
971 expected_outputs=[b''],
972 expected_ret=1,
973 stage=False,
974 )
975
976
977def test_meta_hook_passes(cap_out, store, repo_with_passing_hook):

Callers

nothing calls this directly

Calls 3

add_config_to_repoFunction · 0.90
cmd_outputFunction · 0.90
_test_runFunction · 0.85

Tested by

no test coverage detected