11import subprocess
2+ import sys
23
34import pytest
5+ from cookiecutter .exceptions import CookiecutterException
46from cookiecutter .main import cookiecutter
57
68
79def sanity_check_project (proj_path ):
810 """Sanity-check a generated project (linters, tests, doc generation)."""
9- subprocess .check_call ("poetry install --with docs" .split (), cwd = proj_path )
10- subprocess .check_call ("poetry run poe lint --all-files" .split (), cwd = proj_path )
11- subprocess .check_call ("poetry run poe test" .split (), cwd = proj_path )
12- subprocess .check_call ("poetry run poe docs" .split (), cwd = proj_path )
11+ try :
12+ subprocess .check_output (
13+ "poetry install --with docs" .split (), cwd = proj_path , stderr = subprocess .PIPE
14+ )
15+ subprocess .check_output (
16+ "poetry run poe lint --all-files" .split (),
17+ cwd = proj_path ,
18+ stderr = subprocess .PIPE ,
19+ )
20+ subprocess .check_output (
21+ "poetry run poe test" .split (), cwd = proj_path , stderr = subprocess .PIPE
22+ )
23+ subprocess .check_output (
24+ "poetry run poe docs" .split (), cwd = proj_path , stderr = subprocess .PIPE
25+ )
26+ except subprocess .CalledProcessError as e :
27+ print ("exit code: {}" .format (e .returncode ))
28+ print ("stderr: {}" .format (e .stderr .decode (sys .getfilesystemencoding ())))
1329
1430
1531@pytest .fixture
@@ -23,9 +39,25 @@ def gen(tmp_path_factory):
2339
2440 def gen_project (** cc_args ):
2541 out_dir = tmp_path_factory .mktemp ("gen_proj" )
42+ out_dir_raw = tmp_path_factory .mktemp ("gen_proj_raw" )
2643
27- # actual project generation
28- cookiecutter (template = "./" , no_input = True , output_dir = out_dir , ** cc_args )
44+ # NOTE: once 2.1.2 is out with keep_project_on_failure,
45+ # this can be simplified
46+ # instantiate without hooks (for debugging)
47+ cookiecutter (
48+ template = "./" ,
49+ no_input = True ,
50+ output_dir = out_dir_raw ,
51+ accept_hooks = False ,
52+ ** cc_args ,
53+ )
54+
55+ # actual project generation (with hooks)
56+ try :
57+ cookiecutter (template = "./" , no_input = True , output_dir = out_dir , ** cc_args )
58+ except CookiecutterException as e :
59+ print (f"DEBUG DIR (without hook evaluation): { out_dir_raw } " )
60+ raise e
2961
3062 # should be unique directory
3163 paths = list (out_dir .iterdir ())
0 commit comments