summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-12-26 10:29:29 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2017-12-26 10:29:29 (GMT)
commit32518b439b9590cce0ef0639e558dc1ce2e152bb (patch)
treed7504d20b08443d291e06cdc54900b7d1799578f /Lib
parentd62b7412c18bd5dfa6d7346abfaf8a922818e6db (diff)
downloadcpython-32518b439b9590cce0ef0639e558dc1ce2e152bb.zip
cpython-32518b439b9590cce0ef0639e558dc1ce2e152bb.tar.gz
cpython-32518b439b9590cce0ef0639e558dc1ce2e152bb.tar.bz2
bpo-26133: Fix typos (GH-5010) (#5014)
* Fix typos * Change warning text * Add test (cherry picked from commit a8f4e15f3d33084862ddd3a7d58cd00034e94f16)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/unix_events.py4
-rw-r--r--Lib/test/test_asyncio/test_unix_events.py17
2 files changed, 19 insertions, 2 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index 70b7050..b18824f 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -66,9 +66,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()
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index 5a49984..868751b 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -230,6 +230,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')