bpo-26133: Fix typos (#5010)

* Fix typos
* Change warning text
* Add test
This commit is contained in:
Andrew Svetlov 2017-12-26 11:53:38 +02:00 committed by GitHub
parent e0aef4f3cd
commit a8f4e15f3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -56,9 +56,9 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
self.remove_signal_handler(sig)
else:
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"stage, signal unsubsription is disabled",
f"stage, skipping signal handlers removal",
ResourceWarning,
source=self)
self._signal_handlers.clear()

View File

@ -229,6 +229,23 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
self.assertEqual(len(self.loop._signal_handlers), 0)
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'),
'UNIX Sockets are not supported')