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


Python Circuit.when_built方法代码示例

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


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

示例1: test_is_built

# 需要导入模块: from txtorcon import Circuit [as 别名]
# 或者: from txtorcon.Circuit import when_built [as 别名]
    def test_is_built(self):
        tor = FakeTorController()
        a = FakeRouter('$E11D2B2269CC25E67CA6C9FB5843497539A74FD0', 'a')
        b = FakeRouter('$50DD343021E509EB3A5A7FD0D8A4F8364AFBDCB5', 'b')
        c = FakeRouter('$253DFF1838A2B7782BE7735F74E50090D46CA1BC', 'c')
        tor.routers['$E11D2B2269CC25E67CA6C9FB5843497539A74FD0'] = a
        tor.routers['$50DD343021E509EB3A5A7FD0D8A4F8364AFBDCB5'] = b
        tor.routers['$253DFF1838A2B7782BE7735F74E50090D46CA1BC'] = c

        circuit = Circuit(tor)
        circuit.listen(tor)

        circuit.update('123 EXTENDED $E11D2B2269CC25E67CA6C9FB5843497539A74FD0=eris,$50DD343021E509EB3A5A7FD0D8A4F8364AFBDCB5=venus,$253DFF1838A2B7782BE7735F74E50090D46CA1BC=chomsky PURPOSE=GENERAL'.split())
        built0 = circuit.is_built
        built1 = circuit.when_built()

        self.assertTrue(built0 is not built1)
        self.assertFalse(built0.called)
        self.assertFalse(built1.called)

        circuit.update('123 BUILT $E11D2B2269CC25E67CA6C9FB5843497539A74FD0=eris,$50DD343021E509EB3A5A7FD0D8A4F8364AFBDCB5=venus,$253DFF1838A2B7782BE7735F74E50090D46CA1BC=chomsky PURPOSE=GENERAL'.split())

        # create callback when we're alread in BUILT; should be
        # callback'd already
        built2 = circuit.when_built()

        self.assertTrue(built2 is not built1)
        self.assertTrue(built2 is not built0)
        self.assertTrue(built0.called)
        self.assertTrue(built1.called)
        self.assertTrue(built2.called)
        self.assertTrue(built0.result == circuit)
        self.assertTrue(built1.result == circuit)
        self.assertTrue(built2.result == circuit)
开发者ID:david415,项目名称:txtorcon,代码行数:36,代码来源:test_circuit.py

示例2: test_is_built_errback

# 需要导入模块: from txtorcon import Circuit [as 别名]
# 或者: from txtorcon.Circuit import when_built [as 别名]
    def test_is_built_errback(self):
        tor = FakeTorController()
        a = FakeRouter('$E11D2B2269CC25E67CA6C9FB5843497539A74FD0', 'a')
        tor.routers['$E11D2B2269CC25E67CA6C9FB5843497539A74FD0'] = a

        state = TorState(tor)
        circuit = Circuit(tor)
        circuit.listen(tor)

        circuit.update('123 EXTENDED $E11D2B2269CC25E67CA6C9FB5843497539A74FD0=eris PURPOSE=GENERAL'.split())
        state.circuit_new(circuit)
        d = circuit.when_built()

        state.circuit_closed(circuit)

        self.assertTrue(d.called)
        self.assertTrue(isinstance(d.result, Failure))
开发者ID:david415,项目名称:txtorcon,代码行数:19,代码来源:test_circuit.py


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