]> granicus.if.org Git - python/commitdiff
bpo-26133: Fix typos (#5010)
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Tue, 26 Dec 2017 09:53:38 +0000 (11:53 +0200)
committerGitHub <noreply@github.com>
Tue, 26 Dec 2017 09:53:38 +0000 (11:53 +0200)
* Fix typos
* Change warning text
* Add test

Lib/asyncio/unix_events.py
Lib/test/test_asyncio/test_unix_events.py

index 5d6a3c09ac7c95ea912f281ce71621153b14927a..4f6beb43650965b9634f9b4a412793329d3eb39f 100644 (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()
index 097d0ef73dc9af24d3d0988bf409cb9568d929e7..53ed3d94ddb5b1e0af4d1ced244f2a93f269fab3 100644 (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')