Skip to content

Commit d2dc635

Browse files
committed
Remove ProcessPoolExecutor support
Remove the `event_loop_process_pool` fixture and the `pytest.mark.asyncio_process_pool` marker to address deprecation and removal detailed in https://bugs.python.org/issue34075. Fixes pytest-dev#87.
1 parent 50337c8 commit d2dc635

File tree

4 files changed

+5
-57
lines changed

4 files changed

+5
-57
lines changed

README.rst

+4-12
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ If the ``pytest.mark.asyncio`` marker is applied, a pytest hook will
8888
ensure the produced loop is set as the default global loop.
8989
Fixtures depending on the ``event_loop`` fixture can expect the policy to be properly modified when they run.
9090

91-
``event_loop_process_pool``
92-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
93-
The ``event_loop_process_pool`` fixture is almost identical to the
94-
``event_loop`` fixture, except the created event loop will have a
95-
``concurrent.futures.ProcessPoolExecutor`` set as the default executor.
96-
9791
``unused_tcp_port``
9892
~~~~~~~~~~~~~~~~~~~
9993
Finds and yields a single unused TCP port on the localhost interface. Useful for
@@ -176,17 +170,15 @@ Only test coroutines will be affected (by default, coroutines prefixed by
176170
.. |pytestmark| replace:: ``pytestmark``
177171
.. _pytestmark: http://doc.pytest.org/en/latest/example/markers.html#marking-whole-classes-or-modules
178172

179-
``pytest.mark.asyncio_process_pool``
180-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181-
The ``asyncio_process_pool`` marker is almost identical to the ``asyncio``
182-
marker, except the event loop used will have a
183-
``concurrent.futures.ProcessPoolExecutor`` set as the default executor.
184-
185173
Changelog
186174
---------
187175

188176
0.9.0 (UNRELEASED)
189177
~~~~~~~~~~~~~~~~~~
178+
- Python 3.7 support
179+
- Remove ``event_loop_process_pool`` fixture and
180+
``pytest.mark.asyncio_process_pool`` marker (see
181+
https://bugs.python.org/issue34075 for deprecation and removal details)
190182

191183
0.8.0 (2017-09-23)
192184
~~~~~~~~~~~~~~~~~~

pytest_asyncio/plugin.py

+1-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import contextlib
44
import inspect
55
import socket
6-
from concurrent.futures import ProcessPoolExecutor
76

87
import pytest
98
from _pytest.python import transfer_markers
@@ -25,11 +24,6 @@ def pytest_configure(config):
2524
"asyncio: "
2625
"mark the test as a coroutine, it will be "
2726
"run using an asyncio event loop")
28-
config.addinivalue_line("markers",
29-
"asyncio_process_pool: "
30-
"mark the test as a coroutine, it will be "
31-
"run using an asyncio event loop with a process "
32-
"pool")
3327

3428

3529
@pytest.mark.tryfirst
@@ -44,8 +38,7 @@ def pytest_pycollect_makeitem(collector, name, obj):
4438
transfer_markers(obj, item.cls, item.module)
4539
item = pytest.Function(name, parent=collector) # To reload keywords.
4640

47-
if ('asyncio' in item.keywords or
48-
'asyncio_process_pool' in item.keywords):
41+
if 'asyncio' in item.keywords:
4942
return list(collector._genfunctions(name, obj))
5043

5144

@@ -170,7 +163,6 @@ def pytest_runtest_setup(item):
170163
# to marked test functions
171164
_markers_2_fixtures = {
172165
'asyncio': 'event_loop',
173-
'asyncio_process_pool': 'event_loop_process_pool',
174166
}
175167

176168

@@ -182,15 +174,6 @@ def event_loop(request):
182174
loop.close()
183175

184176

185-
@pytest.fixture
186-
def event_loop_process_pool(event_loop):
187-
"""Create a fresh instance of the default event loop.
188-
189-
The event loop will have a process pool set as the default executor."""
190-
event_loop.set_default_executor(ProcessPoolExecutor())
191-
return event_loop
192-
193-
194177
@pytest.fixture
195178
def unused_tcp_port():
196179
"""Find an unused localhost TCP port from 1024-65535 and return it."""

tests/test_simple.py

-21
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,6 @@ def test_event_loop_fixture(event_loop):
1919
assert ret == 'ok'
2020

2121

22-
def test_event_loop_processpool_fixture(event_loop_process_pool):
23-
"""Test the injection of the event_loop with a process pool fixture."""
24-
assert event_loop_process_pool
25-
26-
ret = event_loop_process_pool.run_until_complete(
27-
async_coro(event_loop_process_pool))
28-
assert ret == 'ok'
29-
30-
this_pid = os.getpid()
31-
future = event_loop_process_pool.run_in_executor(None, os.getpid)
32-
pool_pid = event_loop_process_pool.run_until_complete(future)
33-
assert this_pid != pool_pid
34-
35-
3622
@pytest.mark.asyncio
3723
def test_asyncio_marker():
3824
"""Test the asyncio pytest marker."""
@@ -51,13 +37,6 @@ def test_asyncio_marker_with_default_param(a_param=None):
5137
yield # sleep(0)
5238

5339

54-
@pytest.mark.asyncio_process_pool
55-
async def test_asyncio_process_pool_marker(event_loop):
56-
"""Test the asyncio pytest marker."""
57-
ret = await async_coro(event_loop)
58-
assert ret == 'ok'
59-
60-
6140
@pytest.mark.asyncio
6241
async def test_unused_port_fixture(unused_tcp_port, event_loop):
6342
"""Test the unused TCP port fixture."""

tests/test_simple_35.py

-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ async def test_asyncio_marker_with_default_param(a_param=None):
2020
"""Test the asyncio pytest marker."""
2121

2222

23-
@pytest.mark.asyncio_process_pool
24-
async def test_asyncio_process_pool_marker(event_loop):
25-
ret = await async_coro(event_loop)
26-
assert ret == 'ok'
27-
28-
2923
@pytest.mark.asyncio
3024
async def test_unused_port_fixture(unused_tcp_port, event_loop):
3125
"""Test the unused TCP port fixture."""

0 commit comments

Comments
 (0)