Skip to content

Commit cb8747e

Browse files
committed
test_pytest_plugin(test): Remove xfail now that git_repo has set_home
why: The git_repo fixture now has set_home dependency, so the test passes what: - Remove @pytest.mark.xfail from test_git_repo_fixture_submodule_file_protocol - Update docstring to document the fix
1 parent c405217 commit cb8747e

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

tests/test_pytest_plugin.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,11 @@ def test_gitconfig_submodule_file_protocol(
262262

263263

264264
@pytest.mark.skipif(not shutil.which("git"), reason="git is not available")
265-
@pytest.mark.xfail(reason="git_repo fixture missing set_home dependency")
266265
def test_git_repo_fixture_submodule_file_protocol(
267266
git_repo: GitSync,
268267
create_git_remote_repo: CreateRepoPytestFixtureFn,
269268
git_commit_envvars: dict[str, str],
270269
user_path: pathlib.Path,
271-
tmp_path: pathlib.Path,
272270
monkeypatch: pytest.MonkeyPatch,
273271
) -> None:
274272
"""Test that git_repo fixture allows file:// protocol for submodule operations.
@@ -277,20 +275,23 @@ def test_git_repo_fixture_submodule_file_protocol(
277275
processes (spawned by git submodule add) can find $HOME/.gitconfig with
278276
protocol.file.allow=always.
279277
280-
Without set_home in git_repo, this test fails with:
281-
fatal: transport 'file' not allowed
278+
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.
282280
283281
See: https://github.com/vcs-python/libvcs/issues/509
284282
"""
285283
from libvcs.pytest_plugin import git_remote_repo_single_commit_post_init
286284

287-
# Isolate git config: set HOME to a clean path without protocol.file.allow
288-
# This simulates what happens on a fresh build system like Arch Linux packaging
289-
clean_home = tmp_path / "clean_home"
290-
clean_home.mkdir()
291-
monkeypatch.setenv("HOME", str(clean_home))
285+
# Verify that HOME is set to user_path where test gitconfig resides
286+
assert os.environ.get("HOME") == str(user_path), (
287+
f"git_repo fixture should set HOME to user_path.\n"
288+
f"Expected: {user_path}\n"
289+
f"Actual: {os.environ.get('HOME')}\n"
290+
"git_repo fixture is missing set_home dependency"
291+
)
292+
293+
# Block system config to prevent interference
292294
monkeypatch.setenv("GIT_CONFIG_SYSTEM", os.devnull)
293-
monkeypatch.delenv("GIT_CONFIG_GLOBAL", raising=False)
294295

295296
# Create a repo to use as submodule source (with a commit so it can be cloned)
296297
submodule_source = create_git_remote_repo()
@@ -299,7 +300,7 @@ def test_git_repo_fixture_submodule_file_protocol(
299300
env=git_commit_envvars,
300301
)
301302

302-
# Add submodule - this spawns child git clone that needs HOME set
303+
# Add submodule - this spawns child git clone that needs HOME set correctly
303304
# NOTE: We do NOT use the local config workaround here
304305
result = git_repo.cmd.submodules.add(
305306
repository=f"file://{submodule_source}",

0 commit comments

Comments
 (0)