Skip to content

Commit 56e94d4

Browse files
committed
Test on Python 3.8, drop 3.3 and 3.4
1 parent 71856a2 commit 56e94d4

File tree

5 files changed

+46
-33
lines changed

5 files changed

+46
-33
lines changed

.travis.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
language: python
2-
python: 3.3
32

4-
env:
5-
- TOX_ENV=py33
6-
- TOX_ENV=py34
3+
matrix:
4+
include:
5+
- python: 3.5
6+
env: TOXENV=py35
7+
- python: 3.6
8+
env: TOXENV=py36
9+
- python: 3.7
10+
env: TOXENV=py37
11+
- python: 3.8
12+
env: TOXENV=py38
713

814
install:
915
- pip install tox
1016

11-
script: tox -e $TOX_ENV
17+
script: tox
1218

1319
after_success:
1420
- pip install coveralls && cd tests && coveralls

pytest_asyncio/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def pytest_pyfunc_call(pyfuncitem):
4040
testargs = {arg: funcargs[arg]
4141
for arg in pyfuncitem._fixtureinfo.argnames}
4242
event_loop.run_until_complete(
43-
asyncio.async(pyfuncitem.obj(**testargs)))
43+
asyncio.ensure_future(pyfuncitem.obj(**testargs)))
4444
return True
4545

4646

test_requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
coverage==3.7.1
1+
coverage==4.5.4

tests/test_simple.py

+28-23
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
"""Quick'n'dirty unit tests for provided fixtures and markers."""
22
import asyncio
33
import os
4+
import sys
45
import pytest
56

67

7-
@asyncio.coroutine
8-
def async_coro(loop):
9-
yield from asyncio.sleep(0, loop=loop)
8+
async def async_coro():
9+
await asyncio.sleep(0)
1010
return 'ok'
1111

1212

1313
def test_event_loop_fixture(event_loop):
1414
"""Test the injection of the event_loop fixture."""
1515
assert event_loop
16-
ret = event_loop.run_until_complete(async_coro(event_loop))
16+
ret = event_loop.run_until_complete(async_coro())
1717
assert ret == 'ok'
1818

1919

20+
@pytest.mark.skipif(
21+
sys.version_info >= (3, 7),
22+
reason="Default process poll executor is deprecated since Python 3.8"
23+
)
2024
def test_event_loop_processpool_fixture(event_loop_process_pool):
2125
"""Test the injection of the event_loop with a process pool fixture."""
2226
assert event_loop_process_pool
2327

2428
ret = event_loop_process_pool.run_until_complete(
25-
async_coro(event_loop_process_pool))
29+
async_coro())
2630
assert ret == 'ok'
2731

2832
this_pid = os.getpid()
@@ -32,50 +36,51 @@ def test_event_loop_processpool_fixture(event_loop_process_pool):
3236

3337

3438
@pytest.mark.asyncio
35-
def test_asyncio_marker():
39+
async def test_asyncio_marker():
3640
"""Test the asyncio pytest marker."""
37-
yield # sleep(0)
41+
await asyncio.sleep(0)
3842

3943

4044
@pytest.mark.asyncio
41-
def test_asyncio_marker_with_default_param(a_param=None):
45+
async def test_asyncio_marker_with_default_param(a_param=None):
4246
"""Test the asyncio pytest marker."""
43-
yield # sleep(0)
47+
await asyncio.sleep(0)
4448

4549

50+
@pytest.mark.skipif(
51+
sys.version_info >= (3, 7),
52+
reason="Default process poll executor is deprecated since Python 3.8"
53+
)
4654
@pytest.mark.asyncio_process_pool
47-
def test_asyncio_process_pool_marker(event_loop):
55+
async def test_asyncio_process_pool_marker(event_loop):
4856
"""Test the asyncio pytest marker."""
49-
ret = yield from async_coro(event_loop)
57+
ret = await async_coro()
5058
assert ret == 'ok'
5159

5260

5361
@pytest.mark.asyncio
54-
def test_unused_port_fixture(unused_tcp_port, event_loop):
62+
async def test_unused_port_fixture(unused_tcp_port, event_loop):
5563
"""Test the unused TCP port fixture."""
5664

57-
@asyncio.coroutine
58-
def closer(_, writer):
65+
async def closer(_, writer):
5966
writer.close()
6067

61-
server1 = yield from asyncio.start_server(closer, host='localhost',
62-
port=unused_tcp_port,
63-
loop=event_loop)
68+
server1 = await asyncio.start_server(closer, host='localhost',
69+
port=unused_tcp_port)
6470

6571
with pytest.raises(IOError):
66-
yield from asyncio.start_server(closer, host='localhost',
67-
port=unused_tcp_port,
68-
loop=event_loop)
72+
await asyncio.start_server(closer, host='localhost',
73+
port=unused_tcp_port)
6974

7075
server1.close()
71-
yield from server1.wait_closed()
76+
await server1.wait_closed()
7277

7378

7479
class Test:
7580
"""Test that asyncio marked functions work in test methods."""
7681

7782
@pytest.mark.asyncio
78-
def test_asyncio_marker_method(self, event_loop):
83+
async def test_asyncio_marker_method(self, event_loop):
7984
"""Test the asyncio pytest marker in a Test class."""
80-
ret = yield from async_coro(event_loop)
85+
ret = await async_coro()
8186
assert ret == 'ok'

tox.ini

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
[tox]
2-
envlist = py33, py34
2+
minversion = 3.14.0
3+
envlist = py35, py36, py37, py38
4+
skip_missing_interpreters = true
35

46
[testenv]
57
deps =
6-
pip >= 6
8+
pip >= 19.3
79
-rtest_requirements.txt
810
commands =
9-
coverage run --source pytest_asyncio -m py.test
11+
coverage run --source pytest_asyncio -m pytest
1012
coverage report
1113
changedir = tests

0 commit comments

Comments
 (0)