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

Function test_render_with_body

tests/test_web_response.py:820–838  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

818
819@pytest.mark.run_loop
820def test_render_with_body():
821 writer = mock.Mock()
822 req = make_request('GET', '/', writer=writer)
823 resp = Response(body=b'data')
824
825 writer.drain.return_value = ()
826 buf = b''
827
828 def append(data):
829 nonlocal buf
830 buf += data
831
832 writer.write.side_effect = append
833
834 yield from resp.prepare(req)
835 yield from resp.write_eof()
836 txt = buf.decode('utf8')
837 assert re.match('HTTP/1.1 200 OK\r\nCONTENT-LENGTH: 4\r\n'
838 'DATE: .+\r\nSERVER: .+\r\n\r\ndata', txt)
839
840
841@pytest.mark.run_loop

Callers

nothing calls this directly

Calls 6

write_eofMethod · 0.95
ResponseClass · 0.90
decodeMethod · 0.80
make_requestFunction · 0.70
prepareMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected