Create UVLOOP_INSTALLED constant

This commit is contained in:
prryplatypus
2021-10-23 20:39:57 +02:00
parent eb2a264404
commit 2e492f94e6
4 changed files with 22 additions and 29 deletions

View File

@@ -9,6 +9,7 @@ from unittest.mock import Mock, patch
import pytest
from sanic import Sanic
from sanic.compat import UVLOOP_INSTALLED
from sanic.config import Config
from sanic.exceptions import SanicException
from sanic.response import text
@@ -19,15 +20,6 @@ def clear_app_registry():
Sanic._app_registry = {}
def uvloop_installed():
try:
import uvloop # noqa
return True
except ImportError:
return False
def test_app_loop_running(app):
@app.get("/test")
async def handler(request):
@@ -39,7 +31,7 @@ def test_app_loop_running(app):
def test_create_asyncio_server(app):
if not uvloop_installed():
if not UVLOOP_INSTALLED:
loop = asyncio.get_event_loop()
asyncio_srv_coro = app.create_server(return_asyncio_server=True)
assert isawaitable(asyncio_srv_coro)
@@ -48,7 +40,7 @@ def test_create_asyncio_server(app):
def test_asyncio_server_no_start_serving(app):
if not uvloop_installed():
if not UVLOOP_INSTALLED:
loop = asyncio.get_event_loop()
asyncio_srv_coro = app.create_server(
port=43123,
@@ -60,7 +52,7 @@ def test_asyncio_server_no_start_serving(app):
def test_asyncio_server_start_serving(app):
if not uvloop_installed():
if not UVLOOP_INSTALLED:
loop = asyncio.get_event_loop()
asyncio_srv_coro = app.create_server(
port=43124,