mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-34622: Extract asyncio exceptions into a separate module (GH-9141)
This commit is contained in:
parent
7c7605ff11
commit
0baa72f4b2
18 changed files with 148 additions and 110 deletions
|
@ -1946,7 +1946,7 @@ class BaseLoopSockSendfileTests(test_utils.TestCase):
|
|||
def test__sock_sendfile_native_failure(self):
|
||||
sock, proto = self.prepare()
|
||||
|
||||
with self.assertRaisesRegex(events.SendfileNotAvailableError,
|
||||
with self.assertRaisesRegex(asyncio.SendfileNotAvailableError,
|
||||
"sendfile is not available"):
|
||||
self.run_loop(self.loop._sock_sendfile_native(sock, self.file,
|
||||
0, None))
|
||||
|
@ -1957,7 +1957,7 @@ class BaseLoopSockSendfileTests(test_utils.TestCase):
|
|||
def test_sock_sendfile_no_fallback(self):
|
||||
sock, proto = self.prepare()
|
||||
|
||||
with self.assertRaisesRegex(events.SendfileNotAvailableError,
|
||||
with self.assertRaisesRegex(asyncio.SendfileNotAvailableError,
|
||||
"sendfile is not available"):
|
||||
self.run_loop(self.loop.sock_sendfile(sock, self.file,
|
||||
fallback=False))
|
||||
|
|
|
@ -2393,7 +2393,7 @@ class SendfileMixin(SendfileBase):
|
|||
|
||||
self.loop._sendfile_native = sendfile_native
|
||||
|
||||
with self.assertRaisesRegex(events.SendfileNotAvailableError,
|
||||
with self.assertRaisesRegex(asyncio.SendfileNotAvailableError,
|
||||
"not supported"):
|
||||
self.run_loop(
|
||||
self.loop.sendfile(cli_proto.transport, self.file,
|
||||
|
|
|
@ -951,7 +951,7 @@ class ProactorEventLoopUnixSockSendfileTests(test_utils.TestCase):
|
|||
def test_sock_sendfile_not_a_file(self):
|
||||
sock, proto = self.prepare()
|
||||
f = object()
|
||||
with self.assertRaisesRegex(events.SendfileNotAvailableError,
|
||||
with self.assertRaisesRegex(asyncio.SendfileNotAvailableError,
|
||||
"not a regular file"):
|
||||
self.run_loop(self.loop._sock_sendfile_native(sock, f,
|
||||
0, None))
|
||||
|
@ -960,7 +960,7 @@ class ProactorEventLoopUnixSockSendfileTests(test_utils.TestCase):
|
|||
def test_sock_sendfile_iobuffer(self):
|
||||
sock, proto = self.prepare()
|
||||
f = io.BytesIO()
|
||||
with self.assertRaisesRegex(events.SendfileNotAvailableError,
|
||||
with self.assertRaisesRegex(asyncio.SendfileNotAvailableError,
|
||||
"not a regular file"):
|
||||
self.run_loop(self.loop._sock_sendfile_native(sock, f,
|
||||
0, None))
|
||||
|
@ -970,7 +970,7 @@ class ProactorEventLoopUnixSockSendfileTests(test_utils.TestCase):
|
|||
sock, proto = self.prepare()
|
||||
f = mock.Mock()
|
||||
f.fileno.return_value = -1
|
||||
with self.assertRaisesRegex(events.SendfileNotAvailableError,
|
||||
with self.assertRaisesRegex(asyncio.SendfileNotAvailableError,
|
||||
"not a regular file"):
|
||||
self.run_loop(self.loop._sock_sendfile_native(sock, f,
|
||||
0, None))
|
||||
|
|
|
@ -521,7 +521,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
|
|||
def test_sock_sendfile_not_available(self):
|
||||
sock, proto = self.prepare()
|
||||
with mock.patch('asyncio.unix_events.os', spec=[]):
|
||||
with self.assertRaisesRegex(events.SendfileNotAvailableError,
|
||||
with self.assertRaisesRegex(asyncio.SendfileNotAvailableError,
|
||||
"os[.]sendfile[(][)] is not available"):
|
||||
self.run_loop(self.loop._sock_sendfile_native(sock, self.file,
|
||||
0, None))
|
||||
|
@ -530,7 +530,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
|
|||
def test_sock_sendfile_not_a_file(self):
|
||||
sock, proto = self.prepare()
|
||||
f = object()
|
||||
with self.assertRaisesRegex(events.SendfileNotAvailableError,
|
||||
with self.assertRaisesRegex(asyncio.SendfileNotAvailableError,
|
||||
"not a regular file"):
|
||||
self.run_loop(self.loop._sock_sendfile_native(sock, f,
|
||||
0, None))
|
||||
|
@ -539,7 +539,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
|
|||
def test_sock_sendfile_iobuffer(self):
|
||||
sock, proto = self.prepare()
|
||||
f = io.BytesIO()
|
||||
with self.assertRaisesRegex(events.SendfileNotAvailableError,
|
||||
with self.assertRaisesRegex(asyncio.SendfileNotAvailableError,
|
||||
"not a regular file"):
|
||||
self.run_loop(self.loop._sock_sendfile_native(sock, f,
|
||||
0, None))
|
||||
|
@ -549,7 +549,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
|
|||
sock, proto = self.prepare()
|
||||
f = mock.Mock()
|
||||
f.fileno.return_value = -1
|
||||
with self.assertRaisesRegex(events.SendfileNotAvailableError,
|
||||
with self.assertRaisesRegex(asyncio.SendfileNotAvailableError,
|
||||
"not a regular file"):
|
||||
self.run_loop(self.loop._sock_sendfile_native(sock, f,
|
||||
0, None))
|
||||
|
@ -605,7 +605,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
|
|||
with self.assertRaises(KeyError):
|
||||
self.loop._selector.get_key(sock)
|
||||
exc = fut.exception()
|
||||
self.assertIsInstance(exc, events.SendfileNotAvailableError)
|
||||
self.assertIsInstance(exc, asyncio.SendfileNotAvailableError)
|
||||
self.assertEqual(0, self.file.tell())
|
||||
|
||||
def test_sock_sendfile_os_error_next_call(self):
|
||||
|
@ -630,7 +630,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
|
|||
|
||||
fileno = self.file.fileno()
|
||||
fut = self.loop.create_future()
|
||||
err = events.SendfileNotAvailableError()
|
||||
err = asyncio.SendfileNotAvailableError()
|
||||
with mock.patch('os.sendfile', side_effect=err):
|
||||
self.loop._sock_sendfile_native_impl(fut, sock.fileno(),
|
||||
sock, fileno,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue