Revert check for websocket protocol to use hasattr
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
from unittest.mock import patch
|
||||
|
||||
from inspect import isawaitable
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -31,9 +30,7 @@ def test_app_loop_running(app):
|
||||
assert response.text == "pass"
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.version_info < (3, 7), reason="requires python3.7 or higher"
|
||||
)
|
||||
@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")
|
||||
def test_create_asyncio_server(app):
|
||||
if not uvloop_installed():
|
||||
loop = asyncio.get_event_loop()
|
||||
@@ -43,9 +40,7 @@ def test_create_asyncio_server(app):
|
||||
assert srv.is_serving() is True
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.version_info < (3, 7), reason="requires python3.7 or higher"
|
||||
)
|
||||
@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")
|
||||
def test_asyncio_server_no_start_serving(app):
|
||||
if not uvloop_installed():
|
||||
loop = asyncio.get_event_loop()
|
||||
@@ -58,9 +53,7 @@ def test_asyncio_server_no_start_serving(app):
|
||||
assert srv.is_serving() is False
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.version_info < (3, 7), reason="requires python3.7 or higher"
|
||||
)
|
||||
@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")
|
||||
def test_asyncio_server_start_serving(app):
|
||||
if not uvloop_installed():
|
||||
loop = asyncio.get_event_loop()
|
||||
@@ -170,12 +163,12 @@ def test_app_websocket_parameters(websocket_protocol_mock, app):
|
||||
|
||||
websocket_protocol_call_args = websocket_protocol_mock.call_args
|
||||
ws_kwargs = websocket_protocol_call_args[1]
|
||||
assert ws_kwargs["max_size"] == app.config.WEBSOCKET_MAX_SIZE
|
||||
assert ws_kwargs["max_queue"] == app.config.WEBSOCKET_MAX_QUEUE
|
||||
assert ws_kwargs["read_limit"] == app.config.WEBSOCKET_READ_LIMIT
|
||||
assert ws_kwargs["write_limit"] == app.config.WEBSOCKET_WRITE_LIMIT
|
||||
assert ws_kwargs["ping_timeout"] == app.config.WEBSOCKET_PING_TIMEOUT
|
||||
assert ws_kwargs["ping_interval"] == app.config.WEBSOCKET_PING_INTERVAL
|
||||
assert ws_kwargs["websocket_max_size"] == app.config.WEBSOCKET_MAX_SIZE
|
||||
assert ws_kwargs["websocket_max_queue"] == app.config.WEBSOCKET_MAX_QUEUE
|
||||
assert ws_kwargs["websocket_read_limit"] == app.config.WEBSOCKET_READ_LIMIT
|
||||
assert ws_kwargs["websocket_write_limit"] == app.config.WEBSOCKET_WRITE_LIMIT
|
||||
assert ws_kwargs["websocket_ping_timeout"] == app.config.WEBSOCKET_PING_TIMEOUT
|
||||
assert ws_kwargs["websocket_ping_interval"] == app.config.WEBSOCKET_PING_INTERVAL
|
||||
|
||||
|
||||
def test_handle_request_with_nested_exception(app, monkeypatch):
|
||||
@@ -186,9 +179,7 @@ def test_handle_request_with_nested_exception(app, monkeypatch):
|
||||
def mock_error_handler_response(*args, **kwargs):
|
||||
raise Exception(err_msg)
|
||||
|
||||
monkeypatch.setattr(
|
||||
app.error_handler, "response", mock_error_handler_response
|
||||
)
|
||||
monkeypatch.setattr(app.error_handler, "response", mock_error_handler_response)
|
||||
|
||||
@app.get("/")
|
||||
def handler(request):
|
||||
@@ -207,9 +198,7 @@ def test_handle_request_with_nested_exception_debug(app, monkeypatch):
|
||||
def mock_error_handler_response(*args, **kwargs):
|
||||
raise Exception(err_msg)
|
||||
|
||||
monkeypatch.setattr(
|
||||
app.error_handler, "response", mock_error_handler_response
|
||||
)
|
||||
monkeypatch.setattr(app.error_handler, "response", mock_error_handler_response)
|
||||
|
||||
@app.get("/")
|
||||
def handler(request):
|
||||
@@ -228,9 +217,7 @@ def test_handle_request_with_nested_sanic_exception(app, monkeypatch, caplog):
|
||||
def mock_error_handler_response(*args, **kwargs):
|
||||
raise SanicException("Mock SanicException")
|
||||
|
||||
monkeypatch.setattr(
|
||||
app.error_handler, "response", mock_error_handler_response
|
||||
)
|
||||
monkeypatch.setattr(app.error_handler, "response", mock_error_handler_response)
|
||||
|
||||
@app.get("/")
|
||||
def handler(request):
|
||||
|
||||
Reference in New Issue
Block a user