summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorGuido van Rossum <guido@dropbox.com>2013-11-07 04:25:50 (GMT)
committerGuido van Rossum <guido@dropbox.com>2013-11-07 04:25:50 (GMT)
commit0b69fbc6420115ce11e7f18249280a2c6d9a87ce (patch)
treeb626b482fa7e8901b64d15fcf1cd4ec1817380fb /Lib/test/test_asyncio
parent79ed4c744a0dc67941f539b3a7883dfe80ca24e8 (diff)
downloadcpython-0b69fbc6420115ce11e7f18249280a2c6d9a87ce.zip
cpython-0b69fbc6420115ce11e7f18249280a2c6d9a87ce.tar.gz
cpython-0b69fbc6420115ce11e7f18249280a2c6d9a87ce.tar.bz2
asyncio: Add close() back to Unix selector event loop, to remove all signal handlers. Should fix buildbot issues.
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_unix_events.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index a4d835e..42eba8d 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -183,6 +183,22 @@ class SelectorEventLoopTests(unittest.TestCase):
self.assertRaises(
RuntimeError, self.loop.remove_signal_handler, signal.SIGHUP)
+ @unittest.mock.patch('asyncio.unix_events.signal')
+ def test_close(self, m_signal):
+ m_signal.NSIG = signal.NSIG
+
+ self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
+ self.loop.add_signal_handler(signal.SIGCHLD, lambda: True)
+
+ self.assertEqual(len(self.loop._signal_handlers), 2)
+
+ m_signal.set_wakeup_fd.reset_mock()
+
+ self.loop.close()
+
+ self.assertEqual(len(self.loop._signal_handlers), 0)
+ m_signal.set_wakeup_fd.assert_called_once_with(-1)
+
class UnixReadPipeTransportTests(unittest.TestCase):