Test client wrapper removing need for gather_request - refs #272

As part of decoupling from Sanic, this will make it easier to run tests
against ASGI instead.
This commit is contained in:
Simon Willison 2018-06-04 20:53:12 -07:00
commit 864328e074
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
4 changed files with 114 additions and 147 deletions

View file

@ -10,6 +10,18 @@ import tempfile
import time
class TestClient:
def __init__(self, sanic_test_client):
self.sanic_test_client = sanic_test_client
def get(self, path, allow_redirects=True):
return self.sanic_test_client.get(
path,
allow_redirects=allow_redirects,
gather_request=False
)
@pytest.fixture(scope='session')
def app_client(sql_time_limit_ms=None, max_returned_rows=None, config=None):
with tempfile.TemporaryDirectory() as tmpdir:
@ -36,7 +48,7 @@ def app_client(sql_time_limit_ms=None, max_returned_rows=None, config=None):
ds.sqlite_functions.append(
('sleep', 1, lambda n: time.sleep(float(n))),
)
client = ds.app().test_client
client = TestClient(ds.app().test_client)
client.ds = ds
yield client