예제 #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'), ['--', '--', '-'])
예제 #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")])
예제 #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")])
예제 #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'),
                  ['--', '--', '-'])
예제 #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'))
예제 #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'))
예제 #7
0
 def test_optional_groups(self):
     assert_equal(cffi_re2.findall(r"(foo)?bar", "bar"), [''])
예제 #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"),
                  [])
예제 #9
0
 def test_optional_groups(self):
     assert_equal(cffi_re2.findall(r"(foo)?bar", "bar"), [''])
예제 #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"), [])