mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
repr() method for Request, refs #1519
This commit is contained in:
parent
3025505515
commit
ff0dd4da38
2 changed files with 11 additions and 0 deletions
|
|
@ -37,6 +37,9 @@ class Request:
|
|||
self.scope = scope
|
||||
self.receive = receive
|
||||
|
||||
def __repr__(self):
|
||||
return '<asgi.Request method="{}" url="{}">'.format(self.method, self.url)
|
||||
|
||||
@property
|
||||
def method(self):
|
||||
return self.scope["method"]
|
||||
|
|
|
|||
|
|
@ -75,6 +75,14 @@ def test_request_args():
|
|||
request.args["missing"]
|
||||
|
||||
|
||||
def test_request_repr():
|
||||
request = Request.fake("/foo?multi=1&multi=2&single=3")
|
||||
assert (
|
||||
repr(request)
|
||||
== '<asgi.Request method="GET" url="http://localhost/foo?multi=1&multi=2&single=3">'
|
||||
)
|
||||
|
||||
|
||||
def test_request_url_vars():
|
||||
scope = {
|
||||
"http_version": "1.1",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue