def test_only_first_between_match_in_sequence_expands(self): self._test_unique_match( text='Some text', match=SequenceMatch( mark_parens(BetweenMatch()), mark_braces(BetweenMatch()), mark_curlies(BetweenMatch()), EndAnchorMatch(), ), expected_solution={'matched_text': '(Some text)[]{}', 'position': 9})
def test_pattern_matches_are_anchors(self): self._test_unique_match( text='abcdefghi', match=SequenceMatch( mark_parens(BetweenMatch()), LiteralMatch('d'), mark_braces(BetweenMatch()), LiteralMatch('g'), mark_curlies(BetweenMatch()), EndAnchorMatch(), ), expected_solution={'matched_text': '(abc)d[ef]g{hi}', 'position': 9})
def test_insert_matches_are_not_anchors(self): self._test_unique_match( text='Some text', match=SequenceMatch( mark_parens(BetweenMatch()), InsertLiteralMatch('1'), mark_braces(BetweenMatch()), InsertLiteralMatch('2'), mark_curlies(BetweenMatch()), EndAnchorMatch(), ), expected_solution={'matched_text': '(Some text)1[]2{}', 'position': 9})
def test_optional_match(self): match = SequenceMatch( mark_parens(FormatMatch('s')), mark_braces(RepeatMatch(FormatMatch('d'), 0, 1)), mark_curlies(FormatMatch('s')), EndAnchorMatch(), ) self._test_unique_match( text='Time 2 Die', match=match, expected_solution={'matched_text': '(Time) [2] {Die}', 'position': 10}) self._test_unique_match( text='Time Die', match=match, expected_solution={'matched_text': '(Time)[] {Die}', 'position': 8}) self._test_unique_match( text='Time 2', match=match, expected_solution={'matched_text': '(Time)[] {2}', 'position': 6})