@@ -36,26 +36,19 @@ def get_all_files_folders(root_path: pathlib.Path) -> set[pathlib.Path]:
3636
3737
3838def test_package_generation (
39- tmp_path : pathlib . Path ,
39+ default_config_with : typing . Callable ,
4040 generate_package : typing .Callable ,
4141) -> None :
4242 """Test package generation."""
43- test_config = {
44- "github_owner" : "test-user" ,
45- "project_short_description" : "description" ,
46- "project_name" : "Cookiecutter Test" ,
47- # Not having a git repo makes it easier to check in/out reference
48- # data files to the main python-tooling git repository
49- "initialise_git_repository" : False ,
50- }
51- generate_package (config = test_config , path = tmp_path )
43+ # Not having a git repo makes it easier to check in/out reference
44+ # data files to the main python-tooling git repository
45+ config = default_config_with (initialise_git_repository = "False" )
46+ _ , test_project_dir = generate_package (config = config )
5247
5348 expected_package_dir = (
5449 pathlib .Path (__file__ ).parent / "data" / "test_package_generation"
5550 )
56- # Check project directory exists
57- test_project_dir = tmp_path / "cookiecutter-test"
58- assert test_project_dir .exists ()
51+ assert test_project_dir .exists (), "Project directory does not exist."
5952
6053 actual_files = get_all_files_folders (test_project_dir )
6154 expected_files = get_all_files_folders (expected_package_dir )
@@ -78,7 +71,7 @@ def test_package_generation(
7871 f2 .readlines (),
7972 fromfile = str (actual_file ),
8073 tofile = str (expected_file ),
81- )
74+ ),
8275 )
8376
8477 if diff :
@@ -94,18 +87,11 @@ def test_package_generation(
9487
9588
9689def test_pip_installable (
97- tmp_path : pathlib .Path ,
9890 venv : pytest_venv .VirtualEnvironment ,
9991 generate_package : typing .Callable ,
10092) -> None :
10193 """Test generated package is pip installable."""
102- test_config = {
103- "github_owner" : "test-user" ,
104- "project_short_description" : "description" ,
105- "project_name" : "Cookiecutter Test" ,
106- }
107- generate_package (config = test_config , path = tmp_path )
108- test_project_dir = tmp_path / "cookiecutter-test"
94+ _ , test_project_dir = generate_package ()
10995 # Try to install package in virtual environment with pip
11096 pipinstall = subprocess .run ( # noqa: S603
11197 [
@@ -124,46 +110,33 @@ def test_pip_installable(
124110 )
125111
126112
127- @pytest .mark .parametrize ("funder" , ["" , "STFC" ])
113+ @pytest .mark .parametrize ("funder" , ["" , "STFC" , "UKRI" , "Wellcome Trust" ])
128114def test_optional_funder (
129- tmp_path : pathlib .Path , generate_package : typing .Callable , funder : str
115+ funder : str ,
116+ default_config_with : typing .Callable ,
117+ generate_package : typing .Callable ,
130118) -> None :
131119 """Test specifying funder or not in package generation."""
132- config = {
133- "github_owner" : "test-user" ,
134- "project_short_description" : "description" ,
135- "project_name" : "Cookiecutter Test" ,
136- "funder" : funder ,
137- }
138-
139- generate_package (config , tmp_path )
120+ config = default_config_with (funder = funder )
121+ _ , test_project_dir = generate_package (config )
140122
141- test_project_dir = tmp_path / "cookiecutter-test"
142123 with (test_project_dir / "README.md" ).open () as f :
143124 readme_text = "" .join (f .readlines ())
144125
145126 if funder == "" :
146127 assert "## Acknowledgements" not in readme_text
147128 else :
148129 assert (
149- f"## Acknowledgements\n \n This work was funded by { config ['funder' ]} ."
150- in readme_text
130+ f"## Acknowledgements\n \n This work was funded by { funder } ." in readme_text
151131 ), readme_text
152132
153133
154134def test_docs_build (
155- tmp_path : pathlib .Path ,
156135 venv : pytest_venv .VirtualEnvironment ,
157136 generate_package : typing .Callable ,
158137) -> None :
159138 """Test documentation build from package created from template."""
160- config = {
161- "github_owner" : "test-user" ,
162- "project_short_description" : "description" ,
163- "project_name" : "Cookiecutter Test" ,
164- }
165- generate_package (config , tmp_path )
166- test_project_dir = tmp_path / "cookiecutter-test"
139+ _ , test_project_dir = generate_package ()
167140 venv .install ("tox" )
168141 tox_docs_process = subprocess .run ( # noqa: S603
169142 [
0 commit comments