本文整理汇总了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)
示例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)
示例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)