mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
request.args.getlist() returns [] if missing, refs #774
Also added some unit tests for request.args
This commit is contained in:
parent
7ccd55a163
commit
84616a2364
4 changed files with 14 additions and 4 deletions
|
|
@ -448,6 +448,16 @@ async def test_request_post_vars():
|
|||
assert {"foo": "bar", "baz": "1"} == await request.post_vars()
|
||||
|
||||
|
||||
def test_request_args():
|
||||
request = Request.fake("/foo?multi=1&multi=2&single=3")
|
||||
assert "1" == request.args.get("multi")
|
||||
assert "3" == request.args.get("single")
|
||||
assert ["1", "2"] == request.args.getlist("multi")
|
||||
assert [] == request.args.getlist("missing")
|
||||
with pytest.raises(KeyError):
|
||||
request.args["missing"]
|
||||
|
||||
|
||||
def test_call_with_supported_arguments():
|
||||
def foo(a, b):
|
||||
return "{}+{}".format(a, b)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue