Skip to content

Commit 46719c5

Browse files
authored
pytest_plugin: rename gitconfig/hgconfig → vcs_-prefixed (#529)
Vacate the `gitconfig` / `hgconfig` pytest fixture names that collided with the third-party `pytest-gitconfig` plugin. When both plugins auto-loaded (e.g. via Arch's python-copier package using a system-site-packages venv), downstream tests crashed with `AttributeError: 'PosixPath' object has no attribute 'set'`. Renames adopt the `vcs_` prefix already used by `vcs_name`, `vcs_email`, and `vcs_user`: - `gitconfig` → `vcs_gitconfig` - `set_gitconfig` → `set_vcs_gitconfig` - `hgconfig` → `vcs_hgconfig` - `set_hgconfig` → `set_vcs_hgconfig` **Breaking changes:** No deprecation alias is provided — registering the old names would still occupy the shared namespace and defeat the deconfliction. Downstream test suites that referenced the old fixture names must update their parameter names. Internal callers across the pytest plugin, root conftest, and libvcs's own test suite are updated. `docs/api/pytest-plugin.md`, `CHANGES`, `MIGRATION`, and `AGENTS.md` are kept in sync. Fixes #528 See also: vcs-python/vcspull#548 (downstream coordination)
2 parents 3305ea4 + 17b6484 commit 46719c5

10 files changed

Lines changed: 83 additions & 46 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ libvcs uses pytest for testing with many custom fixtures. The pytest plugin (`py
146146
- `create_hg_remote_repo`: Creates a Mercurial repository for testing
147147
- `create_svn_remote_repo`: Creates a Subversion repository for testing
148148
- `git_repo`, `svn_repo`, `hg_repo`: Pre-made repository instances
149-
- `set_home`, `gitconfig`, `hgconfig`, `git_commit_envvars`: Environment fixtures
149+
- `set_home`, `vcs_gitconfig`, `vcs_hgconfig`, `git_commit_envvars`: Environment fixtures
150150

151151
These fixtures handle setup and teardown automatically, creating isolated test environments.
152152

CHANGES

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ $ uv add libvcs --prerelease allow
2020
_Notes on the upcoming release will go here._
2121
<!-- END PLACEHOLDER - ADD NEW CHANGELOG ENTRIES BELOW THIS LINE -->
2222

23+
### Breaking changes
24+
25+
#### pytest plugin: Rename `gitconfig` / `hgconfig` fixtures (#528)
26+
27+
The pytest plugin's `gitconfig`, `set_gitconfig`, `hgconfig`, and
28+
`set_hgconfig` fixtures are renamed to `vcs_gitconfig`,
29+
`set_vcs_gitconfig`, `vcs_hgconfig`, and `set_vcs_hgconfig`
30+
respectively, matching the existing `vcs_name` / `vcs_email` / `vcs_user`
31+
convention.
32+
33+
The unprefixed names collided with the third-party
34+
[`pytest-gitconfig`](https://pypi.org/project/pytest-gitconfig/) plugin,
35+
which exposes a `gitconfig` fixture returning a `GitConfig` helper
36+
rather than a `pathlib.Path`. When both plugins auto-loaded, downstream
37+
tests crashed with `AttributeError: 'PosixPath' object has no attribute 'set'`.
38+
39+
No deprecation alias is provided -- the entire point of the rename is
40+
to vacate the shared name. Downstream test suites that referenced the
41+
old fixture names must update parameter names accordingly.
42+
2343
### Bug fixes
2444

2545
- Fix dark-theme flash when light theme is selected — the docs

MIGRATION

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ _Notes on the upcoming release will be added here_
2424

2525
<!-- Maintainers, insert migration notes for the next release here -->
2626

27+
### pytest fixtures: `gitconfig` / `hgconfig` renamed to `vcs_gitconfig` / `vcs_hgconfig` (#528)
28+
29+
- pytest: `gitconfig` renamed to `vcs_gitconfig`
30+
- pytest: `set_gitconfig` renamed to `set_vcs_gitconfig`
31+
- pytest: `hgconfig` renamed to `vcs_hgconfig`
32+
- pytest: `set_hgconfig` renamed to `set_vcs_hgconfig`
33+
34+
The unprefixed names collided with the third-party
35+
[`pytest-gitconfig`](https://pypi.org/project/pytest-gitconfig/) plugin,
36+
which exposes a `gitconfig` fixture returning a `GitConfig` helper rather
37+
than a `pathlib.Path`. When both plugins auto-loaded, downstream tests
38+
crashed with `AttributeError: 'PosixPath' object has no attribute 'set'`.
39+
40+
No deprecation alias is provided -- update parameter names in test
41+
suites, conftests, and any embedded `pytester.makeconftest` text that
42+
references these fixtures.
43+
2744
### pytest fixtures: `git_local_clone` renamed to `example_git_repo` (#468)
2845

2946
- pytest: `git_local_clone` renamed to `example_git_repo`

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def cwd_default(monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path) -> None
4242
@pytest.fixture(autouse=True)
4343
def setup(
4444
request: pytest.FixtureRequest,
45-
gitconfig: pathlib.Path,
45+
vcs_gitconfig: pathlib.Path,
4646
set_home: pathlib.Path,
4747
) -> None:
4848
"""Configure test fixtures for pytest."""

docs/api/pytest-plugin.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ and home-directory setup without repeating bootstrap code in every suite.
1616
These fixtures are the usual starting point when enabling the plugin:
1717

1818
- {fixture}`set_home` patches `$HOME` to point at {fixture}`user_path`.
19-
- {fixture}`set_gitconfig` and {fixture}`set_hgconfig` apply stable VCS
20-
configuration.
19+
- {fixture}`set_vcs_gitconfig` and {fixture}`set_vcs_hgconfig` apply stable
20+
VCS configuration.
2121
- {fixture}`vcs_name`, {fixture}`vcs_email`, and {fixture}`vcs_user` let you
2222
override commit identity defaults.
2323
- {fixture}`git_commit_envvars` helps when Git ignores `GIT_CONFIG` in a
@@ -35,8 +35,8 @@ import pytest
3535
@pytest.fixture(autouse=True)
3636
def setup(
3737
set_home: None,
38-
set_gitconfig: None,
39-
set_hgconfig: None,
38+
set_vcs_gitconfig: None,
39+
set_vcs_hgconfig: None,
4040
) -> None:
4141
pass
4242
```

src/libvcs/pytest_plugin.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def vcs_user(vcs_name: str, vcs_email: str) -> str:
6969
def git_commit_envvars(vcs_name: str, vcs_email: str) -> GitCommitEnvVars:
7070
"""Return environment variables for `git commit`.
7171
72-
For some reason, `GIT_CONFIG` via {func}`set_gitconfig` doesn't work for `git
73-
commit`.
72+
For some reason, `GIT_CONFIG` via {func}`set_vcs_gitconfig` doesn't work for
73+
`git commit`.
7474
"""
7575
return {
7676
"GIT_AUTHOR_NAME": vcs_name,
@@ -146,7 +146,7 @@ def set_home(
146146

147147
@pytest.fixture(scope="session")
148148
@skip_if_git_missing
149-
def gitconfig(
149+
def vcs_gitconfig(
150150
user_path: pathlib.Path,
151151
vcs_email: str,
152152
vcs_name: str,
@@ -174,19 +174,19 @@ def gitconfig(
174174

175175
@pytest.fixture
176176
@skip_if_git_missing
177-
def set_gitconfig(
177+
def set_vcs_gitconfig(
178178
monkeypatch: pytest.MonkeyPatch,
179-
gitconfig: pathlib.Path,
179+
vcs_gitconfig: pathlib.Path,
180180
) -> pathlib.Path:
181181
"""Set git configuration."""
182-
monkeypatch.setenv("GIT_CONFIG", str(gitconfig))
183-
monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(gitconfig)) # For child processes
184-
return gitconfig
182+
monkeypatch.setenv("GIT_CONFIG", str(vcs_gitconfig))
183+
monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(vcs_gitconfig)) # For child processes
184+
return vcs_gitconfig
185185

186186

187187
@pytest.fixture(scope="session")
188188
@skip_if_hg_missing
189-
def hgconfig(
189+
def vcs_hgconfig(
190190
user_path: pathlib.Path,
191191
vcs_user: str,
192192
) -> pathlib.Path:
@@ -210,13 +210,13 @@ def hgconfig(
210210

211211
@pytest.fixture
212212
@skip_if_hg_missing
213-
def set_hgconfig(
213+
def set_vcs_hgconfig(
214214
monkeypatch: pytest.MonkeyPatch,
215-
hgconfig: pathlib.Path,
215+
vcs_hgconfig: pathlib.Path,
216216
) -> pathlib.Path:
217217
"""Set Mercurial configuration."""
218-
monkeypatch.setenv("HGRCPATH", str(hgconfig))
219-
return hgconfig
218+
monkeypatch.setenv("HGRCPATH", str(vcs_hgconfig))
219+
return vcs_hgconfig
220220

221221

222222
@pytest.fixture
@@ -458,7 +458,7 @@ def git_remote_repo_single_commit_post_init(
458458
@skip_if_git_missing
459459
def git_remote_repo(
460460
create_git_remote_repo: CreateRepoFn,
461-
gitconfig: pathlib.Path,
461+
vcs_gitconfig: pathlib.Path,
462462
git_commit_envvars: GitCommitEnvVars,
463463
) -> pathlib.Path:
464464
"""Copy the session-scoped Git repository to a temporary directory."""
@@ -649,7 +649,7 @@ def empty_hg_repo(
649649
def create_hg_remote_repo(
650650
remote_repos_path: pathlib.Path,
651651
empty_hg_repo: pathlib.Path,
652-
hgconfig: pathlib.Path,
652+
vcs_hgconfig: pathlib.Path,
653653
) -> CreateRepoFn:
654654
"""Pre-made hg repo, bare, used as a file:// remote to checkout and commit to."""
655655

@@ -668,7 +668,7 @@ def fn(
668668
if remote_repo_post_init is not None and callable(remote_repo_post_init):
669669
remote_repo_post_init(
670670
remote_repo_path=remote_repo_path,
671-
env={"HGRCPATH": str(hgconfig)},
671+
env={"HGRCPATH": str(vcs_hgconfig)},
672672
)
673673

674674
assert empty_hg_repo.exists()
@@ -685,13 +685,13 @@ def fn(
685685
def hg_remote_repo(
686686
remote_repos_path: pathlib.Path,
687687
create_hg_remote_repo: CreateRepoFn,
688-
hgconfig: pathlib.Path,
688+
vcs_hgconfig: pathlib.Path,
689689
) -> pathlib.Path:
690690
"""Pre-made, file-based repo for push and pull."""
691691
repo_path = create_hg_remote_repo()
692692
hg_remote_repo_single_commit_post_init(
693693
remote_repo_path=repo_path,
694-
env={"HGRCPATH": str(hgconfig)},
694+
env={"HGRCPATH": str(vcs_hgconfig)},
695695
)
696696
return repo_path
697697

@@ -701,7 +701,7 @@ def git_repo(
701701
remote_repos_path: pathlib.Path,
702702
projects_path: pathlib.Path,
703703
git_remote_repo: pathlib.Path,
704-
set_gitconfig: pathlib.Path,
704+
set_vcs_gitconfig: pathlib.Path,
705705
set_home: None, # Needed for child processes (e.g. submodules)
706706
) -> GitSync:
707707
"""Pre-made git clone of remote repo checked out to user's projects dir."""
@@ -736,7 +736,7 @@ def hg_repo(
736736
remote_repos_path: pathlib.Path,
737737
projects_path: pathlib.Path,
738738
hg_remote_repo: pathlib.Path,
739-
set_hgconfig: pathlib.Path,
739+
set_vcs_hgconfig: pathlib.Path,
740740
) -> HgSync:
741741
"""Pre-made hg clone of remote repo checked out to user's projects dir."""
742742
remote_repo_name = unique_repo_name(remote_repos_path=projects_path)
@@ -791,7 +791,7 @@ def add_doctest_fixtures(
791791
tmp_path: pathlib.Path,
792792
set_home: pathlib.Path,
793793
git_commit_envvars: GitCommitEnvVars,
794-
hgconfig: pathlib.Path,
794+
vcs_hgconfig: pathlib.Path,
795795
create_git_remote_repo: CreateRepoFn,
796796
create_svn_remote_repo: CreateRepoFn,
797797
create_hg_remote_repo: CreateRepoFn,
@@ -826,6 +826,6 @@ def add_doctest_fixtures(
826826
create_hg_remote_repo,
827827
remote_repo_post_init=functools.partial(
828828
hg_remote_repo_single_commit_post_init,
829-
env={"HGRCPATH": str(hgconfig)},
829+
env={"HGRCPATH": str(vcs_hgconfig)},
830830
),
831831
)

tests/cmd/test_git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2339,7 +2339,7 @@ def test_reflog_entry_delete(git_repo: GitSync) -> None:
23392339
def submodule_repo(
23402340
tmp_path: pathlib.Path,
23412341
git_commit_envvars: GitCommitEnvVars,
2342-
set_gitconfig: pathlib.Path,
2342+
set_vcs_gitconfig: pathlib.Path,
23432343
) -> git.Git:
23442344
"""Create a git repository to use as a submodule source."""
23452345
# Create a repo to serve as submodule source

tests/sync/test_hg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424

2525
@pytest.fixture(autouse=True)
26-
def set_hgconfig(
27-
set_hgconfig: pathlib.Path,
26+
def set_vcs_hgconfig(
27+
set_vcs_hgconfig: pathlib.Path,
2828
) -> pathlib.Path:
2929
"""Set mercurial configuration."""
30-
return set_hgconfig
30+
return set_vcs_hgconfig
3131

3232

3333
def test_hg_sync(

tests/test_pytest_plugin.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ def test_create_svn_remote_repo(
4646

4747

4848
def test_gitconfig(
49-
gitconfig: pathlib.Path,
50-
set_gitconfig: pathlib.Path,
49+
vcs_gitconfig: pathlib.Path,
50+
set_vcs_gitconfig: pathlib.Path,
5151
vcs_email: str,
5252
) -> None:
53-
"""Test gitconfig fixture."""
53+
"""Test vcs_gitconfig fixture."""
5454
output = run(["git", "config", "--get", "user.email"])
5555
used_config_file_output = run(
5656
[
@@ -61,7 +61,7 @@ def test_gitconfig(
6161
"user.email",
6262
],
6363
)
64-
assert str(gitconfig) in used_config_file_output
64+
assert str(vcs_gitconfig) in used_config_file_output
6565
assert vcs_email in output, "Should use our fixture config and home directory"
6666

6767

@@ -97,7 +97,7 @@ def vcs_email() -> str:
9797
@pytest.fixture(autouse=True)
9898
def setup(
9999
request: pytest.FixtureRequest,
100-
gitconfig: pathlib.Path,
100+
vcs_gitconfig: pathlib.Path,
101101
set_home: pathlib.Path,
102102
) -> None:
103103
pass
@@ -183,12 +183,12 @@ def test_git_bare_repo_sync_and_commit(
183183

184184
@pytest.mark.skipif(not shutil.which("git"), reason="git is not available")
185185
def test_gitconfig_submodule_file_protocol(
186-
gitconfig: pathlib.Path,
186+
vcs_gitconfig: pathlib.Path,
187187
user_path: pathlib.Path,
188188
tmp_path: pathlib.Path,
189189
monkeypatch: pytest.MonkeyPatch,
190190
) -> None:
191-
"""Test that gitconfig fixture allows file:// protocol for git submodule operations.
191+
"""Test that vcs_gitconfig fixture allows file:// protocol for submodule operations.
192192
193193
Git submodule operations spawn child processes that don't inherit local repo config.
194194
The child `git clone` process needs protocol.file.allow=always in global config.
@@ -201,7 +201,7 @@ def test_gitconfig_submodule_file_protocol(
201201
202202
See: https://github.com/vcs-python/libvcs/issues/509
203203
"""
204-
# Isolate git config: use fixture's gitconfig via HOME, block only system config
204+
# Isolate git config: use fixture's vcs_gitconfig via HOME, block only system config
205205
# Note: We don't block GIT_CONFIG_GLOBAL because git falls back to $HOME/.gitconfig
206206
# when GIT_CONFIG_GLOBAL is unset, which is where our fixture puts the config
207207
monkeypatch.setenv("HOME", str(user_path))
@@ -252,7 +252,7 @@ def test_gitconfig_submodule_file_protocol(
252252
# Assert: submodule add should succeed (no "fatal" errors)
253253
assert "fatal" not in result.stderr.lower(), (
254254
f"git submodule add failed with: {result.stderr}\n"
255-
'This indicates gitconfig fixture is missing [protocol "file"] allow = always'
255+
'vcs_gitconfig fixture is missing [protocol "file"] allow = always'
256256
)
257257
assert result.returncode == 0, f"git submodule add failed: {result.stderr}"
258258

@@ -276,13 +276,13 @@ def test_git_repo_fixture_submodule_file_protocol(
276276
protocol.file.allow=always.
277277
278278
The git_repo fixture depends on set_home to ensure child processes
279-
(like git clone spawned by git submodule add) can find the test gitconfig.
279+
(like git clone spawned by git submodule add) can find the test vcs_gitconfig.
280280
281281
See: https://github.com/vcs-python/libvcs/issues/509
282282
"""
283283
from libvcs.pytest_plugin import git_remote_repo_single_commit_post_init
284284

285-
# Verify that HOME is set to user_path where test gitconfig resides
285+
# Verify that HOME is set to user_path where test vcs_gitconfig resides
286286
assert os.environ.get("HOME") == str(user_path), (
287287
f"git_repo fixture should set HOME to user_path.\n"
288288
f"Expected: {user_path}\n"

tests/url/test_hg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717

1818
@pytest.fixture(autouse=True)
19-
def set_hgconfig(
20-
set_hgconfig: pathlib.Path,
19+
def set_vcs_hgconfig(
20+
set_vcs_hgconfig: pathlib.Path,
2121
) -> pathlib.Path:
2222
"""Set mercurial configuration."""
23-
return set_hgconfig
23+
return set_vcs_hgconfig
2424

2525

2626
class HgURLFixture(typing.NamedTuple):

0 commit comments

Comments
 (0)