[issue9026] [argparse] Subcommands not printed in the same order they were added
report at bugs.python.org
Mon Jun 21 17:28:02 CEST 2010
Javier Collado <javier.collado at gmail.com> added the comment:
Finally I had to use an OrderedDict as suggested by R. David Murray because it wasn't safe to rely on _choices_actions in HelpFormatter class (i.e. previous patch wasn't valid):
- _choices_actions attribute is only present in _SubParsersAction class
- Even if action object is an instance of _SubParsersAction, _choices_actions only contains data for for subparsers that contain a help description.
Regarding the test cases:
- TestHelpSubparsersOrdering and TestHelpSubparsersWithHelpOrdering have been added
- TestHelpFormattingMetaClass has been modified:
- New subparsers_signatures tester attribute added to test subparsers help.
- If a 'signatures attribute' isn't present in tester object, then isn't consumed
- assertMultilineEqual used instead of assertEqual to make it easier to debug test case failures.
Added file: http://bugs.python.org/file17730/trunk.diff
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list