11"""Tests for libvcs hg repos."""
22import getpass
3- import os
43import pathlib
54import textwrap
65
1413
1514
1615@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"
16+ def hgrc (user_path : pathlib .Path ):
17+ hgrc = user_path / ".hgrc"
3818 hgrc .write_text (
3919 textwrap .dedent (
4020 f"""
41- [paths]
42- default = { hg_remote }
43-
4421 [ui]
4522 username = libvcs tests <libvcs@git-pull.com>
4623 merge = internal:merge
@@ -55,14 +32,14 @@ def hgrc(hg_user_path: pathlib.Path):
5532
5633
5734@pytest .fixture (autouse = True )
58- def hgrc_default (monkeypatch : pytest .MonkeyPatch , hgrc : pathlib .Path ):
59- monkeypatch .chdir ( hgrc . parent )
35+ def hgrc_default (monkeypatch : pytest .MonkeyPatch , user_path : pathlib .Path ):
36+ monkeypatch .setenv ( "HOME" , str ( user_path ) )
6037
6138
6239@pytest .fixture
6340def hg_remote (parentdir ):
6441 """Create a git repo with 1 commit, used as a remote."""
65- name = "dummyrepo "
42+ name = "test_hg_repo "
6643 repo_path = parentdir / name
6744
6845 run (["hg" , "init" , name ], cwd = parentdir )
@@ -95,4 +72,3 @@ def test_repo_mercurial(tmp_path: pathlib.Path, parentdir, hg_remote):
9572 )
9673
9774 assert mercurial_repo .get_revision () == test_repo_revision
98- assert os .path .exists (tmp_path / repo_name )
0 commit comments