Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2e98d9b

Browse filesBrowse files
committed
test(sync[hg]) Use test fixture
1 parent 130bca3 commit 2e98d9b
Copy full SHA for 2e98d9b

File tree

Expand file treeCollapse file tree

1 file changed

+18
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-6
lines changed

‎tests/url/test_hg.py

Copy file name to clipboardExpand all lines: tests/url/test_hg.py
+18-6Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""Tests for mercurial URL module."""
22

3+
import pathlib
34
import typing
45

56
import pytest
67

8+
from libvcs.pytest_plugin import CreateRepoPytestFixtureFn
79
from libvcs.sync.hg import HgSync
810
from libvcs.url.base import RuleMap
911
from 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+
2032
TEST_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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.