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 | 2b4a6de5804fb0b4cc207d384f8d6aac9f0c2a67 (patch) | |
tree | 1811fc885b93182c3235bd60400f5f3e1a2ed429 /python/subunit/_output.py | |
parent | f9b9c8ccebc2f7a9a42caabbfb11a81db02cfc99 (diff) | |
download | subunit-git-2b4a6de5804fb0b4cc207d384f8d6aac9f0c2a67.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 " \ |