Skip to content

Commit

Permalink
bpo-26133: Fix typos (GH-5010) (#5014)
Browse files Browse the repository at this point in the history
* Fix typos
* Change warning text
* Add test
(cherry picked from commit a8f4e15)
  • Loading branch information
miss-islington authored and asvetlov committed Dec 26, 2017
1 parent d62b741 commit 32518b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/asyncio/unix_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def close(self):
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()
Expand Down
17 changes: 17 additions & 0 deletions Lib/test/test_asyncio/test_unix_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,23 @@ def test_close(self, m_signal):
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')
Expand Down

0 comments on commit 32518b4

Please sign in to comment.