diff options
author | Thomi Richards <thomi.richards@canonical.com> | 2013-11-20 14:17:36 +1300 |
---|---|---|
committer | Thomi Richards <thomi.richards@canonical.com> | 2013-11-20 14:17:36 +1300 |
commit | 4c9b32360c7f2c3cc82c438d0206dc484c85ad02 (patch) | |
tree | 5acb9bcc6127d2371eb8881a405f4bd2fb543eb6 | |
parent | 52e8d163f68bfa42d71fbb281ccc5ee6deefa23e (diff) | |
download | subunit-4c9b32360c7f2c3cc82c438d0206dc484c85ad02.tar.gz |
Fix docstring, code shuffle.
-rw-r--r-- | python/subunit/_output.py | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/python/subunit/_output.py b/python/subunit/_output.py index ff6004e..08ed3fc 100644 --- a/python/subunit/_output.py +++ b/python/subunit/_output.py @@ -35,29 +35,9 @@ def parse_arguments(args=None, ParserClass=ArgumentParser): 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 + ParserClass may be specified to override the class we use to parse the command-line arguments. This is useful for testing. - """ - - class StatusAction(Action): - """A custom action that stores option name and argument separately. - - This is part of a workaround for the fact that argparse does not - support optional subcommands (http://bugs.python.org/issue9253). - """ - - def __init__(self, status_name, *args, **kwargs): - super(StatusAction, self).__init__(*args, **kwargs) - self._status_name = status_name - - def __call__(self, parser, namespace, values, option_string=None): - if getattr(namespace, self.dest, None) is not None: - raise ArgumentError(self, "Only one status may be specified at once.") - setattr(namespace, self.dest, self._status_name) - setattr(namespace, 'test_id', values[0]) - - parser = ParserClass( prog='subunit-output', description="A tool to generate a subunit result byte-stream", @@ -142,6 +122,24 @@ def parse_arguments(args=None, ParserClass=ArgumentParser): return args +class StatusAction(Action): + """A custom action that stores option name and argument separately. + + This is part of a workaround for the fact that argparse does not + support optional subcommands (http://bugs.python.org/issue9253). + """ + + def __init__(self, status_name, *args, **kwargs): + super(StatusAction, self).__init__(*args, **kwargs) + self._status_name = status_name + + def __call__(self, parser, namespace, values, option_string=None): + if getattr(namespace, self.dest, None) is not None: + raise ArgumentError(self, "Only one status may be specified at once.") + setattr(namespace, self.dest, self._status_name) + setattr(namespace, 'test_id', values[0]) + + def get_output_stream_writer(): return StreamResultToBytes(stdout) |