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

Function test_handle_error__utf

tests/test_server.py:261–281  ·  view source on GitHub ↗
(make_srv)

Source from the content-addressed store, hash-verified

259
260
261def test_handle_error__utf(make_srv):
262 transport = mock.Mock()
263 srv = make_srv(debug=True)
264 srv.connection_made(transport)
265 srv.keep_alive(True)
266 srv.writer = mock.Mock()
267 srv.logger = mock.Mock()
268
269 try:
270 raise RuntimeError('что-то пошло не так')
271 except RuntimeError as exc:
272 srv.handle_error(exc=exc)
273 content = b''.join(
274 [c[1][0] for c in list(srv.writer.write.mock_calls)])
275 assert b'HTTP/1.1 500 Internal Server Error' in content
276 assert b'CONTENT-TYPE: text/html; charset=utf-8' in content
277 pattern = escape("raise RuntimeError('что-то пошло не так')")
278 assert pattern.encode('utf-8') in content
279 assert not srv._keep_alive
280
281 srv.logger.exception.assert_called_with("Error handling request")
282
283
284def test_handle_error_traceback_exc(make_srv):

Callers

nothing calls this directly

Calls 5

make_srvFunction · 0.85
handle_errorMethod · 0.80
encodeMethod · 0.80
connection_madeMethod · 0.45
keep_aliveMethod · 0.45

Tested by

no test coverage detected