MCPcopy Create free account
hub / github.com/aio-libs/aiohttp / test_HTTPFound

Function test_HTTPFound

tests/test_web_exceptions.py:104–120  ·  view source on GitHub ↗
(buf, http_request)

Source from the content-addressed store, hash-verified

102
103
104async def test_HTTPFound(buf, http_request) -> None:
105 resp = web.HTTPFound(location="/redirect")
106 assert "/redirect" == resp.location
107 assert "/redirect" == resp.headers["location"]
108 await resp.prepare(http_request)
109 await resp.write_eof()
110 txt = buf.decode("utf8")
111 assert re.match(
112 "HTTP/1.1 302 Found\r\n"
113 "Content-Type: text/plain; charset=utf-8\r\n"
114 "Location: /redirect\r\n"
115 "Content-Length: 10\r\n"
116 "Date: .+\r\n"
117 "Server: .+\r\n\r\n"
118 "302: Found",
119 txt,
120 )
121
122
123def test_HTTPFound_empty_location() -> None:

Callers

nothing calls this directly

Calls 4

prepareMethod · 0.45
write_eofMethod · 0.45
decodeMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected