1
1
"""Tests for mercurial URL module."""
2
2
3
+ import pathlib
3
4
import typing
4
5
5
6
import pytest
6
7
8
+ from libvcs .pytest_plugin import CreateRepoPytestFixtureFn
7
9
from libvcs .sync .hg import HgSync
8
10
from libvcs .url .base import RuleMap
9
11
from libvcs .url .hg import DEFAULT_RULES , PIP_DEFAULT_RULES , HgBaseURL , HgURL
@@ -17,6 +19,16 @@ class HgURLFixture(typing.NamedTuple):
17
19
hg_url : HgURL
18
20
19
21
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
+
20
32
TEST_FIXTURES : list [HgURLFixture ] = [
21
33
HgURLFixture (
22
34
url = "https://bitbucket.com/vcs-python/libvcs" ,
@@ -52,8 +64,8 @@ def test_hg_url(
52
64
hg_repo : HgSync ,
53
65
) -> None :
54
66
"""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 )
57
69
58
70
assert HgURL .is_valid (url ) == is_valid , f"{ url } compatibility should be { is_valid } "
59
71
assert HgURL (url ) == hg_url
@@ -121,10 +133,10 @@ class HgURLWithPip(HgURL):
121
133
_rule_map = {m .label : m for m in [* DEFAULT_RULES , * PIP_DEFAULT_RULES ]},
122
134
)
123
135
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 )
126
138
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 )
128
140
129
141
assert (
130
142
HgBaseURL .is_valid (url ) != is_valid
@@ -186,6 +198,6 @@ def test_hg_to_url(
186
198
hg_repo : HgSync ,
187
199
) -> None :
188
200
"""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 )
190
202
191
203
assert hg_url .to_url () == expected
0 commit comments