本文整理汇总了Python中schedule.models.Event.get_occurrence方法的典型用法代码示例。如果您正苦于以下问题:Python Event.get_occurrence方法的具体用法?Python Event.get_occurrence怎么用?Python Event.get_occurrence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类schedule.models.Event
的用法示例。
在下文中一共展示了Event.get_occurrence方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_occurrence
# 需要导入模块: from schedule.models import Event [as 别名]
# 或者: from schedule.models.Event import get_occurrence [as 别名]
def test_get_occurrence(self):
event = Event(**self.recurring_data)
event.save()
occurrence = event.get_occurrence(datetime.datetime(2008, 1, 5, 8, 0))
self.assertEqual(occurrence.start, datetime.datetime(2008,1,5,8))
occurrence.save()
occurrence = event.get_occurrence(datetime.datetime(2008, 1, 5, 8, 0))
self.assertTrue(occurrence.pk is not None)
示例2: test_prevent_type_error_when_comparing_naive_and_aware_dates
# 需要导入模块: from schedule.models import Event [as 别名]
# 或者: from schedule.models.Event import get_occurrence [as 别名]
def test_prevent_type_error_when_comparing_naive_and_aware_dates(self):
# this only test if the TypeError is raised
event = Event(**self.recurring_data)
event.save()
naive_date = datetime.datetime(2008, 1, 20, 0, 0)
self.assertIsNone(event.get_occurrence(naive_date))