Commit a8f4e15f authored by Andrew Svetlov's avatar Andrew Svetlov Committed by GitHub

bpo-26133: Fix typos (#5010)

* Fix typos
* Change warning text
* Add test
parent e0aef4f3
...@@ -56,9 +56,9 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): ...@@ -56,9 +56,9 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
self.remove_signal_handler(sig) self.remove_signal_handler(sig)
else: else:
if self._signal_handlers: if self._signal_handlers:
warinigs.warn(f"Closing the loop {self!r} " warnings.warn(f"Closing the loop {self!r} "
f"on interpreter shutdown " f"on interpreter shutdown "
f"stage, signal unsubsription is disabled", f"stage, skipping signal handlers removal",
ResourceWarning, ResourceWarning,
source=self) source=self)
self._signal_handlers.clear() self._signal_handlers.clear()
......
...@@ -229,6 +229,23 @@ class SelectorEventLoopSignalTests(test_utils.TestCase): ...@@ -229,6 +229,23 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
self.assertEqual(len(self.loop._signal_handlers), 0) self.assertEqual(len(self.loop._signal_handlers), 0)
m_signal.set_wakeup_fd.assert_called_once_with(-1) m_signal.set_wakeup_fd.assert_called_once_with(-1)
@mock.patch('asyncio.unix_events.sys')
@mock.patch('asyncio.unix_events.signal')
def test_close_on_finalizing(self, m_signal, m_sys):
m_signal.NSIG = signal.NSIG
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
self.assertEqual(len(self.loop._signal_handlers), 1)
m_sys.is_finalizing.return_value = True
m_signal.signal.reset_mock()
with self.assertWarnsRegex(ResourceWarning,
"skipping signal handlers removal"):
self.loop.close()
self.assertEqual(len(self.loop._signal_handlers), 0)
self.assertFalse(m_signal.signal.called)
@unittest.skipUnless(hasattr(socket, 'AF_UNIX'), @unittest.skipUnless(hasattr(socket, 'AF_UNIX'),
'UNIX Sockets are not supported') 'UNIX Sockets are not supported')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment