mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Implemented custom 404/500, more tests pass #272
This commit is contained in:
parent
b53a75c460
commit
55fc993667
3 changed files with 102 additions and 3 deletions
|
|
@ -24,6 +24,10 @@ class TestResponse:
|
|||
def json(self):
|
||||
return json.loads(self.body)
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
return self.body.decode("utf8")
|
||||
|
||||
|
||||
class TestClient:
|
||||
def __init__(self, asgi_app):
|
||||
|
|
@ -49,7 +53,9 @@ class TestClient:
|
|||
# First message back should be response.start with headers and status
|
||||
start = await instance.receive_output(2)
|
||||
assert start["type"] == "http.response.start"
|
||||
headers = start["headers"]
|
||||
headers = dict(
|
||||
[(k.decode("utf8"), v.decode("utf8")) for k, v in start["headers"]]
|
||||
)
|
||||
status = start["status"]
|
||||
# Now loop until we run out of response.body
|
||||
body = b""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue