33"""
44
55import pathlib
6- import tempfile
6+ import shutil
77
88import pytest
99from cookiecutter .main import cookiecutter
1010
1111
12- @pytest .fixture ( scope = "session" , autouse = True )
12+ @pytest .fixture
1313def cookiecutter_dir () -> pathlib .Path :
1414 """
1515 CookieCutter Tests
1616 """
17- with tempfile .TemporaryDirectory () as tmpdir :
18- tmp_path = pathlib .Path (tmpdir )
19- _this_file = pathlib .Path (__file__ ).resolve ()
20- cookiecutter_dir = _this_file .parent .parent
21- cookiecutter (
22- template = str (cookiecutter_dir ),
23- output_dir = str (tmp_path ),
24- no_input = True ,
25- extra_context = {
26- "build_docker_image" : True ,
27- "publish_to_pypi" : True ,
28- "publish_to_docker_hub" : True ,
29- }
30- )
31- yield tmp_path / "example-project"
17+ _this_file = pathlib .Path (__file__ ).resolve ()
18+ cookiecutter_dir = _this_file .parent .parent
19+ test_dir = cookiecutter_dir / "tests"
20+ output_dir = test_dir / "output"
21+ output_repo = output_dir / "example-project"
22+ shutil .rmtree (output_dir , ignore_errors = True )
23+ cookiecutter (
24+ template = str (cookiecutter_dir ),
25+ output_dir = str (output_dir ),
26+ no_input = True ,
27+ extra_context = {
28+ "build_docker_image" : True ,
29+ "publish_to_pypi" : True ,
30+ "publish_to_docker_hub" : True ,
31+ }
32+ )
33+ return output_repo
3234
3335
3436def test_cookiecutter_dir (cookiecutter_dir : pathlib .Path ) -> None :
@@ -48,7 +50,7 @@ def test_cookiecutter_dir(cookiecutter_dir: pathlib.Path) -> None:
4850 try :
4951 assert expected == actual
5052 except AssertionError as e :
51- msg = f"Unexpected File Difference - { test_path } "
53+ msg = f"Unexpected File Difference - { test_path } - { generated_file } "
5254 raise ValueError (msg ) from e
5355 file_counter += 1
5456 assert file_counter > 0
0 commit comments