From 7c471afe7b067eb0a230b758dcd850914c5fcdc5 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Thu, 11 Oct 2012 14:19:31 +0200 Subject: [PATCH] Fix tagre tests. --- tests/make_table.py | 56 +++++++++++++++++++++++++++++++++++++++++++++ tests/test_util.py | 3 +-- 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 tests/make_table.py diff --git a/tests/make_table.py b/tests/make_table.py new file mode 100644 index 000000000..b48f83346 --- /dev/null +++ b/tests/make_table.py @@ -0,0 +1,56 @@ +#!/usr/bin/python +import sys +import codecs + +HTML_START = """ + + + + Dosage comic status + + +""" + +HTML_END = """ + +""" + + +def main(args=None): + if args is None: + args = sys.argv[1:] + filename = 'testresults.txt' + with open(filename) as fp: + tests = parse_test_data(fp) + output = 'table.html' + with codecs.open(output, 'w', 'utf-8') as fp: + render_test_data(tests, fp) + + +def get_comic_name(line): + return line.split('::')[1][4:] + + +def parse_test_data(fp): + data = [] + for line in fp: + if line.rstrip().endswith('::test_comic'): + name = get_comic_name(line) + failed = line.startswith('F') + data.append((name, failed)) + data.sort() + return data + + +def render_test_data(tests, fp): + fp.write(HTML_START) + fp.write('\n') + for name, failed in tests: + status = failed and "broken" or "ok" + fp.write('\n' % (name, status)) + fp.write('
NameStatus
%s%s
\n') + fp.write(HTML_END) + + +if __name__ == '__main__': + main() diff --git a/tests/test_util.py b/tests/test_util.py index 76de7c7d9..089d98ef2 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -71,7 +71,7 @@ class RegexTest(TestCase): ) def test_regex(self): - matcher = re.compile(tagre("img", "src", self.ValuePrefix+".*")) + matcher = re.compile(tagre("img", "src", "(%s.*)" % self.ValuePrefix)) for tag, value, domatch in self.TagTests: self.match_tag(matcher, tag, value, domatch) @@ -82,4 +82,3 @@ class RegexTest(TestCase): self.assertEqual(match.group(1), value) else: self.assertFalse(match) -