From 2bf7d82ce68dc62bf6d05bbbd0a213dc3393f9b7 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Tue, 27 Mar 2012 11:57:51 +0100 Subject: Rename main() and give it a docstring. --- python/subunit/filters.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'python/subunit') diff --git a/python/subunit/filters.py b/python/subunit/filters.py index 0bab9ed..f8ce2dd 100644 --- a/python/subunit/filters.py +++ b/python/subunit/filters.py @@ -18,7 +18,6 @@ from optparse import OptionParser import sys from subunit import DiscardStream, ProtocolTestCase -from subunit.test_results import CsvResult def make_options(description): @@ -106,7 +105,20 @@ def filter_by_result(result_factory, output_path, no_passthrough, forward, return 1 -def main(result_factory, description): +def run_filter_script(result_factory, description): + """Main function for simple subunit filter scripts. + + Many subunit filter scripts take a stream of subunit input and use a + TestResult to handle the events generated by that stream. This function + wraps a lot of the boiler-plate around that by making a script with + options for handling passthrough information and stream forwarding, and + that will exit with a successful return code (i.e. 0) if the input stream + represents a successful test run. + + :param result_factory: A callable that takes an output stream and returns + a test result that outputs to that stream. + :param description: A description of the filter script. + """ parser = make_options(description) (options, args) = parser.parse_args() sys.exit( -- cgit v1.2.1