Resolve tests
This commit is contained in:
parent
1f0f4ef5d5
commit
76ef641743
|
@ -1450,7 +1450,7 @@ class Sanic:
|
|||
pass
|
||||
finally:
|
||||
self.websocket_tasks.remove(fut)
|
||||
await ws.close()
|
||||
await ws.close()
|
||||
|
||||
# -------------------------------------------------------------------- #
|
||||
# ASGI
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user