fix uvloop check

This commit is contained in:
Denis Makogon 2019-01-15 17:45:47 +02:00
parent f8f0241c27
commit b36bd21813

View File

@ -27,28 +27,30 @@ def test_app_loop_running(app):
assert response.text == "pass" assert response.text == "pass"
@pytest.mark.skipif(sys.version_info < (3, 7) and uvloop_installed(), @pytest.mark.skipif(sys.version_info < (3, 7),
reason="requires python3.7 or higher") reason="requires python3.7 or higher")
def test_create_asyncio_server(app): def test_create_asyncio_server(app):
loop = asyncio.get_event_loop() if not uvloop_installed():
asyncio_srv_coro = app.create_server( loop = asyncio.get_event_loop()
return_asyncio_server=True) asyncio_srv_coro = app.create_server(
assert isawaitable(asyncio_srv_coro) return_asyncio_server=True)
srv = loop.run_until_complete(asyncio_srv_coro) assert isawaitable(asyncio_srv_coro)
assert srv.is_serving() is True srv = loop.run_until_complete(asyncio_srv_coro)
assert srv.is_serving() is True
@pytest.mark.skipif(sys.version_info < (3, 7) and uvloop_installed(), @pytest.mark.skipif(sys.version_info < (3, 7),
reason="requires python3.7 or higher") reason="requires python3.7 or higher")
def test_asyncio_server_start_serving(app): def test_asyncio_server_start_serving(app):
loop = asyncio.get_event_loop() if not uvloop_installed():
asyncio_srv_coro = app.create_server( loop = asyncio.get_event_loop()
return_asyncio_server=True, asyncio_srv_coro = app.create_server(
asyncio_server_kwargs=dict( return_asyncio_server=True,
start_serving=False asyncio_server_kwargs=dict(
)) start_serving=False
srv = loop.run_until_complete(asyncio_srv_coro) ))
assert srv.is_serving() is False srv = loop.run_until_complete(asyncio_srv_coro)
assert srv.is_serving() is False
def test_app_loop_not_running(app): def test_app_loop_not_running(app):