Fix tagre tests.

This commit is contained in:
Bastian Kleineidam 2012-10-11 17:02:40 +02:00
parent ecfc88faf1
commit 979c97901b
2 changed files with 5 additions and 4 deletions

View file

@ -45,7 +45,7 @@ def tagre(tag, attribute, value, quote='"'):
value=value, value=value,
quote=quote, quote=quote,
) )
return r'<\s*%(tag)s\s+[^>]*%(attribute)s\s*=\s*%(quote)s%(value)s%(quote)s[^>]*>' % attrs return r'<\s*%(tag)s\s+(?:[^>]*\s+)?%(attribute)s\s*=\s*%(quote)s%(value)s%(quote)s[^>]*>' % attrs
def case_insensitive_re(name): def case_insensitive_re(name):

View file

@ -76,9 +76,10 @@ class RegexTest(TestCase):
self.match_tag(matcher, tag, value, domatch) self.match_tag(matcher, tag, value, domatch)
def match_tag(self, matcher, tag, value, domatch=True): def match_tag(self, matcher, tag, value, domatch=True):
match = matcher.match(tag % value) text = tag % value
match = matcher.search(text)
if domatch: if domatch:
self.assertTrue(match) self.assertTrue(match, "%s should match %s" % (matcher.pattern, text))
self.assertEqual(match.group(1), value) self.assertEqual(match.group(1), value)
else: else:
self.assertFalse(match) self.assertFalse(match, "%s should not match %s" % (matcher.pattern, text))