Resolve tests

This commit is contained in:
Adam Hopkins 2021-01-25 02:14:48 +02:00
parent 1f0f4ef5d5
commit 76ef641743
7 changed files with 17 additions and 10 deletions

View File

@ -19,6 +19,11 @@ if sys.platform in ["win32", "cygwin"]:
collect_ignore = ["test_worker.py"]
@pytest.fixture
def caplog(caplog):
yield caplog
async def _handler(request):
"""
Dummy placeholder method used for route resolver when creating a new

View File

@ -41,8 +41,7 @@ def transport(message_stack, receive, send):
@pytest.fixture
# @pytest.mark.asyncio
def protocol(transport, loop):
def protocol(transport):
return transport.get_protocol()

View File

@ -35,6 +35,7 @@ def test_log(app):
logging.basicConfig(
format=logging_format, level=logging.DEBUG, stream=log_stream
)
logging.getLogger("asyncio").setLevel(logging.WARNING)
log = logging.getLogger()
rand_string = str(uuid.uuid4())

View File

@ -480,21 +480,21 @@ def test_websocket_route_with_subprotocols(app):
results.append(ws.subprotocol)
assert ws.subprotocol is not None
request, response = app.test_client.websocket("/ws", subprotocols=["bar"])
_, response = SanicTestClient(app).websocket("/ws", subprotocols=["bar"])
assert response.opened is True
assert results == ["bar"]
request, response = app.test_client.websocket(
_, response = SanicTestClient(app).websocket(
"/ws", subprotocols=["bar", "foo"]
)
assert response.opened is True
assert results == ["bar", "bar"]
request, response = app.test_client.websocket("/ws", subprotocols=["baz"])
_, response = SanicTestClient(app).websocket("/ws", subprotocols=["baz"])
assert response.opened is True
assert results == ["bar", "bar", None]
request, response = app.test_client.websocket("/ws")
_, response = SanicTestClient(app).websocket("/ws")
assert response.opened is True
assert results == ["bar", "bar", None, None]

View File

@ -1,5 +1,7 @@
import asyncio
from sanic_testing.testing import SanicTestClient
from sanic.blueprints import Blueprint
@ -48,14 +50,14 @@ def test_websocket_bp_route_name(app):
uri = app.url_for("test_bp.test_route")
assert uri == "/bp/route"
request, response = app.test_client.websocket(uri)
request, response = SanicTestClient(app).websocket(uri)
assert response.opened is True
assert event.is_set()
event.clear()
uri = app.url_for("test_bp.test_route2")
assert uri == "/bp/route2"
request, response = app.test_client.websocket(uri)
request, response = SanicTestClient(app).websocket(uri)
assert response.opened is True
assert event.is_set()

View File

@ -7,7 +7,7 @@ setenv =
{py36,py37,py38,py39,pyNightly}-no-ext: SANIC_NO_UJSON=1
{py36,py37,py38,py39,pyNightly}-no-ext: SANIC_NO_UVLOOP=1
deps =
sanic-testing
sanic-testing==0.1.2
coverage==5.3
pytest==5.2.1
pytest-cov