forked from csernazs/pytest-httpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_parse_qs.py
More file actions
22 lines (17 loc) · 738 Bytes
/
test_parse_qs.py
File metadata and controls
22 lines (17 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from __future__ import annotations
import urllib.parse
import pytest
parse_qsl_semicolon_cases = [
("&", []),
("&&", []),
("&a=b", [("a", "b")]),
("a=a+b&b=b+c", [("a", "a b"), ("b", "b c")]),
("a=1&a=2", [("a", "1"), ("a", "2")]),
("a=", [("a", "")]),
("a=foo bar&b=bar foo", [("a", "foo bar"), ("b", "bar foo")]),
("a=foo%20bar&b=bar%20foo", [("a", "foo bar"), ("b", "bar foo")]),
("a=%20%21%22%23%24%25%26%27%28%29%2A%2B%2C%2F%3A%3B%3D%3F%40%5B%5D", [("a", " !\"#$%&'()*+,/:;=?@[]")]),
]
@pytest.mark.parametrize(("qs", "expected"), parse_qsl_semicolon_cases)
def test_qsl(qs: str, expected: list[tuple[bytes, bytes]]):
assert urllib.parse.parse_qsl(qs, keep_blank_values=True) == expected