@@ -9,6 +9,26 @@ def successfully_created_project(result):
99 return result .exit_code == 0 and result .exception is None and result .project_dir .is_dir ()
1010
1111
12+ def contains_required_files (result ):
13+ required_files = [
14+ ".copier-answers.yml" ,
15+ ".git_archival.txt" ,
16+ ".gitattributes" ,
17+ ".gitignore" ,
18+ ".pre-commit-config.yaml" ,
19+ ".setup_dev.sh" ,
20+ "LICENSE" ,
21+ "pyproject.toml" ,
22+ "README.md" ,
23+ ]
24+ all_found = True
25+ for file in required_files :
26+ if not (result .project_dir / file ).is_file ():
27+ all_found = False
28+ print ("Required file not generated:" , file )
29+ return all_found
30+
31+
1232def directory_structure_is_correct (result , package_name = "example_package" ):
1333 """Test to ensure that the default directory structure ws created correctly"""
1434 return (result .project_dir / f"src/{ package_name } " ).is_dir () and (
@@ -65,14 +85,24 @@ def docs_build_successfully(result):
6585 virtual environment for the project.
6686 """
6787
68- sphinx_results = subprocess .run (
69- ["make" , "html" ],
70- cwd = (result .project_dir / "docs" ),
71- )
88+ required_files = [
89+ ".readthedocs.yml" ,
90+ ]
91+ all_found = True
92+ for file in required_files :
93+ if not (result .project_dir / file ).is_file ():
94+ all_found = False
95+ print ("Required file not generated:" , file )
96+ return all_found
97+
98+ # sphinx_results = subprocess.run(
99+ # ["make", "html"],
100+ # cwd=(result.project_dir / "docs"),
101+ # )
102+
103+ # return sphinx_results.returncode == 0
72104
73- return sphinx_results .returncode == 0
74105
75-
76106def github_workflows_are_valid (result ):
77107 """Test to ensure that the GitHub workflows are valid"""
78108 workflows_results = subprocess .run (
@@ -95,14 +125,9 @@ def test_all_defaults(copie):
95125 result = copie .copy ()
96126
97127 assert successfully_created_project (result )
98-
99128 assert directory_structure_is_correct (result )
100-
101129 assert not pylint_runs_successfully (result )
102-
103- # make sure that some basic files were created
104- assert (result .project_dir / "README.md" ).is_file ()
105- assert (result .project_dir / "pyproject.toml" ).is_file ()
130+ assert contains_required_files (result )
106131
107132 # check to see if the README file was hydrated with copier answers.
108133 found_line = False
@@ -130,10 +155,9 @@ def test_use_black_and_no_example_modules(copie):
130155 result = copie .copy (extra_answers = extra_answers )
131156
132157 assert successfully_created_project (result )
133-
134158 assert directory_structure_is_correct (result )
135-
136159 assert pylint_runs_successfully (result )
160+ assert contains_required_files (result )
137161
138162 # make sure that the files that were not requested were not created
139163 assert not (result .project_dir / "src/example_package/example_module.py" ).is_file ()
@@ -174,6 +198,7 @@ def test_code_style_combinations(copie, enforce_style):
174198 result = copie .copy (extra_answers = extra_answers )
175199 assert successfully_created_project (result )
176200 assert directory_structure_is_correct (result )
201+ assert contains_required_files (result )
177202 # black would still run successfully.
178203 assert black_runs_successfully (result )
179204
@@ -202,6 +227,7 @@ def test_smoke_test_notification(copie, notification):
202227 assert successfully_created_project (result )
203228 assert directory_structure_is_correct (result )
204229 assert black_runs_successfully (result )
230+ assert contains_required_files (result )
205231
206232
207233@pytest .mark .parametrize (
@@ -226,6 +252,8 @@ def test_doc_combinations(copie, doc_answers):
226252 assert successfully_created_project (result )
227253 assert directory_structure_is_correct (result )
228254 assert black_runs_successfully (result )
255+ assert contains_required_files (result )
256+ assert docs_build_successfully (result )
229257 assert (result .project_dir / "docs" ).is_dir ()
230258
231259
@@ -251,9 +279,10 @@ def test_doc_combinations_no_docs(copie, doc_answers):
251279 assert successfully_created_project (result )
252280 assert directory_structure_is_correct (result )
253281 assert black_runs_successfully (result )
282+ assert contains_required_files (result )
254283 assert not (result .project_dir / "docs" ).is_dir ()
255284
256-
285+
257286def test_github_workflows_schema (copie ):
258287 """Confirm the current GitHub workflows have valid schemas."""
259288 extra_answers = {
@@ -263,3 +292,4 @@ def test_github_workflows_schema(copie):
263292 result = copie .copy (extra_answers = extra_answers )
264293 initialize_git_project (result )
265294 assert github_workflows_are_valid (result )
295+ assert contains_required_files (result )
0 commit comments