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

Function test_close

tests/test_websocket_client_functional.py:135–160  ·  view source on GitHub ↗
(create_app_and_client)

Source from the content-addressed store, hash-verified

133
134@pytest.mark.run_loop
135def test_close(create_app_and_client):
136
137 @asyncio.coroutine
138 def handler(request):
139 ws = web.WebSocketResponse()
140 yield from ws.prepare(request)
141
142 yield from ws.receive_bytes()
143 ws.send_str('test')
144
145 yield from ws.receive()
146 return ws
147
148 app, client = yield from create_app_and_client()
149 app.router.add_route('GET', '/', handler)
150 resp = yield from client.ws_connect('/')
151
152 resp.send_bytes(b'ask')
153
154 closed = yield from resp.close()
155 assert closed
156 assert resp.closed
157 assert resp.close_code == 1000
158
159 msg = yield from resp.receive()
160 assert msg.tp == aiohttp.MsgType.closed
161
162
163@pytest.mark.run_loop

Callers

nothing calls this directly

Calls 6

create_app_and_clientFunction · 0.85
add_routeMethod · 0.45
ws_connectMethod · 0.45
send_bytesMethod · 0.45
closeMethod · 0.45
receiveMethod · 0.45

Tested by

no test coverage detected