summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_unix_events.py
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2018-01-19 18:04:29 (GMT)
committerGitHub <noreply@github.com>2018-01-19 18:04:29 (GMT)
commit7464e87a6511d3626b04c9833a262a77b1f21e23 (patch)
tree4d7bc17260536bd3d91902b521cbf30957cdc1c8 /Lib/test/test_asyncio/test_unix_events.py
parent2507e29a9e4e9dcac6eab46546bd3d34a69342ba (diff)
downloadcpython-7464e87a6511d3626b04c9833a262a77b1f21e23.zip
cpython-7464e87a6511d3626b04c9833a262a77b1f21e23.tar.gz
cpython-7464e87a6511d3626b04c9833a262a77b1f21e23.tar.bz2
bpo-32410: Make SendfileNotAvailableError exception public (#5243)
Diffstat (limited to 'Lib/test/test_asyncio/test_unix_events.py')
-rw-r--r--Lib/test/test_asyncio/test_unix_events.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index 4e2b76b..8646bf7 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -23,6 +23,7 @@ if sys.platform == 'win32':
import asyncio
from asyncio import log
from asyncio import base_events
+from asyncio import events
from asyncio import unix_events
from test.test_asyncio import utils as test_utils
@@ -517,7 +518,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
def test_sendfile_not_available(self):
sock, proto = self.prepare()
with mock.patch('asyncio.unix_events.os', spec=[]):
- with self.assertRaisesRegex(base_events._SendfileNotAvailable,
+ with self.assertRaisesRegex(events.SendfileNotAvailableError,
"os[.]sendfile[(][)] is not available"):
self.run_loop(self.loop._sock_sendfile_native(sock, self.file,
0, None))
@@ -526,7 +527,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
def test_sendfile_not_a_file(self):
sock, proto = self.prepare()
f = object()
- with self.assertRaisesRegex(base_events._SendfileNotAvailable,
+ with self.assertRaisesRegex(events.SendfileNotAvailableError,
"not a regular file"):
self.run_loop(self.loop._sock_sendfile_native(sock, f,
0, None))
@@ -535,7 +536,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
def test_sendfile_iobuffer(self):
sock, proto = self.prepare()
f = io.BytesIO()
- with self.assertRaisesRegex(base_events._SendfileNotAvailable,
+ with self.assertRaisesRegex(events.SendfileNotAvailableError,
"not a regular file"):
self.run_loop(self.loop._sock_sendfile_native(sock, f,
0, None))
@@ -545,7 +546,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
sock, proto = self.prepare()
f = mock.Mock()
f.fileno.return_value = -1
- with self.assertRaisesRegex(base_events._SendfileNotAvailable,
+ with self.assertRaisesRegex(events.SendfileNotAvailableError,
"not a regular file"):
self.run_loop(self.loop._sock_sendfile_native(sock, f,
0, None))
@@ -631,7 +632,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
with self.assertRaises(KeyError):
self.loop._selector.get_key(sock)
exc = fut.exception()
- self.assertIsInstance(exc, base_events._SendfileNotAvailable)
+ self.assertIsInstance(exc, events.SendfileNotAvailableError)
self.assertEqual(0, self.file.tell())
def test_os_error_next_call(self):
@@ -656,7 +657,7 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
fileno = self.file.fileno()
fut = self.loop.create_future()
- err = RuntimeError()
+ err = events.SendfileNotAvailableError()
with mock.patch('os.sendfile', side_effect=err):
self.loop._sock_sendfile_native_impl(fut, sock.fileno(),
sock, fileno,