diff options
| author | Thomi Richards <thomi.richards@canonical.com> | 2013-11-19 09:55:44 +1300 |
|---|---|---|
| committer | Thomi Richards <thomi.richards@canonical.com> | 2013-11-19 09:55:44 +1300 |
| commit | 0261bdde749194d51098a97ccb41fa5ddae91c15 (patch) | |
| tree | 1811fc885b93182c3235bd60400f5f3e1a2ed429 /python/subunit/_output.py | |
| parent | 3277945b614a58aba415001f543b63f84a077e29 (diff) | |
| download | subunit-0261bdde749194d51098a97ccb41fa5ddae91c15.tar.gz | |
Allow customisation of argument parser class used, so we can write failing tests for command line arguments not yet supported. Have failing test for attaching files.
Diffstat (limited to 'python/subunit/_output.py')
| -rw-r--r-- | python/subunit/_output.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/python/subunit/_output.py b/python/subunit/_output.py index 4889e6f..b3a5bba 100644 --- a/python/subunit/_output.py +++ b/python/subunit/_output.py @@ -27,20 +27,25 @@ def output_main(): return 0 -def parse_arguments(args=None): +def parse_arguments(args=None, ParserClass=ArgumentParser): """Parse arguments from the command line. If specified, args must be a list of strings, similar to sys.argv[1:]. + ParserClass can be specified to override the class we use to parse the + command-line arguments. This is useful for testing. + """ - parser = ArgumentParser( + parser = ParserClass( prog='subunit-output', description="A tool to generate a subunit result byte-stream", ) - common_args = ArgumentParser(add_help=False) - common_args.add_argument("test_id", help="""A string that uniquely - identifies this test.""") + common_args = ParserClass(add_help=False) + common_args.add_argument( + "test_id", + help="A string that uniquely identifies this test." + ) sub_parsers = parser.add_subparsers(dest="action") final_state = "This is a final action: No more actions may be generated " \ |
