Skip to content

Commit

Permalink
Remove asyncio toolkit support (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdickinson committed Dec 16, 2021
1 parent 096a978 commit df08004
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
8 changes: 8 additions & 0 deletions docs/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ Features
* Support Qt6-based toolkits PyQt6 and PySide6. (This is dependent on
corresponding support in Pyface.) (#488)

Changes
~~~~~~~

* The "asyncio" and "null" entry points for the "traits_futures.event_loops"
entry point group have been removed. Their behaviour was ill-defined, and
dependent on ``asyncio.get_event_loop``, which is deprecated in Python.
(#490)

Documentation
~~~~~~~~~~~~~

Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ def get_long_description():
],
entry_points={
"traits_futures.event_loops": [
"asyncio = traits_futures.asyncio.event_loop:AsyncioEventLoop",
"null = traits_futures.asyncio.event_loop:AsyncioEventLoop",
"qt = traits_futures.qt.event_loop:QtEventLoop",
"qt4 = traits_futures.qt.event_loop:QtEventLoop",
"wx = traits_futures.wx.event_loop:WxEventLoop",
Expand Down
33 changes: 25 additions & 8 deletions traits_futures/tests/test_ets_event_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
#: resolved by ETSEventLoop.
PRINT_TOOLKIT = """
from traits_futures.ets_event_loop import ETSEventLoop
print(type(ETSEventLoop().toolkit_event_loop).__name__)
try:
event_loop = ETSEventLoop().toolkit_event_loop
except Exception as e:
print("Failed:", type(e).__name__)
else:
print("Loop:", type(event_loop).__name__)
"""


Expand Down Expand Up @@ -64,6 +69,7 @@ def find_selected_toolkit(ets_toolkit=None):
return process.stdout.rstrip()


@requires_qt
class TestETSEventLoop(IEventLoopTests, unittest.TestCase):
#: Factory for instances of the event loop.
event_loop_factory = ETSEventLoop
Expand All @@ -79,22 +85,33 @@ def test_toolkit_choice_cached(self):
class TestToolkitSelection(unittest.TestCase):
@requires_qt
def test_selects_qt(self):
self.assertEqual(find_selected_toolkit("qt"), "QtEventLoop")
self.assertEqual(find_selected_toolkit("qt4"), "QtEventLoop")
self.assertEqual(find_selected_toolkit("qt"), "Loop: QtEventLoop")
self.assertEqual(find_selected_toolkit("qt4"), "Loop: QtEventLoop")

@requires_qt
def test_qt_priority(self):
# If Qt is present, under current ETS rules it takes priority,
# regardless of what other toolkits are available.
self.assertEqual(find_selected_toolkit(), "Loop: QtEventLoop")

@requires_wx
def test_selects_wx(self):
self.assertEqual(find_selected_toolkit("wx"), "WxEventLoop")
self.assertEqual(find_selected_toolkit("wx"), "Loop: WxEventLoop")

def test_null_selects_asyncio(self):
self.assertEqual(find_selected_toolkit("asyncio"), "AsyncioEventLoop")
self.assertEqual(find_selected_toolkit("null"), "AsyncioEventLoop")
def test_bogus_value(self):
self.assertEqual(
find_selected_toolkit("bogus"), "Failed: RuntimeError"
)

def test_no_ets_toolkit_var(self):
toolkit_event_loop = find_selected_toolkit()
# We'll get different results depending on the environment that
# the toolkit selection is performed in.
self.assertIn(
toolkit_event_loop,
["QtEventLoop", "WxEventLoop", "AsyncioEventLoop"],
[
"Loop: QtEventLoop",
"Loop: WxEventLoop",
"Failed: RuntimeError",
],
)

0 comments on commit df08004

Please sign in to comment.