def test_between_match_in_search_at_end(self):
     self._test_unique_match(
         text='abracadabra',
         match=SearchReplaceMatch(
             SequenceMatch(
                 delete_action(LiteralMatch('r')),
                 mark_parens(BetweenMatch()),
             ),
         ),
         expected_solution={'text': 'ab(acadab)(a)', 'matched_text': '', 'position': 0})
Exemple #2
0
 def test_no_match(self):
     self._test_rule(
         text='abc 123',
         rule=Rule(
             SequenceMatch(
                 mark_parens(LiteralMatch('abc')),
                 delete_action(FormatMatch('ws')),
                 mark_braces(LiteralMatch('x')),
             ),
         ),
         expected_text='abc 123'
     )
 def test_basic(self):
     self._test_simple_text_action(
         'abracadabra',
         ApplyRuleSetAction(
             RuleSet(
                 Rule(
                     SequenceMatch(
                         BetweenMatch(),
                         delete_action(LiteralMatch('c')),
                     ),
                 ),
             ),
         ),
         'abraadabra'
     )
 def test_recursive_search_replace(self):
     self._test_unique_match(
         text='abracadabra',
         match=SearchReplaceMatch(
             SequenceMatch(
                 delete_action(LiteralMatch('r')),
                 SearchReplaceMatch(
                     MatchWithActions(
                         LiteralMatch('a'),
                         ReplaceByLiteralAction('i'),
                     ),
                 ),
             ),
         ),
         expected_solution={'text': 'abicidibi', 'matched_text': '', 'position': 0})
 def test_start_in_middle(self):
     self._test_unique_match(
         text='abracadabra',
         match=SearchReplaceMatch(delete_action(LiteralMatch('a'))),
         position=5,
         expected_solution={'text': 'abracdbr', 'matched_text': '', 'position': 5})
 def test_basic(self):
     self._test_unique_match(
         text='abracadabra',
         match=SearchReplaceMatch(delete_action(LiteralMatch('a'))),
         expected_solution={'text': 'brcdbr', 'matched_text': '', 'position': 0})