if matched_str: assert m print "yeah hit" assert m == matched_str, "%s != %s" % (m, matched_str) print "match is correct" assert i == c + len(matched_str) print "iterator incremented correct amount" assert attr.value == attrval, 'got attr.value "%s" expected "%s"' % (attr.value, attrval) else: assert i == c print "verified iterator not changed" tests = [('', end_p, '', None), ('012xyz', int_p, '012', 12), ('xyz012', int_p, False, None), ('xy', ch_p('x'), 'x', 'x'), ('yx', ch_p('x'), False, None), ('y', ch_p('y') >> end_p, 'y', ('y',None)), ('yx', ch_p('y') >> end_p, False, None), ('abdxx', ch_p('a') >> ch_p('b').opt >> ch_p('d'), 'abd', (('a', 'b'), 'd')), ('adxx', ch_p('a') >> ch_p('b').opt >> ch_p('d'), 'ad', (('a', None), 'd')), ('arx', ch_p('a') >> (ch_p('s') | ch_p('r')) >> ch_p('x'), 'arx', (('a', 'r'), ('x'))), ('asx', ch_p('a') >> (ch_p('s') | ch_p('r')) >> ch_p('x'), 'asx', (('a', 's'), ('x'))), ('avx', ch_p('a') >> (ch_p('s') | ch_p('r')) >> ch_p('x'), False, None), ('xxxxxxx', ch_p('x').star, 'xxxxxxx', (['x', 'x', 'x', 'x', 'x', 'x', 'x'])),
assert m == matched_str, "%s != %s" % (m, matched_str) print "match is correct" assert i == c + len(matched_str) print "iterator incremented correct amount" assert attr.value == attrval, 'got attr.value "%s" expected "%s"' % (attr.value, attrval) else: assert i == c print "verified iterator not changed" tests = [('', end_p, '', None), ('012xyz', int_p, '012', 12), ('xyz012', int_p, False, None), ('xy', ch_p('x'), 'x', 'x'), ('yx', ch_p('x'), False, None), ('y', ch_p('y') >> end_p, 'y', ('y',)), ('yx', ch_p('y') >> end_p, False, None), ('abdxx', ch_p('a') >> ch_p('b').opt >> ch_p('d'), 'abd', ('a', 'b', 'd')), ('adxx', ch_p('a') >> ch_p('b').opt >> ch_p('d'), 'ad', ('a', 'd')), ('arx', ch_p('a') >> (ch_p('s') | ch_p('r')) >> ch_p('x'), 'arx', ('a', 'r', 'x')),