remove testmanager

This commit is contained in:
Adam Hopkins 2021-01-19 16:34:52 +02:00
parent 933d005e5d
commit 1f0f4ef5d5
2 changed files with 17 additions and 12 deletions

View File

@ -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

View File

@ -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