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


Python HtmlWriter.start方法代碼示例

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


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

示例1: HtmlFileWriter

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import start [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: _download_and_format_issues

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import start [as 別名]
def _download_and_format_issues():
    try:
        from robot.utils import HtmlWriter, html_format
    except ImportError:
        sys.exit('creating release requires Robot Framework to be installed.')
    URL = Template('http://code.google.com/p/robotframework-ride/issues/csv?'
                   'sort=priority+type&colspec=ID%20Type%20Priority%20Summary'
                   '&q=target%3A${version}&can=1')
    reader = csv.reader(urlopen(URL.substitute({'version': VERSION})))
    total_issues = 0
    writer = HtmlWriter(StringIO())
    writer.element('h2', 'Release notes for %s' % VERSION)
    writer.start('table', attrs={'border': '1'})
    for row in reader:
        if not row or row[1] == 'Task':
            continue
        row = row[:4]
        writer.start('tr')
        if reader.line_num == 1:
            row = [ '*%s*' % cell for cell in row ]
        else:
            row[0] = '<a href="http://code.google.com/p/robotframework-ride/'\
                     'issues/detail?id=%s">Issue %s</a>' % (row[0], row[0])
            total_issues += 1
        for cell in row:
            if reader.line_num == 1:
                cell = html_format(cell)
            writer.element('td', cell, escape=False)
        writer.end('tr')
    writer.end('table')
    writer.element('p', 'Altogether %d issues.' % total_issues)
    return writer.output.getvalue()
開發者ID:lostmouse,項目名稱:RIDE,代碼行數:34,代碼來源:pavement.py

示例3: test_line_separator

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import start [as 別名]
 def test_line_separator(self):
     output = StringIO()
     writer = HtmlWriter(output)
     writer.start('b')
     writer.end('b')
     writer.element('i')
     assert_equal(repr(output.getvalue()), repr('<b>\n</b>\n<i></i>\n'))
開發者ID:koonchaim,項目名稱:robotframework,代碼行數:9,代碼來源:test_htmlwriter.py

示例4: _test_encoding

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import start [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

示例5: _test_line_separator

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import start [as 別名]
 def _test_line_separator(self, linesep):
     output = StringIO()
     writer = HtmlWriter(output, line_separator=linesep)
     writer.start('b')
     writer.end('b')
     writer.element('i')
     expected = '<b>%(LS)s</b>%(LS)s<i></i>%(LS)s' % {'LS': linesep}
     assert_equals(repr(output.getvalue()), repr(expected))
開發者ID:Senseg,項目名稱:robotframework,代碼行數:10,代碼來源:test_htmlwriter.py

示例6: test_non_ascii

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import start [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

示例7: _download_and_format_issues

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import start [as 別名]
def _download_and_format_issues():
    try:
        from robot.utils import HtmlWriter, html_format
    except ImportError:
        sys.exit('creating release requires Robot Framework to be installed.')
    writer = HtmlWriter(StringIO())
    writer.element('h2', 'Release notes for %s' % VERSION)
    writer.start('table', attrs={'border': '1'})
    writer.start('tr')
    for header in ['ID', 'Type', 'Priority', 'Summary']:
        writer.element(
            'td', html_format('*{}*'.format(header)), escape=False)
    writer.end('tr')
    issues = list(_get_issues())
    for issue in issues:
        writer.start('tr')
        link_tmpl = '<a href="http://github.com/robotframework/RIDE/issues/{0}">Issue {0}</a>'
        row = [link_tmpl.format(issue.number),
               find_type(issue),
               find_priority(issue),
               issue.title]
        for cell in row:
            writer.element('td', cell, escape=False)
        writer.end('tr')
    writer.end('table')
    writer.element('p', 'Altogether %d issues.' % len(issues))
    return writer.output.getvalue()
開發者ID:leeloveying,項目名稱:RIDE,代碼行數:29,代碼來源:pavement.py

示例8: DiffReporter

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import start [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

示例9: _download_and_format_issues

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import start [as 別名]
def _download_and_format_issues():
    try:
        from robot.utils import HtmlWriter, html_format
    except ImportError:
        sys.exit("creating release requires Robot Framework to be installed.")
    writer = HtmlWriter(StringIO())
    writer.element("h2", "Release notes for %s" % VERSION)
    writer.start("table", attrs={"border": "1"})
    writer.start("tr")
    for header in ["ID", "Type", "Priority", "Summary"]:
        writer.element("td", html_format("*{}*".format(header)), escape=False)
    writer.end("tr")
    issues = _get_issues()
    for issue in issues:
        writer.start("tr")
        link_tmpl = '<a href="http://github.com/robotframework/RIDE/issues/{0}">Issue {0}</a>'
        row = [link_tmpl.format(issue.number), _find_type(issue), _find_priority(issue), issue.title]
        for cell in row:
            writer.element("td", cell, escape=False)
        writer.end("tr")
    writer.end("table")
    writer.element("p", "Altogether %d issues." % len(issues))
    return writer.output.getvalue()
開發者ID:pskpg86,項目名稱:RIDE,代碼行數:25,代碼來源:tasks.py

示例10: TestHtmlWriter

# 需要導入模塊: from robot.utils import HtmlWriter [as 別名]
# 或者: from robot.utils.HtmlWriter import start [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.start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。