本文整理汇总了Python中pants.engine.Engine.add_channel方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.add_channel方法的具体用法?Python Engine.add_channel怎么用?Python Engine.add_channel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.engine.Engine
的用法示例。
在下文中一共展示了Engine.add_channel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestEngineAddChannel
# 需要导入模块: from pants.engine import Engine [as 别名]
# 或者: from pants.engine.Engine import add_channel [as 别名]
class TestEngineAddChannel(unittest.TestCase):
def setUp(self):
self.engine = Engine()
self.poller = MagicMock()
self.poller.add = MagicMock()
self.engine._poller = self.poller
self.channel = MagicMock()
self.channel.fileno = "foo"
self.channel._events = "bar"
def test_channel_is_added_to_engine(self):
self.engine.add_channel(self.channel)
self.assertTrue(self.channel.fileno in self.engine._channels)
self.assertEqual(self.engine._channels[self.channel.fileno], self.channel)
def test_channel_is_added_to_poller(self):
self.engine.add_channel(self.channel)
self.poller.add.assert_called_once_with(self.channel.fileno, self.channel._events)
示例2: test_channel_gets_added_to_engine
# 需要导入模块: from pants.engine import Engine [as 别名]
# 或者: from pants.engine.Engine import add_channel [as 别名]
def test_channel_gets_added_to_engine(self):
engine = Engine()
engine.add_channel = MagicMock()
channel = _Channel(socket=socket.socket(), engine=engine)
engine.add_channel.assert_called_once_with(channel)
channel.close()