def test_run_legacy_executes_legacy_script(tmpdir, capfd): hook = tmpdir.join('pre-commit.legacy') hook.write('#!/usr/bin/env bash\necho hi "$@"\nexit 1\n') make_executable(hook) retv, stdin = hook_impl._run_legacy('pre-commit', tmpdir, ('arg1', 'arg2')) assert capfd.readouterr().out.strip() == 'hi arg1 arg2' assert (retv, stdin) == (1, b'')
def call(*_, **__): return hook_impl._run_legacy('pre-commit', tmpdir, ())
def test_run_legacy_pre_push_returns_stdin(tmpdir): with mock.patch.object(sys.stdin.buffer, 'read', return_value=b'stdin'): retv, stdin = hook_impl._run_legacy('pre-push', tmpdir, ()) assert (retv, stdin) == (0, b'stdin')
def test_run_legacy_does_not_exist(tmpdir): retv, stdin = hook_impl._run_legacy('pre-commit', tmpdir, ()) assert (retv, stdin) == (0, b'')