33
44"""Generation tests for cookiecutter."""
55
6+ import os
67import pathlib
78import re
89import shutil
@@ -73,6 +74,7 @@ def _generate_repo(
7374 / ,
7475 * ,
7576 capture_output : bool = False ,
77+ env : dict [str , str ] | None = None ,
7678) -> tuple [pathlib .Path , subprocess .CompletedProcess [bytes ]]:
7779 cwd = pathlib .Path ().cwd ()
7880 run_result = _run (
@@ -84,6 +86,7 @@ def _generate_repo(
8486 "name=test" ,
8587 "description=Test description" ,
8688 capture_output = capture_output ,
89+ env = env ,
8790 )
8891
8992 subdirs = list (tmp_path .iterdir ())
@@ -93,14 +96,21 @@ def _generate_repo(
9396
9497
9598def _run (
96- cwd : pathlib .Path , / , * cmd : str , capture_output : bool = False , check : bool = True
99+ cwd : pathlib .Path ,
100+ / ,
101+ * cmd : str ,
102+ capture_output : bool = False ,
103+ check : bool = True ,
104+ env : dict [str , str ] | None = None ,
97105) -> subprocess .CompletedProcess [bytes ]:
98106 """Run a command in a subprocess."""
99107 print ()
100108 print ("-" * 80 )
101109 print (f"Running [{ cwd } ]: { ' ' .join (cmd )} " )
102110 print ()
103- return subprocess .run (cmd , cwd = cwd , check = check , capture_output = capture_output )
111+ return subprocess .run (
112+ cmd , cwd = cwd , check = check , capture_output = capture_output , env = env
113+ )
104114
105115
106116def _read_golden_file (golden_path : pathlib .Path , name : str ) -> str :
0 commit comments