@@ -32,37 +32,33 @@ def dummy_git_repo(empty_git_dir):
3232 yield empty_git_dir
3333
3434
35+ def _make_repo (repo_path , repo_source ):
36+ copy_tree_to_path (get_resource_path (repo_source ), repo_path )
37+ add_and_commit ()
38+ return repo_path
39+
40+
3541@pytest .yield_fixture
3642def python_hooks_repo (dummy_git_repo ):
37- copy_tree_to_path (
38- get_resource_path ('python_hooks_repo' ),
39- dummy_git_repo ,
40- )
41- add_and_commit ()
42- yield dummy_git_repo
43+ yield _make_repo (dummy_git_repo , 'python_hooks_repo' )
4344
4445
4546@pytest .yield_fixture
4647def node_hooks_repo (dummy_git_repo ):
47- copy_tree_to_path (
48- get_resource_path ('node_hooks_repo' ),
49- dummy_git_repo ,
50- )
51- add_and_commit ()
52- yield dummy_git_repo
48+ yield _make_repo (dummy_git_repo , 'node_hooks_repo' )
5349
5450
5551@pytest .yield_fixture
5652def consumer_repo (dummy_git_repo ):
57- copy_tree_to_path (
58- get_resource_path ('consumer_repo' ),
59- dummy_git_repo ,
60- )
61- add_and_commit ()
62- yield dummy_git_repo
53+ yield _make_repo (dummy_git_repo , 'consumer_repo' )
6354
6455
65- @pytest .fixture
56+ @pytest .yield_fixture
57+ def prints_cwd_repo (dummy_git_repo ):
58+ yield _make_repo (dummy_git_repo , 'prints_cwd_repo' )
59+
60+
61+ @pytest .yield_fixture
6662def config_for_node_hooks_repo (node_hooks_repo ):
6763 config = {
6864 'repo' : node_hooks_repo ,
@@ -74,11 +70,10 @@ def config_for_node_hooks_repo(node_hooks_repo):
7470 }
7571 jsonschema .validate ([config ], CONFIG_JSON_SCHEMA )
7672 validate_config_extra ([config ])
77-
78- return config
73+ yield config
7974
8075
81- @pytest .fixture
76+ @pytest .yield_fixture
8277def config_for_python_hooks_repo (python_hooks_repo ):
8378 config = {
8479 'repo' : python_hooks_repo ,
@@ -90,5 +85,19 @@ def config_for_python_hooks_repo(python_hooks_repo):
9085 }
9186 jsonschema .validate ([config ], CONFIG_JSON_SCHEMA )
9287 validate_config_extra ([config ])
88+ yield config
89+
9390
94- return config
91+ @pytest .yield_fixture
92+ def config_for_prints_cwd_repo (prints_cwd_repo ):
93+ config = {
94+ 'repo' : prints_cwd_repo ,
95+ 'sha' : git .get_head_sha (prints_cwd_repo ),
96+ 'hooks' : [{
97+ 'id' : 'prints_cwd' ,
98+ 'files' : '\.py$' ,
99+ }],
100+ }
101+ jsonschema .validate ([config ], CONFIG_JSON_SCHEMA )
102+ validate_config_extra ([config ])
103+ yield config
0 commit comments