当前位置: 首页>>代码示例>>Python>>正文


Python StringIO.getvalue方法代码示例

本文整理汇总了Python中robot.utils.StringIO.getvalue方法的典型用法代码示例。如果您正苦于以下问题:Python StringIO.getvalue方法的具体用法?Python StringIO.getvalue怎么用?Python StringIO.getvalue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在robot.utils.StringIO的用法示例。


在下文中一共展示了StringIO.getvalue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_line_separator

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [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

示例2: get_lines

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
def get_lines(suite=(), strings=(), basemillis=100, start_block='',
              end_block='', split_threshold=9999, min_level='INFO'):
    output = StringIO()
    data = JsExecutionResult(suite, None, None, strings, basemillis, min_level=min_level)
    writer = JsResultWriter(output, start_block, end_block, split_threshold)
    writer.write(data, settings={})
    return output.getvalue().splitlines()
开发者ID:moto-timo,项目名称:robotframework,代码行数:9,代码来源:test_jswriter.py

示例3: test_dont_register_signal_handlers_then_run_on_thread

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
 def test_dont_register_signal_handlers_then_run_on_thread(self):
     stream = StringIO()
     thread = threading.Thread(target=run_without_outputs, args=(self.data,),
                               kwargs=dict(stdout=stream, stderr=stream))
     thread.start()
     thread.join()
     output = stream.getvalue()
     assert_true('ERROR' not in output.upper(), 'Errors:\n%s' % output)
开发者ID:moto-timo,项目名称:robotframework,代码行数:10,代码来源:test_run_and_rebot.py

示例4: test_json_dump_mapping

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
 def test_json_dump_mapping(self):
     output = StringIO()
     dumper = JsonDumper(output)
     mapped1 = object()
     mapped2 = "string"
     dumper.dump([mapped1, [mapped2, {mapped2: mapped1}]], mapping={mapped1: "1", mapped2: "a"})
     assert_equal(output.getvalue(), "[1,[a,{a:1}]]")
     assert_raises(ValueError, dumper.dump, [mapped1])
开发者ID:robotframework,项目名称:robotframework,代码行数:10,代码来源:test_jsonwriter.py

示例5: test_configuring_number_of_separating_spaces

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
    def test_configuring_number_of_separating_spaces(self):
        output = StringIO()
        create_test_case_file().save(output=output, txt_separating_spaces=8)
        expected = """\
*** test case ***         some        and other
A test                    A kw        an arg
"""
        assert_equals(repr(expected), repr(output.getvalue()))
开发者ID:nurruden,项目名称:robotframework,代码行数:10,代码来源:test_filewriters.py

示例6: test_end_of_line_whitespace_is_removed

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
    def test_end_of_line_whitespace_is_removed(self):
        output = StringIO()
        create_test_case_file().save(output=output)
        expected = """\
*** test case ***     some    and other
A test                A kw    an arg
"""
        assert_equals(repr(expected), repr(output.getvalue()))
开发者ID:nurruden,项目名称:robotframework,代码行数:10,代码来源:test_filewriters.py

示例7: _MockLogger

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
class _MockLogger(object):
    def __init__(self):
        self._output = StringIO()

    def message(self, msg):
        self._output.write(msg.message)

    def value(self):
        return self._output.getvalue()
开发者ID:HelioGuilherme66,项目名称:robotframework,代码行数:11,代码来源:test_populator.py

示例8: test_json_dump_mapping

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
 def test_json_dump_mapping(self):
     output = StringIO()
     dumper = JsonDumper(output)
     mapped1 = object()
     mapped2 = 'string'
     dumper.dump([mapped1, [mapped2, {mapped2: mapped1}]],
                 mapping={mapped1: '1', mapped2: 'a'})
     assert_equal(output.getvalue(), '[1,[a,{a:1}]]')
     assert_raises(ValueError, dumper.dump, [mapped1])
开发者ID:synsun,项目名称:robotframework,代码行数:11,代码来源:test_jsonwriter.py

示例9: ClosableOutput

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
class ClosableOutput(object):

    def __init__(self, path):
        self._output = StringIO()
        self._path = path

    def __enter__(self):
        return self

    def __exit__(self, *args):
        self.close()

    def write(self, data):
        self._output.write(data)

    def close(self):
        self.value = self._output.getvalue()
        self._output.close()

    def __str__(self):
        return self._path
开发者ID:BanerjeeSandipan,项目名称:robotframework,代码行数:23,代码来源:test_reporting.py

示例10: _dump

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
 def _dump(self, data):
     output = StringIO()
     JsonDumper(output).dump(data)
     return output.getvalue()
开发者ID:robotframework,项目名称:robotframework,代码行数:6,代码来源:test_jsonwriter.py

示例11: _add_long_step_and_save

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
 def _add_long_step_and_save(self, format):
     data = create_test_case_file()
     data.testcase_table.tests[0].add_step(["A kw", "1", "2", "3", "4", "6", "7", "8"])
     output = StringIO()
     data.save(format=format, output=output)
     return output.getvalue().strip()
开发者ID:nurruden,项目名称:robotframework,代码行数:8,代码来源:test_filewriters.py

示例12: TestHtmlWriter

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [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):
        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'))

    def test_non_ascii(self):
        self.output = StringIO()
#.........这里部分代码省略.........
开发者ID:koonchaim,项目名称:robotframework,代码行数:103,代码来源:test_htmlwriter.py

示例13: test_combining_results

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
 def test_combining_results(self):
     output = StringIO()
     writer = TestableOutputWriter(output)
     ExecutionResult(GOLDEN_XML, GOLDEN_XML).visit(writer)
     self._assert_xml_content(self._xml_lines(output.getvalue()), self._xml_lines(GOLDEN_XML_TWICE))
开发者ID:RoyeeW,项目名称:robotframework,代码行数:7,代码来源:test_resultserializer.py

示例14: _xml_lines

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
 def _xml_lines(self, text):
     with ETSource(text) as source:
         tree = ET.parse(source)
     output = StringIO()
     tree.write(output)
     return output.getvalue().splitlines()
开发者ID:RoyeeW,项目名称:robotframework,代码行数:8,代码来源:test_resultserializer.py

示例15: test_single_result_serialization

# 需要导入模块: from robot.utils import StringIO [as 别名]
# 或者: from robot.utils.StringIO import getvalue [as 别名]
 def test_single_result_serialization(self):
     output = StringIO()
     writer = TestableOutputWriter(output)
     ExecutionResult(GOLDEN_XML).visit(writer)
     self._assert_xml_content(self._xml_lines(output.getvalue()), self._xml_lines(GOLDEN_XML))
开发者ID:RoyeeW,项目名称:robotframework,代码行数:7,代码来源:test_resultserializer.py


注:本文中的robot.utils.StringIO.getvalue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。