本文整理匯總了Python中robot.utils.HtmlWriter.close方法的典型用法代碼示例。如果您正苦於以下問題:Python HtmlWriter.close方法的具體用法?Python HtmlWriter.close怎麽用?Python HtmlWriter.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類robot.utils.HtmlWriter
的用法示例。
在下文中一共展示了HtmlWriter.close方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DiffReporter
# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import close [as 別名]
class DiffReporter(object):
def __init__(self, outpath=None, title=None):
self.outpath = os.path.abspath(outpath or 'robotdiff.html')
self._title = title or 'Test Run Diff Report'
self._writer = HtmlWriter(open(self.outpath, 'w'))
def report(self, results):
self._start(results.column_names)
for row in results.rows:
self._write_row(row)
self._end()
def _start(self, columns):
self._writer.content(START_HTML % {'TITLE': self._title}, escape=False)
self._writer.start('tr')
self._writer.element('th', 'Name', {'class': 'col_name'})
for name in columns:
self._writer.element('th', name, {'class': 'col_status'})
self._writer.end('tr')
def _write_row(self, row):
self._writer.start('tr')
self._write_name(row)
for item in row:
self._write_status(item)
self._writer.end('tr')
def _write_name(self, row):
self._writer.element('td', row.name, {'class': 'col_name ' + row.status,
'title': row.explanation})
def _write_status(self, item):
self._writer.element('td', item.name,
{'class': 'col_status ' + item.status})
def _end(self):
for tag in 'table', 'body', 'html':
self._writer.end(tag)
self._writer.close()