MCPcopy
hub / github.com/pallets/werkzeug / test_merge_slashes_match

Function test_merge_slashes_match

tests/test_routing.py:91–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89
90
91def test_merge_slashes_match():
92 url_map = r.Map(
93 [
94 r.Rule("/no/tail", endpoint="no_tail"),
95 r.Rule("/yes/tail/", endpoint="yes_tail"),
96 r.Rule("/with/<path:path>", endpoint="with_path"),
97 r.Rule("/no//merge", endpoint="no_merge", merge_slashes=False),
98 r.Rule("/no/merging", endpoint="no_merging", merge_slashes=False),
99 ]
100 )
101 adapter = url_map.bind("localhost", "/")
102
103 with pytest.raises(r.RequestRedirect) as excinfo:
104 adapter.match("/no//tail")
105
106 assert excinfo.value.new_url.endswith("/no/tail")
107
108 with pytest.raises(r.RequestRedirect) as excinfo:
109 adapter.match("/yes//tail")
110
111 assert excinfo.value.new_url.endswith("/yes/tail/")
112
113 with pytest.raises(r.RequestRedirect) as excinfo:
114 adapter.match("/yes/tail//")
115
116 assert excinfo.value.new_url.endswith("/yes/tail/")
117
118 with pytest.raises(r.RequestRedirect):
119 adapter.match("//yes///tail////")
120
121 assert adapter.match("/no/tail")[0] == "no_tail"
122 assert adapter.match("/yes/tail/")[0] == "yes_tail"
123
124 _, rv = adapter.match("/with/http://example.com/")
125 assert rv["path"] == "http://example.com/"
126 _, rv = adapter.match("/with/x//y")
127 assert rv["path"] == "x//y"
128
129 assert adapter.match("/no//merge")[0] == "no_merge"
130
131 assert adapter.match("/no/merging")[0] == "no_merging"
132 pytest.raises(NotFound, lambda: adapter.match("/no//merging"))
133
134
135@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 2

bindMethod · 0.95
matchMethod · 0.45

Tested by

no test coverage detected