当前位置: 首页>>代码示例>>Python>>正文


Python NonCallableMagicMock.in_flight方法代码示例

本文整理汇总了Python中mock.NonCallableMagicMock.in_flight方法的典型用法代码示例。如果您正苦于以下问题:Python NonCallableMagicMock.in_flight方法的具体用法?Python NonCallableMagicMock.in_flight怎么用?Python NonCallableMagicMock.in_flight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mock.NonCallableMagicMock的用法示例。


在下文中一共展示了NonCallableMagicMock.in_flight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_failed_wait_for_connection

# 需要导入模块: from mock import NonCallableMagicMock [as 别名]
# 或者: from mock.NonCallableMagicMock import in_flight [as 别名]
    def test_failed_wait_for_connection(self):
        host = Mock(spec=Host, address='ip1')
        session = self.make_session()
        conn = NonCallableMagicMock(spec=Connection, in_flight=0, is_defunct=False, is_closed=False)
        session.cluster.connection_factory.return_value = conn

        pool = HostConnectionPool(host, HostDistance.LOCAL, session)
        session.cluster.connection_factory.assert_called_once_with(host.address)

        pool.borrow_connection(timeout=0.01)
        self.assertEqual(1, conn.in_flight)

        conn.in_flight = MAX_STREAM_PER_CONNECTION

        # we're already at the max number of requests for this connection,
        # so we this should fail
        self.assertRaises(NoConnectionsAvailable, pool.borrow_connection, 0)
开发者ID:EverythingMe,项目名称:python-driver,代码行数:19,代码来源:test_host_connection_pool.py

示例2: test_spawn_when_at_max

# 需要导入模块: from mock import NonCallableMagicMock [as 别名]
# 或者: from mock.NonCallableMagicMock import in_flight [as 别名]
    def test_spawn_when_at_max(self):
        host = Mock(spec=Host, address='ip1')
        session = self.make_session()
        conn = NonCallableMagicMock(spec=Connection, in_flight=0, is_defunct=False, is_closed=False)
        session.cluster.connection_factory.return_value = conn

        # core conns = 1, max conns = 2
        session.cluster.get_max_connections_per_host.return_value = 2

        pool = HostConnectionPool(host, HostDistance.LOCAL, session)
        session.cluster.connection_factory.assert_called_once_with(host.address)

        pool.borrow_connection(timeout=0.01)
        self.assertEqual(1, conn.in_flight)

        # make this conn full
        conn.in_flight = MAX_STREAM_PER_CONNECTION

        # we don't care about making this borrow_connection call succeed for the
        # purposes of this test, as long as it results in a new connection
        # creation being scheduled
        self.assertRaises(NoConnectionsAvailable, pool.borrow_connection, 0)
        session.submit.assert_called_once_with(pool._create_new_connection)
开发者ID:EverythingMe,项目名称:python-driver,代码行数:25,代码来源:test_host_connection_pool.py


注:本文中的mock.NonCallableMagicMock.in_flight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。