From 1f0f4ef5d56fd1e0d6913daf1adedea3c82d9c26 Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Tue, 19 Jan 2021 16:34:52 +0200 Subject: [PATCH] remove testmanager --- sanic/app.py | 23 ++++++++++++----------- tests/conftest.py | 6 +++++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/sanic/app.py b/sanic/app.py index 1c1d1282..f8b02ef8 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -86,7 +86,8 @@ class Sanic: self.websocket_tasks: Set[Future] = set() self.named_request_middleware: Dict[str, MiddlewareType] = {} self.named_response_middleware: Dict[str, MiddlewareType] = {} - self._test_manager = None + self._test_client = None + self._asgi_client = None # Register alternative method names self.go_fast = self.run @@ -1032,21 +1033,21 @@ class Sanic: @property def test_client(self): - if self._test_manager: - return self._test_manager.test_client - from sanic_testing import TestManager + if self._test_client: + return self._test_client + from sanic_testing.testing import SanicTestClient - manager = TestManager(self) - return manager.test_client + self._test_client = SanicTestClient(self) + return self._test_client @property def asgi_client(self): - if self._test_manager: - return self._test_manager.asgi_client - from sanic_testing import TestManager + if self._asgi_client: + return self._asgi_client + from sanic_testing.testing import SanicASGITestClient - manager = TestManager(self) - return manager.asgi_client + self._asgi_client = SanicASGITestClient(self) + return self._asgi_client # -------------------------------------------------------------------- # # Execution diff --git a/tests/conftest.py b/tests/conftest.py index cad8d754..46dddf01 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,6 +6,8 @@ import uuid import pytest +from sanic_testing import TestManager + from sanic import Sanic from sanic.router import RouteExists, Router @@ -129,4 +131,6 @@ def url_param_generator(): @pytest.fixture(scope="function") def app(request): - return Sanic(request.node.name) + app = Sanic(request.node.name) + # TestManager(app) + return app