Skip to content

Commit b2452f0

Browse files
committed
Allow passing an environment to _run and _generate_repo
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 2d48d01 commit b2452f0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/integration/test_cookiecutter_generation.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
"""Generation tests for cookiecutter."""
55

6+
import os
67
import pathlib
78
import re
89
import 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

9598
def _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

106116
def _read_golden_file(golden_path: pathlib.Path, name: str) -> str:

0 commit comments

Comments
 (0)