1
1
import json
2
+ import os
2
3
import subprocess
3
4
import sys
4
5
from pathlib import Path
13
14
14
15
@pytest .fixture
15
16
def new_cookie (temp_dir : str ) -> Iterator [Path ]:
17
+ author_name = "Ness"
18
+ author_email = "ness@onett.example"
16
19
project_name = "unit-test-1"
17
20
testargs = [
18
21
"new-cookie" ,
@@ -24,8 +27,8 @@ def new_cookie(temp_dir: str) -> Iterator[Path]:
24
27
"--extra-context" ,
25
28
json .dumps (
26
29
{
27
- "author_email" : "ness@onett.example" ,
28
- "author_name" : "Ness" ,
30
+ "author_email" : author_email ,
31
+ "author_name" : author_name ,
29
32
"github_user" : "ness.unittest.example" ,
30
33
"project_description" : "Unit test project" ,
31
34
"project_name" : project_name ,
@@ -37,12 +40,21 @@ def new_cookie(temp_dir: str) -> Iterator[Path]:
37
40
with patch .object (sys , "argv" , testargs ):
38
41
new_cookie_main ()
39
42
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
+ )
40
52
for cmd in (
41
53
["poetry" , "lock" , "--no-update" ],
42
54
["git" , "add" , "poetry.lock" ],
43
55
["git" , "commit" , "-m" , "Create `poetry.lock`" ],
44
56
):
45
- subprocess .run (cmd , cwd = project_dir , check = True )
57
+ subprocess .run (cmd , cwd = project_dir , check = True , env = environ )
46
58
yield project_dir
47
59
48
60
0 commit comments