[Patches] [ python-Patches-697939 ] optparse unit tests + fixes
SourceForge.net
noreply@sourceforge.net
Thu, 13 Mar 2003 03:19:17 -0800
Patches item #697939, was opened at 2003-03-05 12:43
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=697939&group_id=5470
Category: Tests
Group: Python 2.3
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Johannes Gijsbers (jlgijsbers)
Assigned to: Nobody/Anonymous (nobody)
Summary: optparse unit tests + fixes
Initial Comment:
Here's a patch that mostly converts the tests from optik
1.4 to the unittest format and makes it usable in the
Python library. I've also added some tests, of which five
fail with current CVS:
test_opt_string_empty
test_opt_string_too_short
test_opt_string_long_invalid
test_opt_string_short_invalid
test_help_long_opts_first
I changed the following to fix the tests:
* format_option_strings_short_first and
format_option_strings_long_first have been merged into
one function, format_options, to eliminate the almost
complete duplication. To make this possible, short_first
is now an attribute, which conveniently also eases
changing short_first after instantiation.
* _short_opts and _long_opts are set in the Option
constructor, instead of in _check_option_strings, to
prevent an AttributeError which would occur when no
option strings were passed, making the "at least one
option string must be supplied" OptionError useless.
* Removed the check that would raise a RuntimeError in
Option.__str__ when no option strings existed in
_short_opts or _long_opts. A RuntimeError would be
raised when an OptionError was raised in
_set_opt_strings, because, quite logically, no option
strings were set at that point.
I'm not sure why the check was there, because
_short_opts and _long_opts are only empty when
instantation fails, or when somebody set those *internal*
attributes to false. And the moment you start mucking
with internal attributes, you're on your own. :)
----------------------------------------------------------------------
>Comment By: Johannes Gijsbers (jlgijsbers)
Date: 2003-03-13 12:19
Message:
Logged In: YES
user_id=469548
I should have submitted a patch to the Optik code, according
to Greg, I'll close this one and resubmit to him.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=697939&group_id=5470