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


Python subunit.ProtocolTestCase方法代码示例

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


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

示例1: main

# 需要导入模块: import subunit [as 别名]
# 或者: from subunit import ProtocolTestCase [as 别名]
def main():
    if '--version' in sys.argv:
        print(__version__)
        exit(0)

    if len(sys.argv) < 2:
        print("Need at least one argument: path to subunit log.")
        exit(1)
    subunit_file = sys.argv[1]
    if len(sys.argv) > 2:
        html_file = sys.argv[2]
    else:
        html_file = 'results.html'

    html_result = HtmlOutput(html_file)
    stream = open(subunit_file, 'rb')

    # Feed the subunit stream through both a V1 and V2 parser.
    # Depends on having the v2 capable libraries installed.
    # First V2.
    # Non-v2 content and captured non-test output will be presented as file
    # segments called stdout.
    suite = subunit.ByteStreamToStreamResult(stream, non_subunit_name='stdout')
    # The HTML output code is in legacy mode.
    result = testtools.StreamToExtendedDecorator(html_result)
    # Divert non-test output
    accumulator = FileAccumulator()
    result = testtools.StreamResultRouter(result)
    result.add_rule(accumulator, 'test_id', test_id=None)
    result.startTestRun()
    suite.run(result)
    # Now reprocess any found stdout content as V1 subunit
    for bytes_io in accumulator.route_codes.values():
        bytes_io.seek(0)
        suite = subunit.ProtocolTestCase(bytes_io)
        suite.run(html_result)
    result.stopTestRun() 
开发者ID:openstack,项目名称:os-testr,代码行数:39,代码来源:subunit2html.py

示例2: run_tests

# 需要导入模块: import subunit [as 别名]
# 或者: from subunit import ProtocolTestCase [as 别名]
def run_tests(self, result_filter, input_stream=None):
        """Run tests through the given filter.

        :param result_filter: A filtering TestResult object.
        :param input_stream: Bytes of subunit stream data. If not provided,
            uses TestTestResultFilter.example_subunit_stream.
        """
        if input_stream is None:
            input_stream = self.example_subunit_stream
        test = subunit.ProtocolTestCase(BytesIO(input_stream))
        test.run(result_filter) 
开发者ID:byt3bl33d3r,项目名称:pth-toolkit,代码行数:13,代码来源:test_subunit_filter.py

示例3: setUp

# 需要导入模块: import subunit [as 别名]
# 或者: from subunit import ProtocolTestCase [as 别名]
def setUp(self):
        self.output = StringIO()
        self.result = subunit.TestResultStats(self.output)
        self.input_stream = BytesIO()
        self.test = subunit.ProtocolTestCase(self.input_stream) 
开发者ID:byt3bl33d3r,项目名称:pth-toolkit,代码行数:7,代码来源:test_subunit_stats.py

示例4: process_stream

# 需要导入模块: import subunit [as 别名]
# 或者: from subunit import ProtocolTestCase [as 别名]
def process_stream(self):
        """Read and process subunit data from a stream."""
        with open(self.in_stream, 'r') as fin:
            test = subunit.ProtocolTestCase(fin)
            runner = unittest.TextTestRunner(stream=open(os.devnull, 'w'),
                                             resultclass=self.result_class)

            # Run (replay) the test from subunit stream.
            test_result = runner.run(test)
            return test_result.get_results() 
开发者ID:openstack-archive,项目名称:refstack-client,代码行数:12,代码来源:subunit_processor.py


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