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

Function test_init_templatedir

tests/commands/init_templatedir_test.py:19–40  ·  view source on GitHub ↗
(tmpdir, tempdir_factory, store, cap_out)

Source from the content-addressed store, hash-verified

17
18
19def test_init_templatedir(tmpdir, tempdir_factory, store, cap_out):
20 target = str(tmpdir.join('tmpl'))
21 init_templatedir(C.CONFIG_FILE, store, target, hook_types=['pre-commit'])
22 lines = cap_out.get().splitlines()
23 assert lines[0].startswith('pre-commit installed at ')
24 assert lines[1] == (
25 '[WARNING] `init.templateDir` not set to the target directory'
26 )
27 assert lines[2].startswith(
28 '[WARNING] maybe `git config --global init.templateDir',
29 )
30
31 with envcontext((('GIT_TEMPLATE_DIR', target),)):
32 path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
33
34 with cwd(path):
35 retcode, output = git_commit(
36 fn=cmd_output_mocked_pre_commit_home,
37 tempdir_factory=tempdir_factory,
38 )
39 assert retcode == 0
40 assert 'Bash hook....' in output
41
42
43def test_init_templatedir_already_set(tmpdir, tempdir_factory, store, cap_out):

Callers

nothing calls this directly

Calls 6

init_templatedirFunction · 0.90
envcontextFunction · 0.90
make_consuming_repoFunction · 0.90
cwdFunction · 0.90
git_commitFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected