def test_option_line_factory_from_text_block(): source_text = """\ # Starting with a comment importance :: a | b | c [ ] Some task Mary had a little lamb [x] This task has been finished # asdasd asdasd """ factory = OptionLineFactory() class_names = [] # print(source_text.splitlines()) for source_line in source_text.rstrip().splitlines(): line_obj = factory.make_line(source_line) class_names.append(line_obj.__class__.__name__) assert class_names == [ "CommentLine", "OptionLine", "TaskLine", "TaskContinuationLine", "TaskLine", "BlankLine", "BlankLine", "CommentLine", ]
def test_no_such_line_type(): factory = OptionLineFactory() with pytest.raises(OptionLineError) as exc: line_obj = factory.make_line("foo bar baz") assert exc.value.message.startswith("Unknown line type for option line")
def test_option_line_factory_individual_lines(source_line, class_name): factory = OptionLineFactory() # lines = [] line_obj = factory.make_line(source_line) assert line_obj.__class__.__name__ == class_name