22
33import os
44import pathlib
5+ import shutil
56import subprocess
67import uuid
78
@@ -50,16 +51,22 @@ def _(*variables):
5051
5152
5253@pytest .fixture
53- def commit (integration_dir ):
54+ def git ():
55+ return shutil .which ("git" )
56+
57+
58+ @pytest .fixture
59+ def commit (integration_dir , git ):
5460 def _ ():
5561 subprocess .check_call (
56- [" git" , "add" , "." ],
62+ [git , "add" , "." ],
5763 cwd = integration_dir ,
5864 )
5965 subprocess .check_call (
60- [" git" , "commit" , "-m" , str (uuid .uuid4 ())],
66+ [git , "commit" , "-m" , str (uuid .uuid4 ())],
6167 cwd = integration_dir ,
62- env = {
68+ env = os .environ
69+ | {
6370 "GIT_AUTHOR_NAME" : "foo" ,
6471 "GIT_AUTHOR_EMAIL" : "foo" ,
6572 "GIT_COMMITTER_NAME" : "foo" ,
@@ -73,27 +80,27 @@ def _():
7380
7481
7582@pytest .fixture
76- def integration_env (integration_dir , write_file , run_coverage , commit , request ):
77- subprocess .check_call ([" git" , "init" , "-b" , "main" ], cwd = integration_dir )
83+ def integration_env (integration_dir , write_file , run_coverage , commit , request , git ):
84+ subprocess .check_call ([git , "init" , "-b" , "main" ], cwd = integration_dir )
7885 # diff coverage reads the "origin/{...}" branch so we simulate an origin remote
79- subprocess .check_call ([" git" , "remote" , "add" , "origin" , "." ], cwd = integration_dir )
86+ subprocess .check_call ([git , "remote" , "add" , "origin" , "." ], cwd = integration_dir )
8087 write_file ("A" , "B" )
8188 commit ()
8289
8390 add_branch_mark = request .node .get_closest_marker ("add_branches" )
8491 for additional_branch in add_branch_mark .args if add_branch_mark else []:
8592 subprocess .check_call (
86- [" git" , "switch" , "-c" , additional_branch ],
93+ [git , "switch" , "-c" , additional_branch ],
8794 cwd = integration_dir ,
8895 )
8996
9097 subprocess .check_call (
91- [" git" , "switch" , "-c" , "branch" ],
98+ [git , "switch" , "-c" , "branch" ],
9299 cwd = integration_dir ,
93100 )
94101
95102 write_file ("A" , "B" , "C" , "D" )
96103 commit ()
97104
98105 run_coverage ("A" , "C" )
99- subprocess .check_call ([" git" , "fetch" , "origin" ], cwd = integration_dir )
106+ subprocess .check_call ([git , "fetch" , "origin" ], cwd = integration_dir )
0 commit comments