Exemplo n.º 1
0
 def test_findall_overlapping(self):
     """Check overlapping matches with findall"""
     # Prerequisited
     assert_equal(cffi_re2.findall(r'-{1,2}', 'program-files'), ['-'])
     assert_equal(cffi_re2.findall(r'-{1,2}', 'pro--gram-files'), ['--', '-'])
     assert_equal(cffi_re2.findall(r'-{1,2}', 'pro---gram-files'), ['--', '-', '-'])
     # Actual test
     assert_equal(cffi_re2.findall(r'-{1,2}', 'pro----gram-files'), ['--', '--', '-'])
Exemplo n.º 2
0
 def test_findall_subgroups(self):
     mo = cffi_re2.findall(r'ab+', "abbcdefabbbbca")
     assert_equal(mo, ["abb", "abbbb"])
     mo = cffi_re2.findall(r'a(b+)', "abbcdefabbbbca")
     assert_equal(mo, ["bb", "bbbb"])
     mo = cffi_re2.findall(r'(a)(b+)', "abbcdefabbbbca")
     assert_equal(mo, [("a", "bb"), ("a", "bbbb")])
     mo = cffi_re2.findall(r'(a)(b)(b+)', "abbcdefabbbbca")
     assert_equal(mo, [("a", "b", "b"), ("a", "b", "bbb")])
Exemplo n.º 3
0
 def test_findall_subgroups(self):
     mo = cffi_re2.findall(r'ab+', "abbcdefabbbbca")
     assert_equal(mo, ["abb", "abbbb"])
     mo = cffi_re2.findall(r'a(b+)', "abbcdefabbbbca")
     assert_equal(mo, ["bb", "bbbb"])
     mo = cffi_re2.findall(r'(a)(b+)', "abbcdefabbbbca")
     assert_equal(mo, [("a", "bb"), ("a", "bbbb")])
     mo = cffi_re2.findall(r'(a)(b)(b+)', "abbcdefabbbbca")
     assert_equal(mo, [("a", "b", "b"), ("a", "b", "bbb")])
Exemplo n.º 4
0
 def test_findall_overlapping(self):
     """Check overlapping matches with findall"""
     # Prerequisited
     assert_equal(cffi_re2.findall(r'-{1,2}', 'program-files'), ['-'])
     assert_equal(cffi_re2.findall(r'-{1,2}', 'pro--gram-files'),
                  ['--', '-'])
     assert_equal(cffi_re2.findall(r'-{1,2}', 'pro---gram-files'),
                  ['--', '-', '-'])
     # Actual test
     assert_equal(cffi_re2.findall(r'-{1,2}', 'pro----gram-files'),
                  ['--', '--', '-'])
Exemplo n.º 5
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.º 6
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.º 7
0
 def test_optional_groups(self):
     assert_equal(cffi_re2.findall(r"(foo)?bar", "bar"), [''])
Exemplo n.º 8
0
 def test_more_x(self):
     assert_is_none(cffi_re2.search(r"<(a|span|div|table)", "Kapazitäten"))
     assert_equal(cffi_re2.findall(r"<(a|span|div|table)", "Kapazitäten"),
                  [])
Exemplo n.º 9
0
 def test_optional_groups(self):
     assert_equal(cffi_re2.findall(r"(foo)?bar", "bar"), [''])
Exemplo n.º 10
0
 def test_more_x(self):
     assert_is_none(cffi_re2.search(r"<(a|span|div|table)", "Kapazitäten"))
     assert_equal(cffi_re2.findall(r"<(a|span|div|table)", "Kapazitäten"), [])