MCPcopy Index your code
hub / github.com/python-websockets/websockets / test_parse_extension

Method test_parse_extension

tests/test_headers.py:72–112  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

70 parse_upgrade(header)
71
72 def test_parse_extension(self):
73 for header, parsed in [
74 # Synthetic examples
75 ("foo", [("foo", [])]),
76 ("foo, bar", [("foo", []), ("bar", [])]),
77 (
78 'foo; name; token=token; quoted-string="quoted-string", '
79 "bar; quux; quuux",
80 [
81 (
82 "foo",
83 [
84 ("name", None),
85 ("token", "token"),
86 ("quoted-string", "quoted-string"),
87 ],
88 ),
89 ("bar", [("quux", None), ("quuux", None)]),
90 ],
91 ),
92 # Pathological example
93 (
94 ",\t, , ,foo ;bar = 42,, baz,,",
95 [("foo", [("bar", "42")]), ("baz", [])],
96 ),
97 # Realistic use cases for permessage-deflate
98 ("permessage-deflate", [("permessage-deflate", [])]),
99 (
100 "permessage-deflate; client_max_window_bits",
101 [("permessage-deflate", [("client_max_window_bits", None)])],
102 ),
103 (
104 "permessage-deflate; server_max_window_bits=10",
105 [("permessage-deflate", [("server_max_window_bits", "10")])],
106 ),
107 ]:
108 with self.subTest(header=header):
109 self.assertEqual(parse_extension(header), parsed)
110 # Also ensure that build_extension round-trips cleanly.
111 unparsed = build_extension(parsed)
112 self.assertEqual(parse_extension(unparsed), parsed)
113
114 def test_parse_extension_invalid_header_format(self):
115 for header in [

Callers

nothing calls this directly

Calls 2

parse_extensionFunction · 0.85
build_extensionFunction · 0.85

Tested by

no test coverage detected