예제 #1
0
def strict_re_search_test():
    ''' Basic strict re_search test '''
    regexp = r'a\d'
    ok_(re_search(regexp, "a1"))
    ok_(re_search(strict(regexp), "a1"))
    yield failed_re_search, strict(regexp), "ba12"
    yield failed_re_search, strict(regexp), "ba1"
    yield failed_re_search, strict(regexp), "a12"
예제 #2
0
def no_match_error_fields_test():
    ''' Test for presense of NoMatchError members '''
    pattern = r'\d{2,3}'
    string = 'this has no numbers'
    try:
        re_search(pattern, string)
    except NoMatchError as err:
        eq_(err.pattern, pattern)
        eq_(err.string, string)
예제 #3
0
def re_search_test():
    ''' Basic re_search test '''
    regexp = r'a\d'
    ok_(re_search(regexp, "a1"))
    ok_(re_search(regexp, "ba12"))
예제 #4
0
def failed_re_search(pattern, string, flags=0):
    return re_search(pattern, string, flags=flags)