1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
import pytest
from rdflib.plugins.shared.jsonld.util import norm_url
@pytest.mark.parametrize(
["base", "url", "expected_result"],
[
pytest.param(
"git+ssh://example.com:1231/some/thing/",
"a",
"git+ssh://example.com:1231/some/thing/a",
marks=pytest.mark.xfail(
reason="""
URL normalizes to the wrong thing.
AssertionError: assert 'git+ssh://example.com:1231/some/thing/a' == 'a'
""",
raises=AssertionError,
),
),
("http://example.org/", "/one", "http://example.org/one"),
("http://example.org/", "/one#", "http://example.org/one#"),
("http://example.org/one", "two", "http://example.org/two"),
("http://example.org/one/", "two", "http://example.org/one/two"),
(
"http://example.org/",
"http://example.net/one",
"http://example.net/one",
),
(
"",
"1 2 3",
"1 2 3",
),
(
"http://example.org/",
"http://example.org//one",
"http://example.org//one",
),
("", "http://example.org", "http://example.org"),
("", "http://example.org/", "http://example.org/"),
("", "mailto:name@example.com", "mailto:name@example.com"),
(
"http://example.org/",
"mailto:name@example.com",
"mailto:name@example.com",
),
("http://example.org/a/b/c", "../../z", "http://example.org/z"),
("http://example.org/a/b/c", "../", "http://example.org/a/"),
(
"",
"git+ssh://example.com:1231/some/thing",
"git+ssh://example.com:1231/some/thing",
),
(
"git+ssh://example.com:1231/some/thing",
"",
"git+ssh://example.com:1231/some/thing",
),
(
"http://example.com/RDFLib/rdflib",
"http://example.org",
"http://example.org",
),
(
"http://example.com/RDFLib/rdflib",
"http://example.org/",
"http://example.org/",
),
],
)
def test_norm_url_xfail(base: str, url: str, expected_result: str) -> None:
assert expected_result == norm_url(base, url)
|