source: uri/tests/conftest.py@ 826

Last change on this file since 826 was 230, checked in by wouter, 3 years ago

#91 clone https://pypi.org/project/rfc3986/

File size: 3.2 KB
Line 
1# -*- coding: utf-8 -*-
2import itertools
3import sys
4
5import pytest
6
7SNOWMAN = b"\xe2\x98\x83"
8
9valid_hosts = [
10 "[21DA:00D3:0000:2F3B:02AA:00FF:FE28:9C5A]",
11 "[::1]",
12 "[::1%25lo]", # With ZoneID
13 "[FF02:0:0:0:0:0:0:2%25en01]", # With ZoneID
14 "[FF02:30:0:0:0:0:0:5%25en1]", # With ZoneID
15 "[FF02:30:0:0:0:0:0:5%25%26]", # With ZoneID
16 "[FF02:30:0:0:0:0:0:5%2525]", # With ZoneID
17 "[21DA:D3:0:2F3B:2AA:FF:FE28:9C5A]",
18 "[FE80::2AA:FF:FE9A:4CA2]",
19 "[FF02::2]",
20 "[FFFF::]",
21 "[FF02:3::5]",
22 "[FF02:0:0:0:0:0:0:2]",
23 "[FF02:30:0:0:0:0:0:5]",
24 "127.0.0.1",
25 "www.example.com",
26 "localhost",
27 "http-bin.org",
28 "%2Fvar%2Frun%2Fsocket",
29 "6g9m8V6", # Issue #48
30]
31
32invalid_hosts = [
33 "[FF02::3::5]", # IPv6 can only have one ::
34 "[FADF:01]", # Not properly compacted (missing a :)
35 "[FADF:01%en0]", # Not properly compacted (missing a :), Invalid ZoneID
36 "[FADF::01%]", # Empty Zone ID
37 "localhost:80:80:80", # Too many ports
38 "256.256.256.256", # Invalid IPv4 Address
39 SNOWMAN.decode("utf-8"),
40]
41
42equivalent_hostnames = [
43 "example.com",
44 "eXample.com",
45 "example.COM",
46 "EXAMPLE.com",
47 "ExAMPLE.com",
48 "eXample.COM",
49 "example.COM",
50 "EXAMPLE.COM",
51 "ExAMPLE.COM",
52]
53equivalent_schemes = [
54 "https",
55 "HTTPS",
56 "HttPs",
57 "hTTpS",
58 "HtTpS",
59]
60equivalent_schemes_and_hostnames = list(
61 itertools.product(
62 equivalent_schemes,
63 equivalent_hostnames,
64 )
65)
66
67
68@pytest.fixture(params=valid_hosts)
69def basic_uri(request):
70 return "http://%s" % request.param
71
72
73@pytest.fixture(params=equivalent_schemes_and_hostnames)
74def uri_to_normalize(request):
75 return "%s://%s" % request.param
76
77
78@pytest.fixture(params=valid_hosts)
79def basic_uri_with_port(request):
80 return "ftp://%s:21" % request.param
81
82
83@pytest.fixture(params=valid_hosts)
84def uri_with_port_and_userinfo(request):
85 return "ssh://user:pass@%s:22" % request.param
86
87
88@pytest.fixture(params=valid_hosts)
89def uri_with_port_and_tricky_userinfo(request):
90 return "ssh://%s@%s:22" % ("user%20!=:pass", request.param)
91
92
93@pytest.fixture(params=valid_hosts)
94def basic_uri_with_path(request):
95 return "http://%s/path/to/resource" % request.param
96
97
98@pytest.fixture(params=valid_hosts)
99def uri_with_path_and_query(request):
100 return "http://%s/path/to/resource?key=value" % request.param
101
102
103@pytest.fixture(params=valid_hosts)
104def uri_with_everything(request):
105 return "https://user:pass@%s:443/path/to/resource?key=value#fragment" % (
106 request.param
107 )
108
109
110@pytest.fixture(params=valid_hosts)
111def relative_uri(request):
112 return "//%s" % request.param
113
114
115@pytest.fixture
116def absolute_path_uri():
117 return "/path/to/file"
118
119
120@pytest.fixture(params=invalid_hosts)
121def invalid_uri(request):
122 return "https://%s" % request.param
123
124
125@pytest.fixture(params=valid_hosts)
126def uri_path_with_percent(request):
127 return "https://%s/%% " % request.param
128
129
130@pytest.fixture(params=valid_hosts)
131def uri_query_with_percent(request):
132 return "https://%s?a=%%" % request.param
133
134
135@pytest.fixture(params=valid_hosts)
136def uri_fragment_with_percent(request):
137 return "https://%s#perc%%ent" % request.param
138
139
140sys.path.insert(0, ".")
Note: See TracBrowser for help on using the repository browser.