From e36fcde38309f116c6c06042ad80e7debb7db743 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 14 Nov 2014 11:45:47 -0800 Subject: - Issue #22841: Reject coroutines in asyncio add_signal_handler(). Patch by Ludovic.Gasc. --- Lib/test/test_asyncio/test_unix_events.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Lib/test/test_asyncio/test_unix_events.py') diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index e397598222d..2f3fa185c95 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -63,6 +63,18 @@ class SelectorEventLoopSignalTests(test_utils.TestCase): self.loop.add_signal_handler, signal.SIGINT, lambda: True) + @mock.patch('asyncio.unix_events.signal') + def test_add_signal_handler_coroutine_error(self, m_signal): + + @asyncio.coroutine + def simple_coroutine(): + yield from [] + + self.assertRaises( + TypeError, + self.loop.add_signal_handler, + signal.SIGINT, simple_coroutine) + @mock.patch('asyncio.unix_events.signal') def test_add_signal_handler(self, m_signal): m_signal.NSIG = signal.NSIG -- cgit v1.2.3