當前位置: 首頁>>代碼示例>>Python>>正文


Python HtmlWriter.content方法代碼示例

本文整理匯總了Python中robot.utils.HtmlWriter.content方法的典型用法代碼示例。如果您正苦於以下問題:Python HtmlWriter.content方法的具體用法?Python HtmlWriter.content怎麽用?Python HtmlWriter.content使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在robot.utils.HtmlWriter的用法示例。


在下文中一共展示了HtmlWriter.content方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: HtmlFileWriter

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import content [as 別名]
class HtmlFileWriter(_DataFileWriter):

    def __init__(self, configuration):
        formatter = HtmlFormatter(configuration.html_column_count)
        _DataFileWriter.__init__(self, formatter, configuration)
        self._name = configuration.datafile.name
        self._writer = HtmlWriter(configuration.output)

    def write(self, datafile):
        self._writer.content(TEMPLATE_START % {'NAME': self._name}, escape=False)
        _DataFileWriter.write(self, datafile)
        self._writer.content(TEMPLATE_END, escape=False)

    def _write_table(self, table, is_last):
        self._writer.start('table', {'id': table.type.replace(' ', ''),
                                     'border': '1'})
        _DataFileWriter._write_table(self, table, is_last)
        self._writer.end('table')

    def _write_row(self, row):
        self._writer.start('tr')
        for cell in row:
            self._writer.element(cell.tag, cell.content, cell.attributes,
                                 escape=False)
        self._writer.end('tr')
開發者ID:moto-timo,項目名稱:robotframework,代碼行數:27,代碼來源:filewriters.py

示例2: _test_encoding

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import content [as 別名]
 def _test_encoding(self, encoding):
     self.output = StringIO()
     writer = HtmlWriter(self.output, encoding=encoding)
     writer.start(u'p', attrs={'name': u'hyv\xe4\xe4'}, newline=False)
     writer.content(u'y\xf6')
     writer.element('i', u't\xe4', newline=False)
     writer.end('p', newline=False)
     self._verify(u'<p name="hyv\xe4\xe4">y\xf6<i>t\xe4</i></p>'.encode(encoding))
開發者ID:Senseg,項目名稱:robotframework,代碼行數:10,代碼來源:test_htmlwriter.py

示例3: test_non_ascii

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import content [as 別名]
 def test_non_ascii(self):
     self.output = StringIO()
     writer = HtmlWriter(self.output)
     writer.start(u'p', attrs={'name': u'hyv\xe4\xe4'}, newline=False)
     writer.content(u'y\xf6')
     writer.element('i', u't\xe4', newline=False)
     writer.end('p', newline=False)
     self._verify(u'<p name="hyv\xe4\xe4">y\xf6<i>t\xe4</i></p>')
開發者ID:koonchaim,項目名稱:robotframework,代碼行數:10,代碼來源:test_htmlwriter.py

示例4: DiffReporter

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import content [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()
開發者ID:Senseg,項目名稱:robotframework,代碼行數:42,代碼來源:robotdiff.py

示例5: TestHtmlWriter

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import content [as 別名]
class TestHtmlWriter(unittest.TestCase):

    def setUp(self):
        self.output = StringIO()
        self.writer = HtmlWriter(self.output)

    def test_start(self):
        self.writer.start('r')
        self._verify('<r>\n')

    def test_start_without_newline(self):
        self.writer.start('robot', newline=False)
        self._verify('<robot>')

    def test_start_with_attribute(self):
        self.writer.start('robot', {'name': 'Suite1'}, False)
        self._verify('<robot name="Suite1">')

    def test_start_with_attributes(self):
        self.writer.start('test', {'class': '123', 'x': 'y', 'a': 'z'})
        self._verify('<test a="z" class="123" x="y">\n')

    def test_start_with_non_ascii_attributes(self):
        self.writer.start('test', {'name': u'\xA7', u'\xE4': u'\xA7'})
        self._verify(u'<test name="\xA7" \xE4="\xA7">\n')

    def test_start_with_quotes_in_attribute_value(self):
        self.writer.start('x', {'q':'"', 'qs': '""""', 'a': "'"}, False)
        self._verify('<x a="\'" q="&quot;" qs="&quot;&quot;&quot;&quot;">')

    def test_start_with_html_in_attribute_values(self):
        self.writer.start('x', {'1':'<', '2': '&', '3': '</html>'}, False)
        self._verify('<x 1="&lt;" 2="&amp;" 3="&lt;/html&gt;">')

    def test_start_with_newlines_and_tabs_in_attribute_values(self):
        self.writer.start('x', {'1':'\n', '3': 'A\nB\tC', '2': '\t', '4': '\r\n'}, False)
        self._verify('<x 1="&#10;" 2="&#09;" 3="A&#10;B&#09;C" 4="&#13;&#10;">')

    def test_end(self):
        self.writer.start('robot', newline=False)
        self.writer.end('robot')
        self._verify('<robot></robot>\n')

    def test_end_without_newline(self):
        self.writer.start('robot', newline=False)
        self.writer.end('robot', newline=False)
        self._verify('<robot></robot>')

    def test_end_alone(self):
        self.writer.end('suite', newline=False)
        self._verify('</suite>')

    def test_content(self):
        self.writer.start('robot')
        self.writer.content('Hello world!')
        self._verify('<robot>\nHello world!')

    def test_content_with_non_ascii_data(self):
        self.writer.start('robot', newline=False)
        self.writer.content(u'Circle is 360\xB0. ')
        self.writer.content(u'Hyv\xE4\xE4 \xFC\xF6t\xE4!')
        self.writer.end('robot', newline=False)
        expected = u'Circle is 360\xB0. Hyv\xE4\xE4 \xFC\xF6t\xE4!'
        self._verify('<robot>%s</robot>' % expected)

    def test_multiple_content(self):
        self.writer.start('robot')
        self.writer.content('Hello world!')
        self.writer.content('Hi again!')
        self._verify('<robot>\nHello world!Hi again!')

    def test_content_with_chars_needing_escaping(self):
        self.writer.content('Me, "Myself" & I > U')
        self._verify('Me, "Myself" &amp; I &gt; U')

    def test_content_alone(self):
        self.writer.content('hello')
        self._verify('hello')

    def test_none_content(self):
        self.writer.start('robot')
        self.writer.content(None)
        self.writer.content('')
        self._verify('<robot>\n')

    def test_element(self):
        self.writer.element('div', 'content', {'id': '1'})
        self.writer.element('i', newline=False)
        self._verify('<div id="1">content</div>\n<i></i>')

    def test_line_separator(self):
        self._test_line_separator('\n')
        self._test_line_separator('LINESEP')

    def _test_line_separator(self, linesep):
        output = StringIO()
        writer = HtmlWriter(output, line_separator=linesep)
        writer.start('b')
        writer.end('b')
        writer.element('i')
#.........這裏部分代碼省略.........
開發者ID:Senseg,項目名稱:robotframework,代碼行數:103,代碼來源:test_htmlwriter.py


注:本文中的robot.utils.HtmlWriter.content方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。