..
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 | from edify.library import url
urls = [
"example.com",
"www.example.com",
"www.example.com/path/to/file",
"http://www.example.com",
"http://example.com",
"http://www.example.com/path/to/page",
"https://example.com",
"https://www.example.com/",
"https://www.example.com/path/to/page",
"//example.com",
]
def test_all_protocols():
match_list = ["proto", "no_proto"]
expected = [True] * 9 + [False]
for uri, expectation in zip(urls, expected):
assert url(uri, match=match_list) == expectation
def test_proto_only():
match_list = ["proto"]
expected = [False] * 3 + [True] * 6 + [False]
for uri, expectation in zip(urls, expected):
print(uri, expectation)
assert url(uri, match=match_list) == expectation
def test_no_proto_only():
match_list = ["no_proto"]
expected = [True] * 3 + [False] * 7
for uri, expectation in zip(urls, expected):
assert url(uri, match=match_list) == expectation
def test_invalid_protocol():
match_list = ["invalid"]
for uri in urls:
try:
url(uri, match=match_list)
except ValueError:
assert True
def test_invalid_match_type():
match_list = "invalid"
for uri in urls:
try:
url(uri, match=match_list)
except TypeError:
assert True
def test_empty_match_list():
match_list = []
for uri in urls:
try:
url(uri, match=match_list)
except ValueError:
assert True
|
|