From 56e94d42c660f25e5740e91c4abe3ac730760d97 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 23 Oct 2019 13:44:16 +0300 Subject: [PATCH 1/4] Test on Python 3.8, drop 3.3 and 3.4 --- .travis.yml | 16 +++++++++---- pytest_asyncio/plugin.py | 2 +- test_requirements.txt | 2 +- tests/test_simple.py | 51 ++++++++++++++++++++++------------------ tox.ini | 8 ++++--- 5 files changed, 46 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8ba5b681..b6ae9c54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,20 @@ language: python -python: 3.3 -env: - - TOX_ENV=py33 - - TOX_ENV=py34 +matrix: + include: + - python: 3.5 + env: TOXENV=py35 + - python: 3.6 + env: TOXENV=py36 + - python: 3.7 + env: TOXENV=py37 + - python: 3.8 + env: TOXENV=py38 install: - pip install tox -script: tox -e $TOX_ENV +script: tox after_success: - pip install coveralls && cd tests && coveralls diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index d558132e..407b5ef6 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -40,7 +40,7 @@ def pytest_pyfunc_call(pyfuncitem): testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames} event_loop.run_until_complete( - asyncio.async(pyfuncitem.obj(**testargs))) + asyncio.ensure_future(pyfuncitem.obj(**testargs))) return True diff --git a/test_requirements.txt b/test_requirements.txt index 64d96800..4010acd5 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1 +1 @@ -coverage==3.7.1 +coverage==4.5.4 diff --git a/tests/test_simple.py b/tests/test_simple.py index 7fc7a346..7f809047 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -1,28 +1,32 @@ """Quick'n'dirty unit tests for provided fixtures and markers.""" import asyncio import os +import sys import pytest -@asyncio.coroutine -def async_coro(loop): - yield from asyncio.sleep(0, loop=loop) +async def async_coro(): + await asyncio.sleep(0) return 'ok' def test_event_loop_fixture(event_loop): """Test the injection of the event_loop fixture.""" assert event_loop - ret = event_loop.run_until_complete(async_coro(event_loop)) + ret = event_loop.run_until_complete(async_coro()) assert ret == 'ok' +@pytest.mark.skipif( + sys.version_info >= (3, 7), + reason="Default process poll executor is deprecated since Python 3.8" +) def test_event_loop_processpool_fixture(event_loop_process_pool): """Test the injection of the event_loop with a process pool fixture.""" assert event_loop_process_pool ret = event_loop_process_pool.run_until_complete( - async_coro(event_loop_process_pool)) + async_coro()) assert ret == 'ok' this_pid = os.getpid() @@ -32,50 +36,51 @@ def test_event_loop_processpool_fixture(event_loop_process_pool): @pytest.mark.asyncio -def test_asyncio_marker(): +async def test_asyncio_marker(): """Test the asyncio pytest marker.""" - yield # sleep(0) + await asyncio.sleep(0) @pytest.mark.asyncio -def test_asyncio_marker_with_default_param(a_param=None): +async def test_asyncio_marker_with_default_param(a_param=None): """Test the asyncio pytest marker.""" - yield # sleep(0) + await asyncio.sleep(0) +@pytest.mark.skipif( + sys.version_info >= (3, 7), + reason="Default process poll executor is deprecated since Python 3.8" +) @pytest.mark.asyncio_process_pool -def test_asyncio_process_pool_marker(event_loop): +async def test_asyncio_process_pool_marker(event_loop): """Test the asyncio pytest marker.""" - ret = yield from async_coro(event_loop) + ret = await async_coro() assert ret == 'ok' @pytest.mark.asyncio -def test_unused_port_fixture(unused_tcp_port, event_loop): +async def test_unused_port_fixture(unused_tcp_port, event_loop): """Test the unused TCP port fixture.""" - @asyncio.coroutine - def closer(_, writer): + async def closer(_, writer): writer.close() - server1 = yield from asyncio.start_server(closer, host='localhost', - port=unused_tcp_port, - loop=event_loop) + server1 = await asyncio.start_server(closer, host='localhost', + port=unused_tcp_port) with pytest.raises(IOError): - yield from asyncio.start_server(closer, host='localhost', - port=unused_tcp_port, - loop=event_loop) + await asyncio.start_server(closer, host='localhost', + port=unused_tcp_port) server1.close() - yield from server1.wait_closed() + await server1.wait_closed() class Test: """Test that asyncio marked functions work in test methods.""" @pytest.mark.asyncio - def test_asyncio_marker_method(self, event_loop): + async def test_asyncio_marker_method(self, event_loop): """Test the asyncio pytest marker in a Test class.""" - ret = yield from async_coro(event_loop) + ret = await async_coro() assert ret == 'ok' diff --git a/tox.ini b/tox.ini index 6fb5a1ca..24ee0055 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,13 @@ [tox] -envlist = py33, py34 +minversion = 3.14.0 +envlist = py35, py36, py37, py38 +skip_missing_interpreters = true [testenv] deps = - pip >= 6 + pip >= 19.3 -rtest_requirements.txt commands = - coverage run --source pytest_asyncio -m py.test + coverage run --source pytest_asyncio -m pytest coverage report changedir = tests From 05f259cae34e33b245ca65041b260a2844fbd86b Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 23 Oct 2019 14:01:49 +0300 Subject: [PATCH 2/4] Drop unused file --- test_requirements.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test_requirements.txt diff --git a/test_requirements.txt b/test_requirements.txt deleted file mode 100644 index 4010acd5..00000000 --- a/test_requirements.txt +++ /dev/null @@ -1 +0,0 @@ -coverage==4.5.4 From 0f86f798d0ca35ca0e16365414cebd030f2984ee Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 23 Oct 2019 14:12:38 +0300 Subject: [PATCH 3/4] Fix travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 267ef4f5..b93377ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ matrix: install: pip install tox-travis coveralls -script: tox +script: tox -e $TOX_ENV after_success: - tox -e coverage-report From 5e808a36cc655603b9a1e46055662ad6d1246158 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Tue, 10 Dec 2019 17:41:57 +0200 Subject: [PATCH 4/4] Add Python :: 3.8 Throve classifier --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 8c074a24..667ada10 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,7 @@ def find_version(): "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Topic :: Software Development :: Testing", "Framework :: Pytest", ],