本文整理汇总了Python中aiohttp.connector.Connection类的典型用法代码示例。如果您正苦于以下问题:Python Connection类的具体用法?Python Connection怎么用?Python Connection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Connection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_close
def test_close(self):
conn = Connection(
self.connector, self.key, self.request,
self.transport, self.protocol)
conn.close()
self.assertTrue(self.transport.close.called)
self.assertIsNone(conn._transport)
示例2: test_detach_closed
def test_detach_closed(connector, key, protocol, loop):
conn = Connection(connector, key, protocol, loop)
conn.release()
conn.detach()
assert not connector._release_acquired.called
assert conn._protocol is None
示例3: test_close
def test_close(connector, key, protocol, loop) -> None:
conn = Connection(connector, key, protocol, loop)
assert not conn.closed
conn.close()
assert conn._protocol is None
connector._release.assert_called_with(key, protocol, should_close=True)
assert conn.closed
示例4: test_ctor
def test_ctor(connector, key, request, transport, protocol, loop):
conn = Connection(connector, key, request,
transport, protocol, loop)
assert conn.loop is loop
assert conn.protocol is protocol
assert conn.writer is protocol.writer
conn.close()
示例5: test_release_released
def test_release_released(connector, key, protocol, loop) -> None:
conn = Connection(connector, key, protocol, loop)
conn.release()
connector._release.reset_mock()
conn.release()
assert not protocol.transport.close.called
assert conn._protocol is None
assert not connector._release.called
示例6: test_release
def test_release(connector, key, protocol, loop) -> None:
conn = Connection(connector, key, protocol, loop)
assert not conn.closed
conn.release()
assert not protocol.transport.close.called
assert conn._protocol is None
connector._release.assert_called_with(key, protocol, should_close=False)
assert conn.closed
示例7: test_detach
def test_detach(connector, key, request, transport, protocol, loop):
conn = Connection(connector, key, request,
transport, protocol, loop)
assert not conn.closed
conn.detach()
assert conn._transport is None
assert not connector._release.called
assert conn.closed
示例8: test_detach
def test_detach(connector, key, protocol, loop) -> None:
conn = Connection(connector, key, protocol, loop)
assert not conn.closed
conn.detach()
assert conn._protocol is None
assert connector._release_acquired.called
assert not connector._release.called
assert conn.closed
示例9: test_release_released
def test_release_released(connector, key, request, transport, protocol, loop):
conn = Connection(connector, key, request,
transport, protocol, loop)
conn.release()
connector._release.reset_mock()
conn.release()
assert not transport.close.called
assert conn._transport is None
assert not connector._release.called
示例10: test_detach
def test_detach(self):
conn = Connection(
self.connector, self.key, self.request,
self.transport, self.protocol, self.loop)
self.assertFalse(conn.closed)
conn.detach()
self.assertIsNone(conn._transport)
self.assertFalse(self.connector._release.called)
self.assertTrue(conn.closed)
示例11: test_release
def test_release(self):
conn = Connection(
self.connector, self.key, self.request,
self.transport, self.protocol)
conn.release()
self.assertFalse(self.transport.close.called)
self.assertIsNone(conn._transport)
self.connector._release.assert_called_with(
self.key, self.request, self.transport, self.protocol)
示例12: test_no_share_cookies
def test_no_share_cookies(self):
connector = aiohttp.BaseConnector(share_cookies=False, loop=self.loop)
conn = Connection(
connector, self.key, self.request,
self.transport, self.protocol, self.loop)
self.assertEqual(connector.cookies, {})
conn.share_cookies({'c1': 'cookie1'})
self.assertEqual(connector.cookies, {})
示例13: test_close
def test_close(self):
conn = Connection(
self.connector, self.key, self.request,
self.transport, self.protocol, self.loop)
conn.close()
self.assertIsNone(conn._transport)
self.connector._release.assert_called_with(
self.key, self.request, self.transport, self.protocol,
should_close=True)
示例14: test_close
def test_close(connector, key, request, transport, protocol, loop):
conn = Connection(connector, key, request,
transport, protocol, loop)
assert not conn.closed
conn.close()
assert conn._transport is None
connector._release.assert_called_with(
key, request, transport, protocol,
should_close=True)
assert conn.closed
示例15: test_release_released
def test_release_released(self):
conn = Connection(
self.connector, self.key, self.request,
self.transport, self.protocol, self.loop)
conn.release()
self.connector._release.reset_mock()
conn.release()
self.assertFalse(self.transport.close.called)
self.assertIsNone(conn._transport)
self.assertFalse(self.connector._release.called)