Example #1
0
    def __get_next_match(self, test_case, pos):
        with open(test_case, "r") as in_file:
            prog = in_file.read()

        config = self.__get_config()
        m = nestedmatcher.find(config["search"], prog, pos=pos, prefix=config["prefix"])

        return m
Example #2
0
 def test_1(self):
     m = find(BalancedExpr.parens, 'No match in this string!')
     self.assertIsNone(m)
Example #3
0
 def test_10(self):
     m = find(BalancedExpr.parens,
              '(This (string) contains) two nested matches!',
              pos=1)
     self.assertEqual(m, (6, 14))
Example #4
0
 def test_11(self):
     m = find(BalancedExpr.parens,
              '(This (string) contains) two nested matches!',
              prefix='This ')
     self.assertEqual(m, (1, 14))
Example #5
0
 def test_9(self):
     m = find(BalancedExpr.parens,
              '(This (string) contains) two nested matches!')
     self.assertEqual(m, (0, 24))
Example #6
0
 def test_8(self):
     m = find(BalancedExpr.parens,
              '(This string contains) two (simple matches)!')
     self.assertEqual(m, (0, 22))
Example #7
0
 def test_7(self):
     m = find(BalancedExpr.parens,
              '(This string contains) a simple match at the beginning!')
     self.assertEqual(m, (0, 22))
Example #8
0
 def test_6(self):
     m = find(BalancedExpr.parens,
              'This string contains a (simple match at the end!)')
     self.assertEqual(m, (23, 49))
Example #9
0
 def test_5(self):
     m = find(BalancedExpr.parens, 'This string contains a (simple match)!')
     self.assertEqual(m, (23, 37))