1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
from htmltest import *
import pytest
@pytest.fixture(scope='function', autouse=True)
def html_tree():
return html_tree_from_env()
def assert_highlighted_text(element, expected_highlight, expected_text):
assert_tag(element, 'span')
assert_class(element, expected_highlight)
assert element.text == expected_text
def test_message(html_tree):
"""
Verify that the quoted text in the message has the correct
highlight colors.
"""
diag = get_diag_by_index(html_tree, 0)
msg = get_message_within_diag(diag)
assert_tag(msg[0], 'strong')
assert msg[0].text == 'warning: '
assert_tag(msg[1], 'span')
assert_class(msg[1], 'gcc-quoted-text')
assert_highlighted_text(msg[1][0], 'highlight-a', '%i')
assert_tag(msg[2], 'span')
assert_class(msg[2], 'gcc-quoted-text')
assert_highlighted_text(msg[2][0], 'highlight-a', 'int')
assert_tag(msg[3], 'span')
assert_class(msg[3], 'gcc-quoted-text')
assert_highlighted_text(msg[3][0], 'highlight-b', 'const char *')
def test_annotations(html_tree):
"""
Verify that the labels in the annotations have the correct
highlight colors.
"""
diag = get_diag_by_index(html_tree, 0)
locus = get_locus_within_diag(diag)
tbody = locus.find('xhtml:tbody', ns)
assert tbody.attrib['class'] == 'line-span'
rows = tbody.findall('xhtml:tr', ns)
# Source row
row = rows[0]
tds = row.findall('xhtml:td', ns)
assert len(tds) == 2
assert_class(tds[1], 'source')
assert_highlighted_text(tds[1][0], 'highlight-a', '%i')
assert_highlighted_text(tds[1][1], 'highlight-b', 'msg')
# Underline row:
row = rows[1]
tds = row.findall('xhtml:td', ns)
assert len(tds) == 2
assert_class(tds[1], 'annotation')
assert_highlighted_text(tds[1][0], 'highlight-a', '~^')
assert_highlighted_text(tds[1][1], 'highlight-b', '~~~')
# vline row:
row = rows[2]
tds = row.findall('xhtml:td', ns)
assert len(tds) == 2
assert_class(tds[1], 'annotation')
assert_highlighted_text(tds[1][0], 'highlight-a', '|')
assert_highlighted_text(tds[1][1], 'highlight-b', '|')
# Label row:
row = rows[3]
tds = row.findall('xhtml:td', ns)
assert len(tds) == 2
assert_class(tds[1], 'annotation')
assert_highlighted_text(tds[1][0], 'highlight-a', 'int')
assert_highlighted_text(tds[1][1], 'highlight-b', 'const char *')
|