From 979c97901be63bc6a1af52ba74af97be7b46f8bf Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Thu, 11 Oct 2012 17:02:40 +0200 Subject: [PATCH] Fix tagre tests. --- dosagelib/util.py | 2 +- tests/test_util.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dosagelib/util.py b/dosagelib/util.py index c3ea71748..20f9ad906 100644 --- a/dosagelib/util.py +++ b/dosagelib/util.py @@ -45,7 +45,7 @@ def tagre(tag, attribute, value, quote='"'): value=value, 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): diff --git a/tests/test_util.py b/tests/test_util.py index 089d98ef2..dcb67be37 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -76,9 +76,10 @@ class RegexTest(TestCase): self.match_tag(matcher, tag, value, domatch) def match_tag(self, matcher, tag, value, domatch=True): - match = matcher.match(tag % value) + text = tag % value + match = matcher.search(text) if domatch: - self.assertTrue(match) + self.assertTrue(match, "%s should match %s" % (matcher.pattern, text)) self.assertEqual(match.group(1), value) else: - self.assertFalse(match) + self.assertFalse(match, "%s should not match %s" % (matcher.pattern, text))