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

Function test_negative

tests/test_routing.py:359–379  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

357
358
359def test_negative():
360 map = r.Map(
361 [
362 r.Rule("/foos/<int(signed=True):page>", endpoint="foos"),
363 r.Rule("/bars/<float(signed=True):page>", endpoint="bars"),
364 r.Rule("/foo/<int:page>", endpoint="foo"),
365 r.Rule("/bar/<float:page>", endpoint="bar"),
366 ]
367 )
368 adapter = map.bind("example.org", "/")
369
370 assert adapter.match("/foos/-2") == ("foos", {"page": -2})
371 assert adapter.match("/foos/-50") == ("foos", {"page": -50})
372 assert adapter.match("/bars/-2.0") == ("bars", {"page": -2.0})
373 assert adapter.match("/bars/-0.185") == ("bars", {"page": -0.185})
374
375 # Make sure signed values are rejected in unsigned mode
376 pytest.raises(NotFound, lambda: adapter.match("/foo/-2"))
377 pytest.raises(NotFound, lambda: adapter.match("/foo/-50"))
378 pytest.raises(NotFound, lambda: adapter.match("/bar/-0.185"))
379 pytest.raises(NotFound, lambda: adapter.match("/bar/-2.0"))
380
381
382def test_greedy():

Callers

nothing calls this directly

Calls 2

bindMethod · 0.95
matchMethod · 0.45

Tested by

no test coverage detected