Exemplo n.º 1
0
 def test_re_compatibility(self):
     """Test compatibility with the Python re library"""
     #
     cm = cffi_re2.search(r'a(b+)', "abbc")
     rm = pyre.search(r'a(b+)', "abbc")
     assert_equal(cm.groups(), rm.groups())
     #
     cm = cffi_re2.match(r'b+', 'abbcd')
     rm = pyre.match(r'b+', 'abbcd')
     assert_equal(cm, rm)
     # Match without groups
     cm = cffi_re2.match(r'[abc]+', 'abbcd')
     rm = pyre.match(r'[abc]+', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     # Full match regex should match
     cm = cffi_re2.match(r'([abc]+)', 'abbcd')
     rm = pyre.match(r'([abc]+)', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     assert_equal(cm.group(0), rm.group(0))
     assert_equal(cm.group(1), rm.group(1))
     cm = cffi_re2.match(r'([ab]+)(c+)', 'abbcd')
     rm = pyre.match(r'([ab]+)(c+)', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     assert_equal(cm.group(0), rm.group(0))
     assert_equal(cm.group(1), rm.group(1))
     assert_equal(cm.group(2), rm.group(2))
Exemplo n.º 2
0
 def test_re_compatibility(self):
     """Test compatibility with the Python re library"""
     #
     cm = cffi_re2.search(r'a(b+)', "abbc")
     rm = pyre.search(r'a(b+)', "abbc")
     assert_equal(cm.groups(), rm.groups())
     #
     cm = cffi_re2.match(r'b+', 'abbcd')
     rm = pyre.match(r'b+', 'abbcd')
     assert_equal(cm, rm)
     # Match without groups
     cm = cffi_re2.match(r'[abc]+', 'abbcd')
     rm = pyre.match(r'[abc]+', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     # Full match regex should match
     cm = cffi_re2.match(r'([abc]+)', 'abbcd')
     rm = pyre.match(r'([abc]+)', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     assert_equal(cm.group(0), rm.group(0))
     assert_equal(cm.group(1), rm.group(1))
     cm = cffi_re2.match(r'([ab]+)(c+)', 'abbcd')
     rm = pyre.match(r'([ab]+)(c+)', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     assert_equal(cm.group(0), rm.group(0))
     assert_equal(cm.group(1), rm.group(1))
     assert_equal(cm.group(2), rm.group(2))
Exemplo n.º 3
0
 def test_module_level_functions(self):
     """
     Quick test of module-level functions.
     These are generally expected to call the compiled counterparts,
      so these tests do not check all aspects
     """
     assert_equal(cffi_re2.findall(r'a(b+)', "abbcdefabbbbca"), ["bb", "bbbb"])
     assert_equal(cffi_re2.sub(r'b+', '', 'abbcbbd'), 'acd')
     assert_is_not_none(cffi_re2.search(r'b+', 'abbcbbd'))
     assert_is_none(cffi_re2.match(r'b+', 'abbcbbd'))
     assert_is_not_none(cffi_re2.match(r'b+', 'bbbbb'))
Exemplo n.º 4
0
 def test_module_level_functions(self):
     """
     Quick test of module-level functions.
     These are generally expected to call the compiled counterparts,
      so these tests do not check all aspects
     """
     assert_equal(cffi_re2.findall(r'a(b+)', "abbcdefabbbbca"),
                  ["bb", "bbbb"])
     assert_equal(cffi_re2.sub(r'b+', '', 'abbcbbd'), 'acd')
     assert_is_not_none(cffi_re2.search(r'b+', 'abbcbbd'))
     assert_is_none(cffi_re2.match(r'b+', 'abbcbbd'))
     assert_is_not_none(cffi_re2.match(r'b+', 'bbbbb'))