Skip to content

Commit a3171db

Browse files
committed
test(git): Update test_repo_git_obtain_initial_commit_repo
1 parent 9f4ceb3 commit a3171db

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

tests/test_git.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,31 @@ def gitconfig_default(monkeypatch: pytest.MonkeyPatch, user_path: pathlib.Path):
4444
monkeypatch.setenv("HOME", str(user_path))
4545

4646

47-
def test_repo_git_obtain_initial_commit_repo(tmp_path: pathlib.Path):
47+
@pytest.mark.parametrize(
48+
# Postpone evaluation of options so fixture variables can interpolate
49+
"constructor,lazy_constructor_options",
50+
[
51+
[
52+
GitRepo,
53+
lambda bare_repo_dir, tmp_path, **kwargs: {
54+
"url": f"file://{bare_repo_dir}",
55+
"repo_dir": tmp_path / "obtaining a bare repo",
56+
},
57+
],
58+
[
59+
create_repo_from_pip_url,
60+
lambda bare_repo_dir, tmp_path, **kwargs: {
61+
"pip_url": f"git+file://{bare_repo_dir}",
62+
"repo_dir": tmp_path / "obtaining a bare repo",
63+
},
64+
],
65+
],
66+
)
67+
def test_repo_git_obtain_initial_commit_repo(
68+
tmp_path: pathlib.Path,
69+
constructor,
70+
lazy_constructor_options,
71+
):
4872
"""initial commit repos return 'initial'.
4973
5074
note: this behaviors differently from git(1)'s use of the word "bare".
@@ -55,13 +79,7 @@ def test_repo_git_obtain_initial_commit_repo(tmp_path: pathlib.Path):
5579
run(["git", "init", repo_name], cwd=tmp_path)
5680

5781
bare_repo_dir = tmp_path / repo_name
58-
59-
git_repo = create_repo_from_pip_url(
60-
**{
61-
"pip_url": f"git+file://{bare_repo_dir}",
62-
"repo_dir": tmp_path / "obtaining a bare repo",
63-
}
64-
)
82+
git_repo: GitRepo = constructor(**lazy_constructor_options(**locals()))
6583

6684
git_repo.obtain()
6785
assert git_repo.get_revision() == "initial"

0 commit comments

Comments
 (0)