Skip to content

Commit bca9b27

Browse files
committed
Provide values for git author name and email in manage-cookie tests
1 parent c910694 commit bca9b27

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tests/test_manage_cookie.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import os
23
import subprocess
34
import sys
45
from pathlib import Path
@@ -13,6 +14,8 @@
1314

1415
@pytest.fixture
1516
def new_cookie(temp_dir: str) -> Iterator[Path]:
17+
author_name = "Ness"
18+
author_email = "ness@onett.example"
1619
project_name = "unit-test-1"
1720
testargs = [
1821
"new-cookie",
@@ -24,8 +27,8 @@ def new_cookie(temp_dir: str) -> Iterator[Path]:
2427
"--extra-context",
2528
json.dumps(
2629
{
27-
"author_email": "ness@onett.example",
28-
"author_name": "Ness",
30+
"author_email": author_email,
31+
"author_name": author_name,
2932
"github_user": "ness.unittest.example",
3033
"project_description": "Unit test project",
3134
"project_name": project_name,
@@ -37,12 +40,21 @@ def new_cookie(temp_dir: str) -> Iterator[Path]:
3740
with patch.object(sys, "argv", testargs):
3841
new_cookie_main()
3942
project_dir = Path(temp_dir) / project_name
43+
environ = os.environ.copy()
44+
environ.update(
45+
dict(
46+
GIT_AUTHOR_NAME=author_name,
47+
GIT_AUTHOR_EMAIL=author_email,
48+
GIT_COMMITTER_NAME=author_name,
49+
GIT_COMMITTER_EMAIL=author_email,
50+
)
51+
)
4052
for cmd in (
4153
["poetry", "lock", "--no-update"],
4254
["git", "add", "poetry.lock"],
4355
["git", "commit", "-m", "Create `poetry.lock`"],
4456
):
45-
subprocess.run(cmd, cwd=project_dir, check=True)
57+
subprocess.run(cmd, cwd=project_dir, check=True, env=environ)
4658
yield project_dir
4759

4860

0 commit comments

Comments
 (0)