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

Function test_local_hook_passes

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

Source from the content-addressed store, hash-verified

910
911
912def test_local_hook_passes(cap_out, store, repo_with_passing_hook):
913 config = {
914 'repo': 'local',
915 'hooks': [
916 {
917 'id': 'identity-copy',
918 'name': 'identity-copy',
919 'entry': '{} -m pre_commit.meta_hooks.identity'.format(
920 shlex.quote(sys.executable),
921 ),
922 'language': 'system',
923 'files': r'\.py$',
924 },
925 {
926 'id': 'do_not_commit',
927 'name': 'Block if "DO NOT COMMIT" is found',
928 'entry': 'DO NOT COMMIT',
929 'language': 'pygrep',
930 },
931 ],
932 }
933 add_config_to_repo(repo_with_passing_hook, config)
934
935 with open('placeholder.py', 'w') as staged_file:
936 staged_file.write('"""TODO: something"""\n')
937 cmd_output('git', 'add', 'placeholder.py')
938
939 _test_run(
940 cap_out,
941 store,
942 repo_with_passing_hook,
943 opts={},
944 expected_outputs=[b''],
945 expected_ret=0,
946 stage=False,
947 )
948
949
950def test_local_hook_fails(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