Fix tagre tests.
This commit is contained in:
parent
e81d804007
commit
7c471afe7b
2 changed files with 57 additions and 2 deletions
56
tests/make_table.py
Normal file
56
tests/make_table.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/python
|
||||
import sys
|
||||
import codecs
|
||||
|
||||
HTML_START = """<!DOCTYPE html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Dosage comic status</title>
|
||||
</head>
|
||||
<body>
|
||||
"""
|
||||
|
||||
HTML_END = """
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
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('<table><th><td>Name</td><td>Status</td></th>\n')
|
||||
for name, failed in tests:
|
||||
status = failed and "broken" or "ok"
|
||||
fp.write('<tr><td>%s</td><td>%s</td></tr>\n' % (name, status))
|
||||
fp.write('</table>\n')
|
||||
fp.write(HTML_END)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue