本文整理汇总了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()
示例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)
示例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)
示例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()