aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_asyncio/test_unix_events.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_asyncio/test_unix_events.py')
-rw-r--r--Lib/test/test_asyncio/test_unix_events.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index 2f3fa185c95..b6ad0189215 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -65,15 +65,21 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
@mock.patch('asyncio.unix_events.signal')
def test_add_signal_handler_coroutine_error(self, m_signal):
+ m_signal.NSIG = signal.NSIG
@asyncio.coroutine
def simple_coroutine():
yield from []
- self.assertRaises(
- TypeError,
- self.loop.add_signal_handler,
- signal.SIGINT, simple_coroutine)
+ # callback must not be a coroutine function
+ coro_func = simple_coroutine
+ coro_obj = coro_func()
+ self.addCleanup(coro_obj.close)
+ for func in (coro_func, coro_obj):
+ self.assertRaisesRegex(
+ TypeError, 'coroutines cannot be used with add_signal_handler',
+ self.loop.add_signal_handler,
+ signal.SIGINT, func)
@mock.patch('asyncio.unix_events.signal')
def test_add_signal_handler(self, m_signal):