Skip to content

Commit dd3174e

Browse files
committed
Move temp_repo fixture to vcs/git
1 parent a19073a commit dd3174e

File tree

2 files changed

+58
-48
lines changed

2 files changed

+58
-48
lines changed

tests/conftest.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from typing import Any
1313
from typing import Iterator
1414

15-
import dulwich.repo
1615
import httpretty
1716
import keyring
1817
import pytest
@@ -45,7 +44,6 @@
4544
from tests.helpers import mock_clone
4645
from tests.helpers import switch_working_directory
4746
from tests.helpers import with_working_directory
48-
from tests.vcs.git.git_fixture import TempRepoFixture
4947

5048

5149
if TYPE_CHECKING:
@@ -584,49 +582,3 @@ def project_context(project: str | Path, in_place: bool = False) -> Iterator[Pat
584582
yield path
585583

586584
return project_context
587-
588-
589-
@pytest.fixture()
590-
def temp_repo(tmp_path: Path) -> TempRepoFixture:
591-
"""Temporary repository with 2 commits"""
592-
repo = dulwich.repo.Repo.init(str(tmp_path))
593-
594-
# init commit
595-
(tmp_path / "foo").write_text("foo", encoding="utf-8")
596-
repo.stage(["foo"])
597-
598-
init_commit = repo.do_commit(
599-
committer=b"User <user@example.com>",
600-
author=b"User <user@example.com>",
601-
message=b"init",
602-
no_verify=True,
603-
)
604-
605-
# one commit which is not "head"
606-
(tmp_path / "bar").write_text("bar", encoding="utf-8")
607-
repo.stage(["bar"])
608-
middle_commit = repo.do_commit(
609-
committer=b"User <user@example.com>",
610-
author=b"User <user@example.com>",
611-
message=b"extra",
612-
no_verify=True,
613-
)
614-
615-
# extra commit
616-
(tmp_path / "third").write_text("third file", encoding="utf-8")
617-
repo.stage(["third"])
618-
619-
head_commit = repo.do_commit(
620-
committer=b"User <user@example.com>",
621-
author=b"User <user@example.com>",
622-
message=b"extra",
623-
no_verify=True,
624-
)
625-
626-
return TempRepoFixture(
627-
path=tmp_path,
628-
repo=repo,
629-
init_commit=init_commit.decode(),
630-
middle_commit=middle_commit.decode(),
631-
head_commit=head_commit.decode(),
632-
)

tests/vcs/git/conftest.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING
4+
5+
import dulwich.repo
6+
import pytest
7+
8+
from tests.vcs.git.git_fixture import TempRepoFixture
9+
10+
11+
if TYPE_CHECKING:
12+
from pathlib import Path
13+
14+
15+
@pytest.fixture()
16+
def temp_repo(tmp_path: Path) -> TempRepoFixture:
17+
"""Temporary repository with 2 commits"""
18+
repo = dulwich.repo.Repo.init(str(tmp_path))
19+
20+
# init commit
21+
(tmp_path / "foo").write_text("foo", encoding="utf-8")
22+
repo.stage(["foo"])
23+
24+
init_commit = repo.do_commit(
25+
committer=b"User <user@example.com>",
26+
author=b"User <user@example.com>",
27+
message=b"init",
28+
no_verify=True,
29+
)
30+
31+
# one commit which is not "head"
32+
(tmp_path / "bar").write_text("bar", encoding="utf-8")
33+
repo.stage(["bar"])
34+
middle_commit = repo.do_commit(
35+
committer=b"User <user@example.com>",
36+
author=b"User <user@example.com>",
37+
message=b"extra",
38+
no_verify=True,
39+
)
40+
41+
# extra commit
42+
(tmp_path / "third").write_text("third file", encoding="utf-8")
43+
repo.stage(["third"])
44+
45+
head_commit = repo.do_commit(
46+
committer=b"User <user@example.com>",
47+
author=b"User <user@example.com>",
48+
message=b"extra",
49+
no_verify=True,
50+
)
51+
52+
return TempRepoFixture(
53+
path=tmp_path,
54+
repo=repo,
55+
init_commit=init_commit.decode(),
56+
middle_commit=middle_commit.decode(),
57+
head_commit=head_commit.decode(),
58+
)

0 commit comments

Comments
 (0)