This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: optparse unit tests + fixes
Type: Stage:
Components: Tests Versions: Python 2.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jlgijsbers
Priority: normal Keywords: patch

Created on 2003-03-05 11:43 by jlgijsbers, last changed 2022-04-10 16:07 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
optparse.diff jlgijsbers, 2003-03-05 11:44 unit tests + fixes
Messages (2)
msg42954 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2003-03-05 11:43
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. :)
msg42955 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2003-03-13 11:19
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.
History
Date User Action Args
2022-04-10 16:07:22adminsetgithub: 38100
2003-03-05 11:43:18jlgijsberscreate