Skip to content

Commit

Permalink
squash
Browse files Browse the repository at this point in the history
  • Loading branch information
ahopkins committed Jul 14, 2020
1 parent 23e1b5e commit eddb5ba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sanic/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from sanic.log import logger
from sanic.response import text


ASGI_HOST = "mockserver"
HOST = "127.0.0.1"
PORT = None
Expand All @@ -20,7 +21,14 @@ def __init__(self, app, port=PORT, host=HOST):
self.app = app
self.port = port
self.host = host
self.app.test_mode = True

@app.listener("after_server_start")
def _start_test_mode(sanic, loop):
sanic.test_mode = True

@app.listener("before_server_end")
def _end_test_mode(sanic, loop):
sanic.test_mode = False

def get_new_session(self):
return httpx.AsyncClient(verify=False)
Expand Down

0 comments on commit eddb5ba

Please sign in to comment.