Skip to content

Commit 81bdd61

Browse files
committed
tests: Move hg_remote_repo to conftest
1 parent 9f97a84 commit 81bdd61

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

libvcs/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,24 @@ def svn_remote_repo(remote_repos_path: pathlib.Path) -> pathlib.Path:
238238
return remote_repo_path
239239

240240

241+
@pytest.fixture
242+
@skip_if_hg_missing
243+
def hg_remote_repo(projects_path):
244+
"""Pre-made, file-based repo for push and pull."""
245+
name = "test_hg_repo"
246+
repo_path = projects_path / name
247+
248+
run(["hg", "init", name], cwd=projects_path)
249+
250+
testfile_filename = "testfile.test"
251+
252+
run(["touch", testfile_filename], cwd=repo_path)
253+
run(["hg", "add", testfile_filename], cwd=repo_path)
254+
run(["hg", "commit", "-m", "test file for %s" % name], cwd=repo_path)
255+
256+
return repo_path
257+
258+
241259
@pytest.fixture
242260
def git_repo(projects_path: pathlib.Path, git_remote_repo: pathlib.Path):
243261
"""Pre-made git clone of remote repo checked out to user's projects dir."""

tests/states/test_hg.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,6 @@
1010
pytestmark = pytest.mark.skip(reason="hg is not available")
1111

1212

13-
@pytest.fixture
14-
def hg_remote_repo(projects_path):
15-
"""Create a git repo with 1 commit, used as a remote."""
16-
name = "test_hg_repo"
17-
repo_path = projects_path / name
18-
19-
run(["hg", "init", name], cwd=projects_path)
20-
21-
testfile_filename = "testfile.test"
22-
23-
run(["touch", testfile_filename], cwd=repo_path)
24-
run(["hg", "add", testfile_filename], cwd=repo_path)
25-
run(["hg", "commit", "-m", "test file for %s" % name], cwd=repo_path)
26-
27-
return repo_path
28-
29-
3013
def test_repo_mercurial(tmp_path: pathlib.Path, projects_path, hg_remote_repo):
3114
repo_name = "my_mercurial_project"
3215

0 commit comments

Comments
 (0)