def _test_matching_pattern(self, pattern, isvalidchar, unicode=False):
r = unicode_regex(pattern) if unicode else ascii_regex(pattern)
codepoints = six.moves.range(0, sys.maxunicode+1) \
if unicode else six.moves.range(1, 128)
for c in [six.unichr(x) for x in codepoints]:
if isvalidchar(c):
assert r.match(c), (
'"%s" supposed to match "%s" (%r, category "%s"), '
'but it doesnt' % (pattern, c, c, unicodedata.category(c))
)
else:
assert not r.match(c), (
'"%s" supposed not to match "%s" (%r, category "%s"), '
'but it does' % (pattern, c, c, unicodedata.category(c))
)
评论列表
文章目录