summaryrefslogtreecommitdiff
path: root/python/subunit/_output.py
diff options
context:
space:
mode:
authorThomi Richards <thomi.richards@canonical.com>2013-11-19 09:55:44 +1300
committerThomi Richards <thomi.richards@canonical.com>2013-11-19 09:55:44 +1300
commit2b4a6de5804fb0b4cc207d384f8d6aac9f0c2a67 (patch)
tree1811fc885b93182c3235bd60400f5f3e1a2ed429 /python/subunit/_output.py
parentf9b9c8ccebc2f7a9a42caabbfb11a81db02cfc99 (diff)
downloadsubunit-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.py15
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 " \