MCPcopy
hub / github.com/aio-libs/aiohttp / test_static_handle_exception

Method test_static_handle_exception

tests/test_urldispatch.py:612–627  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

610 self.assertFalse(loop.remove_writer.called)
611
612 def test_static_handle_exception(self):
613 loop = mock.Mock()
614 route = self.router.add_static('/st',
615 os.path.dirname(aiohttp.__file__))
616 with mock.patch('aiohttp.web_urldispatcher.os') as m_os:
617 out_fd = 30
618 in_fd = 31
619 fut = asyncio.Future(loop=self.loop)
620 exc = OSError()
621 m_os.sendfile.side_effect = exc
622 route._sendfile_cb(fut, out_fd, in_fd, 0, 100, loop, False)
623 m_os.sendfile.assert_called_with(out_fd, in_fd, 0, 100)
624 self.assertTrue(fut.done())
625 self.assertIs(exc, fut.exception())
626 self.assertFalse(loop.add_writer.called)
627 self.assertFalse(loop.remove_writer.called)
628
629 def fill_routes(self):
630 route1 = self.router.add_route('GET', '/plain', self.make_handler())

Callers

nothing calls this directly

Calls 4

add_staticMethod · 0.80
patchMethod · 0.80
_sendfile_cbMethod · 0.80
exceptionMethod · 0.45

Tested by

no test coverage detected