Fix tagre tests.
This commit is contained in:
parent
ecfc88faf1
commit
979c97901b
2 changed files with 5 additions and 4 deletions
|
@ -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):
|
||||||
|
|
|
@ -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))
|
||||||
|
|
Loading…
Reference in a new issue