コード例 #1
0
ファイル: test_regexp.py プロジェクト: jpalandri/chorddb
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
ファイル: test_regexp.py プロジェクト: jpalandri/chorddb
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
ファイル: test_regexp.py プロジェクト: jpalandri/chorddb
def re_search_test():
    ''' Basic re_search test '''
    regexp = r'a\d'
    ok_(re_search(regexp, "a1"))
    ok_(re_search(regexp, "ba12"))
コード例 #4
0
ファイル: test_regexp.py プロジェクト: jpalandri/chorddb
def failed_re_search(pattern, string, flags=0):
    return re_search(pattern, string, flags=flags)