Skip to content

Commit 2b5a63e

Browse files
committed
test(hg): Add default config
1 parent cf4c215 commit 2b5a63e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/test_hg.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Tests for libvcs hg repos."""
2+
import getpass
23
import os
34
import pathlib
5+
import textwrap
46

57
import pytest
68

@@ -11,6 +13,52 @@
1113
pytestmark = pytest.mark.skip(reason="hg is not available")
1214

1315

16+
@pytest.fixture(autouse=True, scope="session")
17+
def home_path(tmp_path_factory: pytest.TempPathFactory):
18+
return tmp_path_factory.mktemp("home")
19+
20+
21+
@pytest.fixture(autouse=True, scope="session")
22+
def user_path(home_path: pathlib.Path):
23+
p = home_path / getpass.getuser()
24+
p.mkdir()
25+
return p
26+
27+
28+
@pytest.fixture(autouse=True, scope="session")
29+
def hg_user_path(user_path: pathlib.Path):
30+
hg_config = user_path / ".hg"
31+
hg_config.mkdir()
32+
return hg_config
33+
34+
35+
@pytest.fixture(autouse=True, scope="session")
36+
def hgrc(hg_user_path: pathlib.Path):
37+
hgrc = hg_user_path / "hgrc"
38+
hgrc.write_text(
39+
textwrap.dedent(
40+
f"""
41+
[paths]
42+
default = {hg_remote}
43+
44+
[ui]
45+
username = libvcs tests <libvcs@git-pull.com>
46+
merge = internal:merge
47+
48+
[trusted]
49+
users = {getpass.getuser()}
50+
"""
51+
),
52+
encoding="utf-8",
53+
)
54+
return hgrc
55+
56+
57+
@pytest.fixture(autouse=True)
58+
def hgrc_default(monkeypatch: pytest.MonkeyPatch, hgrc: pathlib.Path):
59+
monkeypatch.chdir(hgrc.parent)
60+
61+
1462
@pytest.fixture
1563
def hg_remote(parentdir):
1664
"""Create a git repo with 1 commit, used as a remote."""

0 commit comments

Comments
 (0)