2323import asyncio
2424from asyncio import log
2525from asyncio import base_events
26+ from asyncio import events
2627from asyncio import unix_events
2728from test .test_asyncio import utils as test_utils
2829
@@ -517,7 +518,7 @@ def test_with_offset_and_count(self):
517518 def test_sendfile_not_available (self ):
518519 sock , proto = self .prepare ()
519520 with mock .patch ('asyncio.unix_events.os' , spec = []):
520- with self .assertRaisesRegex (base_events . _SendfileNotAvailable ,
521+ with self .assertRaisesRegex (events . SendfileNotAvailableError ,
521522 "os[.]sendfile[(][)] is not available" ):
522523 self .run_loop (self .loop ._sock_sendfile_native (sock , self .file ,
523524 0 , None ))
@@ -526,7 +527,7 @@ def test_sendfile_not_available(self):
526527 def test_sendfile_not_a_file (self ):
527528 sock , proto = self .prepare ()
528529 f = object ()
529- with self .assertRaisesRegex (base_events . _SendfileNotAvailable ,
530+ with self .assertRaisesRegex (events . SendfileNotAvailableError ,
530531 "not a regular file" ):
531532 self .run_loop (self .loop ._sock_sendfile_native (sock , f ,
532533 0 , None ))
@@ -535,7 +536,7 @@ def test_sendfile_not_a_file(self):
535536 def test_sendfile_iobuffer (self ):
536537 sock , proto = self .prepare ()
537538 f = io .BytesIO ()
538- with self .assertRaisesRegex (base_events . _SendfileNotAvailable ,
539+ with self .assertRaisesRegex (events . SendfileNotAvailableError ,
539540 "not a regular file" ):
540541 self .run_loop (self .loop ._sock_sendfile_native (sock , f ,
541542 0 , None ))
@@ -545,7 +546,7 @@ def test_sendfile_not_regular_file(self):
545546 sock , proto = self .prepare ()
546547 f = mock .Mock ()
547548 f .fileno .return_value = - 1
548- with self .assertRaisesRegex (base_events . _SendfileNotAvailable ,
549+ with self .assertRaisesRegex (events . SendfileNotAvailableError ,
549550 "not a regular file" ):
550551 self .run_loop (self .loop ._sock_sendfile_native (sock , f ,
551552 0 , None ))
@@ -631,7 +632,7 @@ def test_os_error_first_call(self):
631632 with self .assertRaises (KeyError ):
632633 self .loop ._selector .get_key (sock )
633634 exc = fut .exception ()
634- self .assertIsInstance (exc , base_events . _SendfileNotAvailable )
635+ self .assertIsInstance (exc , events . SendfileNotAvailableError )
635636 self .assertEqual (0 , self .file .tell ())
636637
637638 def test_os_error_next_call (self ):
@@ -656,7 +657,7 @@ def test_exception(self):
656657
657658 fileno = self .file .fileno ()
658659 fut = self .loop .create_future ()
659- err = RuntimeError ()
660+ err = events . SendfileNotAvailableError ()
660661 with mock .patch ('os.sendfile' , side_effect = err ):
661662 self .loop ._sock_sendfile_native_impl (fut , sock .fileno (),
662663 sock , fileno ,
0 commit comments