11"""Tests for mercurial URL module."""
22
3+ import pathlib
34import typing
45
56import pytest
67
8+ from libvcs .pytest_plugin import CreateRepoPytestFixtureFn
79from libvcs .sync .hg import HgSync
810from libvcs .url .base import RuleMap
911from libvcs .url .hg import DEFAULT_RULES , PIP_DEFAULT_RULES , HgBaseURL , HgURL
@@ -17,6 +19,16 @@ class HgURLFixture(typing.NamedTuple):
1719 hg_url : HgURL
1820
1921
22+ @pytest .fixture
23+ def hg_repo (
24+ set_home : pathlib .Path ,
25+ hgconfig : pathlib .Path ,
26+ create_hg_remote_repo : CreateRepoPytestFixtureFn ,
27+ ) -> pathlib .Path :
28+ """Create a remote hg repository."""
29+ return create_hg_remote_repo ()
30+
31+
2032TEST_FIXTURES : list [HgURLFixture ] = [
2133 HgURLFixture (
2234 url = "https://bitbucket.com/vcs-python/libvcs" ,
@@ -52,8 +64,8 @@ def test_hg_url(
5264 hg_repo : HgSync ,
5365) -> None :
5466 """Test HgURL."""
55- url = url .format (local_repo = hg_repo . path )
56- hg_url .url = hg_url .url .format (local_repo = hg_repo . path )
67+ url = url .format (local_repo = hg_repo )
68+ hg_url .url = hg_url .url .format (local_repo = hg_repo )
5769
5870 assert HgURL .is_valid (url ) == is_valid , f"{ url } compatibility should be { is_valid } "
5971 assert HgURL (url ) == hg_url
@@ -121,10 +133,10 @@ class HgURLWithPip(HgURL):
121133 _rule_map = {m .label : m for m in [* DEFAULT_RULES , * PIP_DEFAULT_RULES ]},
122134 )
123135
124- hg_url_kwargs ["url" ] = hg_url_kwargs ["url" ].format (local_repo = hg_repo . path )
125- url = url .format (local_repo = hg_repo . path )
136+ hg_url_kwargs ["url" ] = hg_url_kwargs ["url" ].format (local_repo = hg_repo )
137+ url = url .format (local_repo = hg_repo )
126138 hg_url = HgURLWithPip (** hg_url_kwargs )
127- hg_url .url = hg_url .url .format (local_repo = hg_repo . path )
139+ hg_url .url = hg_url .url .format (local_repo = hg_repo )
128140
129141 assert (
130142 HgBaseURL .is_valid (url ) != is_valid
@@ -186,6 +198,6 @@ def test_hg_to_url(
186198 hg_repo : HgSync ,
187199) -> None :
188200 """Test HgURL.to_url()."""
189- hg_url .url = hg_url .url .format (local_repo = hg_repo . path )
201+ hg_url .url = hg_url .url .format (local_repo = hg_repo )
190202
191203 assert hg_url .to_url () == expected
0 commit comments