summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asynchat.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_asynchat.py')
-rw-r--r--Lib/test/test_asynchat.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py
index b74b944..3a33fc8 100644
--- a/Lib/test/test_asynchat.py
+++ b/Lib/test/test_asynchat.py
@@ -7,11 +7,13 @@ thread = support.import_module('_thread')
import asynchat
import asyncore
+import errno
import socket
import sys
import time
import unittest
import warnings
+import unittest.mock
try:
import threading
except ImportError:
@@ -274,6 +276,21 @@ class TestAsynchat_WithPoll(TestAsynchat):
usepoll = True
+class TestAsynchatMocked(unittest.TestCase):
+ def test_blockingioerror(self):
+ # Issue #16133: handle_read() must ignore BlockingIOError
+ sock = unittest.mock.Mock()
+ sock.recv.side_effect = BlockingIOError(errno.EAGAIN)
+
+ dispatcher = asynchat.async_chat()
+ dispatcher.set_socket(sock)
+ self.addCleanup(dispatcher.del_channel)
+
+ with unittest.mock.patch.object(dispatcher, 'handle_error') as error:
+ dispatcher.handle_read()
+ self.assertFalse(error.called)
+
+
class TestHelperFunctions(unittest.TestCase):
def test_find_prefix_at_end(self):
self.assertEqual(asynchat.find_prefix_at_end("qwerty\r", "\r\n"), 1)