本文整理汇总了Python中txtorcon.Stream.id方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.id方法的具体用法?Python Stream.id怎么用?Python Stream.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txtorcon.Stream
的用法示例。
在下文中一共展示了Stream.id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_close_stream
# 需要导入模块: from txtorcon import Stream [as 别名]
# 或者: from txtorcon.Stream import id [as 别名]
def test_close_stream(self):
stream = Stream(self.state)
stream.id = 1
try:
self.state.close_stream(stream)
self.assertTrue(False)
except KeyError:
pass
self.state.streams[1] = stream
self.state.close_stream(stream)
self.assertEqual(self.transport.value(), 'CLOSESTREAM 1 1\r\n')
示例2: test_attacher_errors
# 需要导入模块: from txtorcon import Stream [as 别名]
# 或者: from txtorcon.Stream import id [as 别名]
def test_attacher_errors(self):
class MyAttacher(object):
implements(IStreamAttacher)
def __init__(self, answer):
self.streams = []
self.answer = answer
def attach_stream(self, stream, circuits):
return self.answer
self.state.circuits[1] = FakeCircuit(1)
attacher = MyAttacher(FakeCircuit(2))
self.state.set_attacher(attacher, FakeReactor(self))
stream = Stream(self.state)
stream.id = 3
msg = ''
try:
self.state._maybe_attach(stream)
except Exception, e:
msg = str(e)