@@ -108,17 +108,25 @@ def set_home(
108108 monkeypatch .setenv ("HOME" , str (user_path ))
109109
110110
111- @pytest .fixture
111+ 112+
113+
114+ @pytest .fixture (scope = "session" )
112115@skip_if_git_missing
113- def gitconfig (user_path : pathlib .Path ) -> pathlib .Path :
116+ def gitconfig (
117+ user_path : pathlib .Path ,
118+ ) -> pathlib .Path :
114119 """Return git configuration, pytest fixture."""
115120 gitconfig = user_path / ".gitconfig"
116- 121+
122+ if gitconfig .exists ():
123+ return gitconfig
124+
117125 gitconfig .write_text (
118126 textwrap .dedent (
119127 f"""
120128 [user]
121- email = { user_email }
129+ email = { vcs_email }
122130 name = { getpass .getuser ()}
123131 [color]
124132 diff = auto
@@ -127,26 +135,26 @@ def gitconfig(user_path: pathlib.Path) -> pathlib.Path:
127135 encoding = "utf-8" ,
128136 )
129137
130- output = run (["git" , "config" , "--get" , "user.email" ])
131- used_config_file_output = run (
132- [
133- "git" ,
134- "config" ,
135- "--show-origin" ,
136- "--get" ,
137- "user.email" ,
138- ],
139- )
140- assert str (gitconfig ) in used_config_file_output
141- assert user_email in output , "Should use our fixture config and home directory"
142-
143138 return gitconfig
144139
145140
146141@pytest .fixture
142+ @skip_if_git_missing
143+ def set_gitconfig (
144+ monkeypatch : pytest .MonkeyPatch ,
145+ gitconfig : pathlib .Path ,
146+ ) -> pathlib .Path :
147+ """Set git configuration."""
148+ monkeypatch .setenv ("GIT_CONFIG" , str (gitconfig ))
149+ return gitconfig
150+
151+
152+ @pytest .fixture (scope = "session" )
147153@skip_if_hg_missing
148- def hgconfig (user_path : pathlib .Path ) -> pathlib .Path :
149- """Return Mercurial configuration, pytest fixture."""
154+ def hgconfig (
155+ user_path : pathlib .Path ,
156+ ) -> pathlib .Path :
157+ """Return Mercurial configuration."""
150158 hgrc = user_path / ".hgrc"
151159 hgrc .write_text (
152160 textwrap .dedent (
@@ -164,6 +172,17 @@ def hgconfig(user_path: pathlib.Path) -> pathlib.Path:
164172 return hgrc
165173
166174
175+ @pytest .fixture
176+ @skip_if_hg_missing
177+ def set_hgconfig (
178+ monkeypatch : pytest .MonkeyPatch ,
179+ hgconfig : pathlib .Path ,
180+ ) -> pathlib .Path :
181+ """Set Mercurial configuration."""
182+ monkeypatch .setenv ("HGRCPATH" , str (hgconfig ))
183+ return hgconfig
184+
185+
167186@pytest .fixture
168187def projects_path (
169188 user_path : pathlib .Path ,
0 commit comments