在下面的脚本中,“a”全局设置为 TC-01,b 全局设置为“已通过”,但在执行时我可以获得“a”的值,但“b”的值我无法获得,所以请也为我提供有价值的想法来获得“b”的价值。
import HTML
import html2
from html2 import a,b
file = open('out.html', 'w')
# dictionary of test results, indexed by test id:
test_results = {
a: 'b',-----> In this only a value is take , b is not taking the value.
#'Testcase-005': 'success'
#'Testcase-005': 'error',
}
result_colors = {
'passed': 'lime',
'failed': 'red',
'error': 'yellow',
}
t = HTML.Table(header_row=['Testcase - ID', 'Result'])
for test_id in sorted(test_results):
#create the colored cell:
print test_results
color = result_colors[test_results[test_id]]
colored_result = HTML.TableCell(test_results[test_id], bgcolor=color)
#append the row with two cells:
t.rows.append([test_id, colored_result])
htmlcode = str(t)
c=htmlcode
print htmlcode
file.write(c)