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


Python Circuit.age方法代码示例

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


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

示例1: test_no_age_yet

# 需要导入模块: from txtorcon import Circuit [as 别名]
# 或者: from txtorcon.Circuit import age [as 别名]
    def test_no_age_yet(self):
        """
        make sure age doesn't explode if there's no TIME_CREATED flag.
        """
        tor = FakeTorController()

        circuit = Circuit(tor)
        now = datetime.datetime.now()
        circuit.update('1 LAUNCHED PURPOSE=GENERAL'.split())
        self.assertTrue(circuit.time_created is None)
        diff = circuit.age(now=now)
        self.assertEquals(diff, None)
开发者ID:david415,项目名称:txtorcon,代码行数:14,代码来源:test_circuit.py

示例2: test_age

# 需要导入模块: from txtorcon import Circuit [as 别名]
# 或者: from txtorcon.Circuit import age [as 别名]
    def test_age(self):
        """
        make sure age does something sensible at least once.
        """
        tor = FakeTorController()

        circuit = Circuit(tor)
        now = datetime.datetime.now()
        update = '1 LAUNCHED PURPOSE=GENERAL TIME_CREATED=%s' % time.strftime('%Y-%m-%dT%H:%M:%S')
        circuit.update(update.split())
        diff = circuit.age(now=now)
        self.assertEquals(diff, 0)
        self.assertTrue(circuit.time_created is not None)
开发者ID:david415,项目名称:txtorcon,代码行数:15,代码来源:test_circuit.py

示例3: test_age_default

# 需要导入模块: from txtorcon import Circuit [as 别名]
# 或者: from txtorcon.Circuit import age [as 别名]
    def test_age_default(self, fake_datetime):
        """
        age() w/ defaults works properly
        """
        from datetime import datetime
        now = datetime.fromtimestamp(60.0)
        fake_datetime.return_value = now
        fake_datetime.utcnow = Mock(return_value=now)
        tor = FakeTorController()

        circuit = Circuit(tor)
        circuit._time_created = datetime.fromtimestamp(0.0)
        self.assertEquals(circuit.age(), 60)
        self.assertTrue(circuit.time_created is not None)
开发者ID:david415,项目名称:txtorcon,代码行数:16,代码来源:test_circuit.py


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