本文整理匯總了Python中models.courses.Workflow._convert_date_string_to_datetime方法的典型用法代碼示例。如果您正苦於以下問題:Python Workflow._convert_date_string_to_datetime方法的具體用法?Python Workflow._convert_date_string_to_datetime怎麽用?Python Workflow._convert_date_string_to_datetime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.courses.Workflow
的用法示例。
在下文中一共展示了Workflow._convert_date_string_to_datetime方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_invalid_datetime
# 需要導入模塊: from models.courses import Workflow [as 別名]
# 或者: from models.courses.Workflow import _convert_date_string_to_datetime [as 別名]
def test_invalid_datetime(self):
"""Valid datetimes should be converted without problems."""
invalid_date_strs = [
'abc', '2012-13-31 12:30', '2012-12-31T12:30',
'2012-13-31 12:30+0100']
workflow = Workflow('')
for date_str in invalid_date_strs:
with self.assertRaises(Exception):
workflow._convert_date_string_to_datetime(date_str)
示例2: test_valid_datetime
# 需要導入模塊: from models.courses import Workflow [as 別名]
# 或者: from models.courses.Workflow import _convert_date_string_to_datetime [as 別名]
def test_valid_datetime(self):
"""Valid datetimes should be converted without problems."""
workflow = Workflow('')
date_obj = workflow._convert_date_string_to_datetime('2012-03-21 12:30')
self.assertEqual(date_obj.year, 2012)
self.assertEqual(date_obj.month, 3)
self.assertEqual(date_obj.day, 21)
self.assertEqual(date_obj.hour, 12)
self.assertEqual(date_obj.minute, 30)
示例3: test_no_timezone_set
# 需要導入模塊: from models.courses import Workflow [as 別名]
# 或者: from models.courses.Workflow import _convert_date_string_to_datetime [as 別名]
def test_no_timezone_set(self):
"""Parsed date strings should contain no timezone information."""
workflow = Workflow('')
date_obj = workflow._convert_date_string_to_datetime('2012-03-21 12:30')
self.assertIsNone(date_obj.tzinfo)