def test_close(self): @asyncio.coroutine def gen(): yield from asyncio.sleep(0.00001, loop=self.loop) return b'result' req = HttpRequest( 'POST', 'http://python.org/', data=gen(), loop=self.loop) req.send(self.transport) self.loop.run_until_complete(req.close()) self.assertEqual( self.transport.write.mock_calls[-3:], [unittest.mock.call(b'result'), unittest.mock.call(b'\r\n'), unittest.mock.call(b'0\r\n\r\n')])
def test_close(self): @asyncio.coroutine def gen(): yield from asyncio.sleep(0.00001, loop=self.loop) return b'result' req = HttpRequest('POST', 'http://python.org/', data=gen(), loop=self.loop) req.send(self.transport) self.loop.run_until_complete(req.close()) self.assertEqual(self.transport.write.mock_calls[-3:], [ unittest.mock.call(b'result'), unittest.mock.call(b'\r\n'), unittest.mock.call(b'0\r\n\r\n') ])