@@ -37,7 +37,7 @@ This pytest plugin works by providing {ref}`pytest fixtures <pytest:fixtures-api
37
37
38
38
## Recommended Fixtures
39
39
40
- When the plugin is enabled and ` pytest ` is run, these fixtures are automatically used:
40
+ When the plugin is enabled and ` pytest ` is run, these overridable fixtures are automatically used:
41
41
42
42
- Create temporary test directories for:
43
43
- ` /home/ ` ({func}` home_path ` )
@@ -50,6 +50,11 @@ When the plugin is enabled and `pytest` is run, these fixtures are automatically
50
50
- Set default VCS configurations:
51
51
- Use {func}` hgconfig ` for [ ` HGRCPATH ` ] via {func}` set_hgconfig `
52
52
- Use {func}` gitconfig ` for [ ` GIT_CONFIG ` ] via {func}` set_gitconfig `
53
+ - Set default commit names and emails:
54
+ - Name: {func}` vcs_name `
55
+ - Email: {func}` vcs_email `
56
+ - User (e.g. _ ` user <email@tld> ` _ ): {func}` vcs_user `
57
+ - For git only: {func}` git_commit_envvars `
53
58
54
59
These ensure that repositories can be cloned and created without unnecessary warnings.
55
60
@@ -74,10 +79,19 @@ def setup(set_home: None):
74
79
pass
75
80
```
76
81
77
- ### Setting a Default VCS Configuration
82
+ ### VCS Configuration
78
83
79
84
#### Git
80
85
86
+ You can override the default author used in {func}` git_remote_repo ` and other
87
+ fixtures via {func}` vcs_name ` , {func}` vcs_email ` , and {func}` vcs_user ` :
88
+
89
+ ```
90
+ @pytest.fixture(scope="session")
91
+ def vcs_name() -> str:
92
+ return "My custom name"
93
+ ```
94
+
81
95
Use the {func}` set_gitconfig ` fixture with ` autouse=True ` :
82
96
83
97
``` python
@@ -88,6 +102,27 @@ def setup(set_gitconfig: None):
88
102
pass
89
103
```
90
104
105
+ Sometimes, ` set_getconfig ` via ` GIT_CONFIG ` doesn't apply as expected. For those
106
+ cases, you can use {func}` git_commit_envvars ` :
107
+
108
+ ``` python
109
+ import pytest
110
+
111
+ @pytest.fixture
112
+ def my_git_repo (
113
+ create_git_remote_repo : CreateRepoPytestFixtureFn,
114
+ gitconfig : pathlib.Path,
115
+ git_commit_envvars : " _ENV" ,
116
+ ) -> pathlib.Path:
117
+ """ Copy the session-scoped Git repository to a temporary directory."""
118
+ repo_path = create_git_remote_repo()
119
+ git_remote_repo_single_commit_post_init(
120
+ remote_repo_path = repo_path,
121
+ env = git_commit_envvars,
122
+ )
123
+ return repo_path
124
+ ```
125
+
91
126
#### Mercurial
92
127
93
128
Use the {func}` set_hgconfig ` fixture with ` autouse=True ` :
0 commit comments