本文整理汇总了Python中interpreter.Interpreter._parse_subject方法的典型用法代码示例。如果您正苦于以下问题:Python Interpreter._parse_subject方法的具体用法?Python Interpreter._parse_subject怎么用?Python Interpreter._parse_subject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interpreter.Interpreter
的用法示例。
在下文中一共展示了Interpreter._parse_subject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InterpreterTest
# 需要导入模块: from interpreter import Interpreter [as 别名]
# 或者: from interpreter.Interpreter import _parse_subject [as 别名]
#.........这里部分代码省略.........
arrow.get(2000, 1, 1).datetime, timedelta(days=-1), None)
self.assertEqual(expected, actual)
expected = arrow.get(2000, 1, 1, 2, 5).datetime
actual = self.interpreter._get_new_datetime(
arrow.get(2000, 1, 1).datetime, None, time(hour=2, minute=5))
self.assertEqual(expected, actual)
expected = arrow.get(2000, 1, 2, 2, 5).datetime
actual = self.interpreter._get_new_datetime(
arrow.get(2000, 1, 1, 0, 0, 0).datetime, timedelta(days=1),
time(hour=2, minute=5))
self.assertEqual(expected, actual)
expected = arrow.get(1999, 12, 31, 23, 55).datetime
actual = self.interpreter._get_new_datetime(
arrow.get(2000, 1, 1).datetime, timedelta(days=-1),
time(hour=23, minute=55))
self.assertEqual(expected, actual)
def test_get_datetime_from_token(self):
expected = arrow.get(2014, 1, 15, 12, 0).datetime
actual = self.interpreter._get_datetime_from_token('S1+9D')
self.assertEqual(expected, actual)
expected = arrow.get(2014, 1, 6, 22, 0).datetime
actual = self.interpreter._get_datetime_from_token('S1+10h')
self.assertEqual(expected, actual)
expected = arrow.get(2014, 1, 16, 12, 0).datetime
actual = self.interpreter._get_datetime_from_token('S1+10D')
self.assertEqual(expected, actual)
def test_get_subject(self):
tokens = self.interpreter._split_line('MQ1 S1 S1F')
actual = self.interpreter._parse_subject(tokens)['id']
self.assertEqual('4271', actual)
tokens = self.interpreter._split_line('MQ2 S1 S1F')
actual = self.interpreter._parse_subject(tokens)['id']
self.assertEqual('4272', actual)
tokens = self.interpreter._split_line('MQ3 S1 S1F')
actual = self.interpreter._parse_subject(tokens)['id']
self.assertEqual('4273', actual)
def test_handle_invalid_subject(self):
# Seminars can't be used as subject
tokens = self.interpreter._split_line('S1 Q1 Q1F')
self.assertRaises(
InvalidSubjectException,
self.interpreter._parse_subject, tokens)
# Practica can't be used as subject
tokens = self.interpreter._split_line('P1 Q1 Q1F')
self.assertRaises(
InvalidSubjectException,
self.interpreter._parse_subject, tokens)
def test_get_new_event_from_string(self):
expected_s = arrow.get(
2014, 1, 6, 7, tzinfo=tz.gettz('America/Montreal')).datetime
expected_e = arrow.get(
2014, 1, 6, 8, tzinfo=tz.gettz('America/Montreal')).datetime
actual = self.interpreter.get_new_event_from_string('MQ1 S1S S1F')
actual_s = actual.get_start_datetime()
actual_e = actual.get_end_datetime()
self.assertEqual(expected_s, actual_s)
示例2: InterpreterTest
# 需要导入模块: from interpreter import Interpreter [as 别名]
# 或者: from interpreter.Interpreter import _parse_subject [as 别名]
#.........这里部分代码省略.........
actual = self.interpreter._get_new_datetime(arrow.get(2000, 1, 1).datetime, timedelta(minutes=1), None)
self.assertEqual(expected, actual)
expected = arrow.get(2000, 1, 1).datetime
actual = self.interpreter._get_new_datetime(arrow.get(2000, 1, 1, 0, 2).datetime, timedelta(minutes=-2), None)
self.assertEqual(expected, actual)
expected = arrow.get(2000, 1, 1, 3).datetime
actual = self.interpreter._get_new_datetime(arrow.get(2000, 1, 1).datetime, timedelta(hours=3), None)
self.assertEqual(expected, actual)
expected = arrow.get(1999, 12, 31).datetime
actual = self.interpreter._get_new_datetime(arrow.get(2000, 1, 1).datetime, timedelta(days=-1), None)
self.assertEqual(expected, actual)
expected = arrow.get(2000, 1, 1, 2, 5).datetime
actual = self.interpreter._get_new_datetime(arrow.get(2000, 1, 1).datetime, None, time(hour=2, minute=5))
self.assertEqual(expected, actual)
expected = arrow.get(2000, 1, 2, 2, 5).datetime
actual = self.interpreter._get_new_datetime(
arrow.get(2000, 1, 1, 0, 0, 0).datetime, timedelta(days=1), time(hour=2, minute=5)
)
self.assertEqual(expected, actual)
expected = arrow.get(1999, 12, 31, 23, 55).datetime
actual = self.interpreter._get_new_datetime(
arrow.get(2000, 1, 1).datetime, timedelta(days=-1), time(hour=23, minute=55)
)
self.assertEqual(expected, actual)
def test_get_subject(self):
tokens = self.interpreter._split_line("Q1 S1 S1F")
actual = self.interpreter._parse_subject(tokens)["id"]
self.assertEqual("4271", actual)
tokens = self.interpreter._split_line("Q2 S1 S1F")
actual = self.interpreter._parse_subject(tokens)["id"]
self.assertEqual("4272", actual)
tokens = self.interpreter._split_line("Q3 S1 S1F")
actual = self.interpreter._parse_subject(tokens)["id"]
self.assertEqual("4273", actual)
def test_get_new_event_from_string(self):
expected_s = arrow.get(2014, 1, 6, 7, tzinfo=tz.gettz("America/Montreal")).datetime
expected_e = arrow.get(2014, 1, 6, 8, tzinfo=tz.gettz("America/Montreal")).datetime
actual = self.interpreter.get_new_event_from_string("Q1 S1S S1F")
actual_s = actual.get_start_datetime()
actual_e = actual.get_end_datetime()
self.assertEqual(expected_s, actual_s)
self.assertEqual(expected_e, actual_e)
expected_s = arrow.get(2014, 1, 13, 7, tzinfo=tz.gettz("America/Montreal")).datetime
expected_e = arrow.get(2014, 1, 20, 8, tzinfo=tz.gettz("America/Montreal")).datetime
actual = self.interpreter.get_new_event_from_string("Q1 S2 S3F")
actual_s = actual.get_start_datetime()
actual_e = actual.get_end_datetime()
self.assertEqual(expected_s, actual_s)
self.assertEqual(expected_e, actual_e)
expected_s = arrow.get(2014, 1, 13, 7, tzinfo=tz.gettz("America/Montreal")).datetime
expected_e = arrow.get(2014, 1, 20, 8, tzinfo=tz.gettz("America/Montreal")).datetime
actual = self.interpreter.get_new_event_from_string("H1 S2 S3F")
actual_s = actual.get_start_datetime()
actual_e = actual.get_end_datetime()