Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_optparse.cpython-310.pyc

o

0�i��@s(ddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlZddlmZm
Z
mZmZmZmZmZmZmZmZmZddlmZddlmZGdd	�d	e�ZGd
d�de�ZGdd
�d
ej�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!ddddd�Z"dd�Z#Gdd�de
�Z$Gdd �d e�Z%Gd!d"�d"e�Z&Gd#d$�d$e�Z'Gd%d&�d&e�Z(Gd'd(�d(e�Z)Gd)d*�d*e�Z*Gd+d,�d,e�Z+Gd-d.�d.e�Z,Gd/d0�d0e�Z-Gd1d2�d2e�Z.Gd3d4�d4e�Z/Gd5d6�d6e�Z0Gd7d8�d8e�Z1Gd9d:�d:e�Z2Gd;d<�d<e�Z3Gd=d>�d>e�Z4Gd?d@�d@e�Z5GdAdB�dBe�Z6GdCdD�dDe�Z7GdEdF�dFe�Z8GdGdH�dHe�Z9GdIdJ�dJe9�Z:GdKdL�dLe9�Z;GdMdN�dNe�Z<dOZ=dPZ>dQZ?dRZ@dSZAGdTdU�dUe�ZBGdVdW�dWe�ZCGdXdY�dYe�ZDGdZd[�d[ej�ZEeFd\k�r�e�G�dSdS)]�N)�StringIO)�support)�	os_helper)�make_option�Option�TitledHelpFormatter�OptionParser�OptionGroup�SUPPRESS_USAGE�OptionError�OptionConflictError�BadOptionError�OptionValueError�Values)�
_match_abbrev)�
_parse_numc@s$eZdZ			ddd�Zdd�ZdS)�InterceptedErrorNcCs||_||_||_dS�N)�
error_message�exit_status�exit_message)�selfrrr�r�9/opt/alt/python310/lib64/python3.10/test/test_optparse.py�__init__s
zInterceptedError.__init__cCs|jp|jpdS)Nzintercepted error)rr�rrrr�__str__%�zInterceptedError.__str__)NNN)�__name__�
__module__�__qualname__rrrrrrrs
�rc@seZdZddd�Zdd�ZdS)�InterceptingOptionParserrNcCst||d��)N)rr�r)rZstatus�msgrrr�exit)�zInterceptingOptionParser.exitcCs
t|d��)N)rr")rr#rrr�error,s
zInterceptingOptionParser.error�rN)rrr r$r&rrrrr!(s
r!c@sBeZdZdd�Zdd�Zdd�Z		dd	d
�Zdd�Zd
d�ZdS)�BaseTestcCsH|j�|�\}}t|�}|�||dt��|�||dt��||fS)a�Assert the options are what we expected when parsing arguments.

        Otherwise, fail with a nicely formatted message.

        Keyword arguments:
        args -- A list of arguments to parse with OptionParser.
        expected_opts -- The options expected.
        expected_positional_args -- The positional arguments expected.

        Returns the options and positional args for further testing.
        zJ
Options are %(optdict)s.
Should be %(expected_opts)s.
Args were %(args)s.zj
Positional arguments are %(positional_args)s.
Should be %(expected_positional_args)s.
Args were %(args)s.)�parser�
parse_args�vars�assertEqual�locals)r�argsZ
expected_optsZexpected_positional_args�optionsZpositional_argsZoptdictrrr�
assertParseOK1s
����zBaseTest.assertParseOKc
Cs�|durd}|duri}z	||i|��Wn8|yM}z,t|�}t|tj�r6|�|�|�d|j|f�n|�||d||f�|WYd}~Sd}~ww|�dt	��dS)a-
        Assert that the expected exception is raised when calling a
        function, and that the right error message is included with
        that exception.

        Arguments:
          func -- the function to call
          args -- positional arguments to `func`
          kwargs -- keyword arguments to `func`
          expected_exception -- exception that should be raised
          expected_message -- expected exception message (or pattern
            if a compiled regex object)

        Returns the exception raised for further testing.
        NrzLexpected exception message pattern:
/%s/
actual exception message:
'''%s'''
zHexpected exception message:
'''%s'''
actual exception message:
'''%s'''
znexpected exception %(expected_exception)s not raised
called %(func)r
with args %(args)r
and kwargs %(kwargs)r
)
�str�
isinstance�re�Pattern�
assertTrue�search�patternr,�failr-)r�funcr.�kwargsZexpected_exception�expected_message�errZactual_messagerrr�assertRaisesOs4����	��
�zBaseTest.assertRaisesc
CsTz|j�|�Wnty"}z|�|j|�WYd}~dSd}~ww|�d�dS)z�
        Assert the parser fails with the expected message.  Caller
        must ensure that self.parser is an InterceptingOptionParser.
        Nzexpected parse failure)r)r*rr,r�assertFalse)r�cmdline_args�expected_outputr<rrr�assertParseFail�s��zBaseTest.assertParseFailrNc
Cs�tj}z zt�t_|j�|�Wtj��}|t_n	tj��}|t_wWn?tyb}z3|�t|t	�dt
|��||krI|�d|d|d�|�|j
|�|�|j|�WYd}~dSd}~ww|�d�dS)z7Assert the parser prints the expected output on stdout.z0expected output to be an ordinary string, not %rzexpected: 
'''
z'''
but got 
'''
z'''Nzexpected parser.exit())�sys�stdoutrr)r*�getvaluerr5r2r1�typer8r,rrr>)rr?r@Zexpected_statusZexpected_errorZsave_stdout�outputr<rrr�assertOutput�s:

���
�����zBaseTest.assertOutputcGs|�||dt|�dS)z4Assert that TypeError is raised when executing func.N)r=�	TypeError)rr9r;r.rrr�assertTypeError�szBaseTest.assertTypeErrorcCs.|��}||kr|�d|d|d��dS)Nzhelp text failure; expected:
"z	"; got:
"z"
)Zformat_helpZfailureException)rr)�
expected_helpZactual_helprrr�
assertHelp�s������zBaseTest.assertHelpr')	rrr r0r=rArGrIrKrrrrr(0s;
�r(c@s�eZdZdd�Zgifdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/S)0�TestOptionCheckscC�ttd�|_dS�N��usage�rr
r)rrrr�setUp�rzTestOptionChecks.setUpcCs|�t||t|�dSr)r=rr)rr;r.r:rrr�assertOptionError��
�z"TestOptionChecks.assertOptionErrorcCs|�td�dS)Nz+at least one option string must be supplied)rIrrrrr�test_opt_string_empty�s�z&TestOptionChecks.test_opt_string_emptycC�|�ddg�dS)Nz?invalid option string 'b': must be at least two characters long�b�rSrrrr�test_opt_string_too_short�s�z*TestOptionChecks.test_opt_string_too_shortcCrV)NzOinvalid short option string '--': must be of the form -x, (x any non-dash char)�--rXrrrr�test_opt_string_short_invalid���z.TestOptionChecks.test_opt_string_short_invalidcCrV)NzJinvalid long option string '---': must start with --, followed by non-dashz---rXrrrr�test_opt_string_long_invalid�r\z-TestOptionChecks.test_opt_string_long_invalidcCs|�ddgddd��dS)Nz.option -b: invalid keyword arguments: bar, foo�-b��foo�barrXrrrr�test_attr_invalid���z"TestOptionChecks.test_attr_invalidcCs|�ddgddi�dS)Nz option -b: invalid action: 'foo'r^�actionr`rXrrrr�test_action_invalid�s
�z$TestOptionChecks.test_action_invalidcCs,|�ddgddi�|�ddgdti�dS)Nz%option -b: invalid option type: 'foo'r^rEr`z'option -b: invalid option type: 'tuple')rS�tuplerrrr�test_type_invalid�s
�
�z"TestOptionChecks.test_type_invalidcC�|�ddgddd��dS)Nz4option -b: must not supply a type for action 'count'r^�count�int)rdrErXrrrr�test_no_type_for_action�rcz(TestOptionChecks.test_no_type_for_actioncCs|�dddgddi�dS)Nz@option -b/--bad: must supply a list of choices for type 'choice'r^�--badrE�choicerXrrrr�test_no_choices_list�s�z%TestOptionChecks.test_no_choices_listcCs*td�j}|�d|ddgddd��dS)N�zBoption -b/--bad: choices must be a list of strings ('%s' supplied)r^rlrmzbad choices�rE�choices)rErrS)r�typenamerrr�test_bad_choices_list�s
��z&TestOptionChecks.test_bad_choices_listcCrh)Nz1option -b: must not supply choices for type 'int'r^rjZbadrprXrrrr�test_no_choices_for_typercz)TestOptionChecks.test_no_choices_for_typecCrh)Nz:option -b: 'const' must not be supplied for action 'store'r^�store�)rd�constrXrrrr�test_no_const_for_actionrcz)TestOptionChecks.test_no_const_for_actioncCrh)Nz:option -b: 'nargs' must not be supplied for action 'count'r^ri�)rd�nargsrXrrrr�test_no_nargs_for_actionrcz)TestOptionChecks.test_no_nargs_for_actioncCrh)Nz'option -b: callback not callable: 'foo'r^�callbackr`�rdr|rXrrrr�test_callback_not_callable���z+TestOptionChecks.test_callback_not_callablecC�dSrrrrrr�dummy�zTestOptionChecks.dummycC�|�ddgd|jdd��dS)NzAoption -b: callback_args, if supplied, must be a tuple: not 'foo'r^r|r`)rdr|�
callback_args�rSr�rrrr�test_callback_args_no_tuple���z,TestOptionChecks.test_callback_args_no_tuplecCr�)NzBoption -b: callback_kwargs, if supplied, must be a dict: not 'foo'r^r|r`)rdr|�callback_kwargsr�rrrr�test_callback_kwargs_no_dict'r�z-TestOptionChecks.test_callback_kwargs_no_dictcCrh)Nz<option -b: callback supplied ('foo') for non-callback optionr^rur`r}rXrrrr�test_no_callback_for_action/rz,TestOptionChecks.test_no_callback_for_actioncCrh)Nz9option -b: callback_args supplied for non-callback optionr^rur`)rdr�rXrrrr� test_no_callback_args_for_action5rz1TestOptionChecks.test_no_callback_args_for_actioncCrh)Nz;option -b: callback_kwargs supplied for non-callback optionr^rur`)rdr�rXrrrr�"test_no_callback_kwargs_for_action;rz3TestOptionChecks.test_no_callback_kwargs_for_actioncCs2|�ddg�|�dddg�|�dddg�dS)NzMinvalid long option string '-debug': must start with --, followed by non-dashz-debugzXoption -d: invalid long option string '-debug': must start with --, followed by non-dash�-dz--debugrXrrrr�test_no_single_dashAs���z$TestOptionChecks.test_no_single_dashN)rrr rRrSrUrYr[r]rbrergrkrnrsrtrxr{r~r�r�r�r�r�r�r�rrrrrL�s0rLc@sreZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
jddd�dd��ZdS)�TestOptionParsercCs:t�|_|jjddddddd�|jjdd	d
ddd�dS)N�-v�	--verbose�-n�--noisy�
store_true�verbose�rd�dest�-q�--quiet�--silent�store_false)rr)�
add_optionrrrrrRRs�
�zTestOptionParser.setUpcC�|�|jjdd�dS)Nznot an Option instance: None�rIr)r�rrrr�test_add_option_no_OptionYrTz*TestOptionParser.test_add_option_no_OptioncC�|�|jjddd�dS�Nzinvalid argumentsr�rrrr�!test_add_option_invalid_arguments]�
�z2TestOptionParser.test_add_option_invalid_argumentscCs\|j�d�}|�|t�|�|jddg�|�|jddg�|�|jd�|�|jd�dS)Nr�r�r�r�r�r�)	r)�
get_optionZassertIsInstancerr,�_short_opts�
_long_optsrdr�)r�opt1rrr�test_get_optionasz TestOptionParser.test_get_optioncCsb|j�d�}|j�d�}|j�d�}|j�d�}|�||uo+|uo+|u�dS�dS)Nr�r�r�r�)r)r�r5)rr�Zopt2Zopt3Zopt4rrr�test_get_option_equalsis
2z'TestOptionParser.test_get_option_equalscCs(|�|j�d��|�|j�d��dS)Nr�r�)r5r)�
has_optionrrrr�test_has_optionpsz TestOptionParser.test_has_optioncCs�|�|j�d�du�|�|j�d�du�|�|j�d�du�|�|j�d�du�|�|j�d��|�|j�d��|�|j�d��|�|j�d��|�|j�d��|�|j�d��dS)Nr�r�r�r�r�r�)r5r)r�r>r�rrrr�assertTrueremovedtsz"TestOptionParser.assertTrueremovedcC�|j�d�|��dS)Nr��r)�
remove_optionr�rrrr�test_remove_short_opt��z&TestOptionParser.test_remove_short_optcCr�)Nr�r�rrrr�test_remove_long_opt�r�z%TestOptionParser.test_remove_long_optcC�|�|jjddtd�dS)N�r`zno such option 'foo')r=r)r��
ValueErrorrrrr�test_remove_nonexistent�s�z(TestOptionParser.test_remove_nonexistentzRelies on sys.getrefcountT)ZcpythoncCsHdg}t�|�}t�}|�dd�||_|��~|�|t�|��dS)N�*�-az	--aaarggh)rB�getrefcountrr��	big_thingZdestroyr,)rr�Zrefcountr)rrr�test_refleak�s
zTestOptionParser.test_refleakN)rrr rRr�r�r�r�r�r�r�r�r�rZimpl_detailr�rrrrr�Qsr�c@�eZdZdd�Zdd�ZdS)�TestOptionValuescCr�rrrrrrrR�r�zTestOptionValues.setUpcCs�t�}|�t|�i�|�|i�|�|ddi�|�|d�ddd�}t|d�}|�t|�|�|�||�|�|ddi�|�|i�|�|d�|�|g�dS)Nr`raror�)r`�baz)�defaults)rr,r+ZassertNotEqual)r�values�dictrrr�test_basics�s

zTestOptionValues.test_basicsN)rrr rRr�rrrrr��sr�c@�$eZdZdd�Zdd�Zdd�ZdS)�TestTypeAliasescCst�|_dSr)rr)rrrrrR�r%zTestTypeAliases.setUpcCs*|jjddd�|�|j�d�jd�dS)N�-sr1�rE�string)r)r�r,r�rErrrr�test_str_aliases_string�sz'TestTypeAliases.test_str_aliases_stringcCsP|jjdtd�|�|j�d�jd�|jjdtd�|�|j�d�jd�dS)Nr�r�r��-xrj)r)r�r1r,r�rErjrrrr�test_type_object�sz TestTypeAliases.test_type_objectN)rrr rRr�r�rrrrr��sr�rv�<ii�Q)�s�m�h�dc	CsXz|d��rt|�WSt|dd��t|dWSttfy+td||f��w)N���zoption %s: invalid duration: %r)�isdigitrj�_time_unitsr��
IndexErrorr��option�opt�valuerrr�_check_duration�s

��r�c@s*eZdZejdZe�ej�Zeed<dS)�DurationOption)�durationr�N)rrr r�TYPES�copy�TYPE_CHECKERr�rrrrr��s
r�c@�4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TestDefaultValuescCs�t�|_|jjdddd�|jjdddd�|jjd	d
dd�|jjd
d
d�|jjddd�|j�d�|jjddd�ddddddd�|_dS)Nr�r�T��defaultr�r�r�)r�r�rj�%�rEr�z-mr�r�r`�-tz-u)r��nr�r��t�u)rr)r��expectedrrrrrR�s�zTestDefaultValues.setUpcCs|�|j��|j�dSr)r,r)�get_default_valuesr�rrrr�test_basic_defaults��z%TestDefaultValues.test_basic_defaultscCs:|jjddd�|j�ddd��|�|j��|j�dS)Nr�i����)r�r�)r)�set_defaultsr��updater,r�rrrr�test_mixed_defaults_post�sz*TestDefaultValues.test_mixed_defaults_postcCs�|jjddd�|jjddd�|j�d�|j�ddd��|�|j��|j�|j�d�|jjddd�|j�ddi�|�|j��|j�dS)	NZbarf�blah)�x�yr�Zfrobr�z-yr�)r)r�r�r�r�r,r�r�rrrr�test_mixed_defaults_pre�sz)TestDefaultValues.test_mixed_defaults_precCs�t|j_|jjdddd�|jjdddd�|jjdd�|j�dd	d
d��|�|j��|j�|j�	d�|j�dddd��|�|j��|j�dS)
Nr�r�i,r�z-eZ6m�42)r�ihr�)r��er�F)
r�r)�option_classr�r�r�r�r,r�Zset_process_default_valuesrrrr�test_process_default�sz&TestDefaultValues.test_process_defaultN)rrr rRr�r�r�r�rrrrr��s
r�c@�0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�TestProgNamez]
    Test that %prog expands to the right thing in usage, version,
    and help strings.
    cC�|�|��|�dSr)r,Z	get_usage�rr)�expected_usagerrr�assertUsage�zTestProgName.assertUsagecCr�r)r,Zget_version)rr)Zexpected_versionrrr�
assertVersionr�zTestProgName.assertVersionc
Cs�tjdd�}z3tj�ddd�tjd<tddd�}d}|�||�|�|d	�|�||d
d�W|tjdd�<dS|tjdd�<w)Nr`razbaz.pyrz	%prog ...z	%prog 1.2)�versionzUsage: baz.py ...
z
baz.py 1.2�
zlOptions:
  --version   show program's version number and exit
  -h, --help  show this help message and exit
)	rB�argv�os�path�joinrr�r�rK)r�	save_argvr)r�rrr�test_default_prognames��"z"TestProgName.test_default_prognamecCsRtdddd�}|�d�|�d�d}|�||�|�|d�|�||d	�dS)
NZthingy�	%prog 0.1z
%prog arg arg)�progr�rP�-h�	--versionzUsage: thingy arg arg
z
thingy 0.1r)rr�r�r�rKr�rrr�test_custom_progname's�

z!TestProgName.test_custom_prognameN)rrr �__doc__r�r�rrrrrrr�	sr�c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�TestExpandDefaultscCs4tdd�|_d|_d|_|jd|_|jd|_dS)N�test)rzXUsage: test [options]

Options:
  -h, --help            show this help message and exit
z"read from FILE [default: %default]z:  -f FILE, --file=FILE  read from FILE [default: foo.txt]
z7  -f FILE, --file=FILE  read from FILE [default: none]
)rr)�help_prefix�	file_help�expected_help_file�expected_help_nonerrrrrR4s�
�zTestExpandDefaults.setUpcCs*|jjddd|jd�|�|j|j�dS)N�-f�--file�foo.txt�r��help)r)r�rrKrrrrr�test_option_defaultB�

�z&TestExpandDefaults.test_option_defaultcCs6|jjdd|jd�|j�dd�|�|j|j�dS)Nrr�r�filer)r)r�r�set_defaultrKrrrrr�test_parser_default_1H�

�z(TestExpandDefaults.test_parser_default_1cCs6|jjdd|jd�|jjdd�|�|j|j�dS)Nrrrr�r)r)r�rr�rKrrrrr�test_parser_default_2Nrz(TestExpandDefaults.test_parser_default_2cCs(|jjdd|jd�|�|j|j�dS)Nrrr�r)r�rrKrrrrr�test_no_defaultTs
�z"TestExpandDefaults.test_no_defaultcCs*|jjddd|jd�|�|j|j�dS)Nrrrr!rrrr�test_default_none_1Yrz&TestExpandDefaults.test_default_none_1cCs6|jjdd|jd�|jjdd�|�|j|j�dS)Nrrrr)r)r�rr�rKrrrrr�test_default_none_2_rz&TestExpandDefaults.test_default_none_2cCs<|jjdddd�|jjdd�|jd}|�|j|�dS)N�-pz--probz1blow up with probability PROB [default: %default]rg��Q���?)ZprobzF  -p PROB, --prob=PROB  blow up with probability PROB [default: 0.43]
)r)r�r�rrK�rrJrrr�test_float_defaultes��z%TestExpandDefaults.test_float_defaultcCs2|jjddddd�d|jj_|�|j|j�dS)Nrrrz#read from FILE [default: *DEFAULT*]rz	*DEFAULT*)r)r��	formatter�default_tagrKrrrrr�test_alt_expandns
�
z"TestExpandDefaults.test_alt_expandcCs:|jjddddd�d|jj_|jd}|�|j|�dS)Nrrrzread from %default filerz0  -f FILE, --file=FILE  read from %default file
)r)r�r(r)rrKr&rrr�test_no_expandus
�
�z!TestExpandDefaults.test_no_expandN)
rrr rRrrr r"r#r$r'r*r+rrrrr
3s	r
c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7S)8�TestStandardcCs8tddd�tddddd�td	d
d�g}tt|d�|_dS)
Nr�r�r�r^�--boorj�boo�rEr��--foo�append�rd�rP�option_list�rr!r
r)�rr/rrrrR�s

��zTestStandard.setUpcC�|�dgd�dS)Nr�z-a option requires 1 argument�rArrrr�test_required_value��z TestStandard.test_required_valuecC�|�ddgd�dS)Nr^Z5xz&option -b: invalid integer value: '5x'r8rrrr�test_invalid_integer��
�z!TestStandard.test_invalid_integercCr7)Nz--boo13zno such option: --boo13r8rrrr�test_no_such_option�r:z TestStandard.test_no_such_optioncCr7)Nz--boo=x5z)option --boo: invalid integer value: 'x5'r8rrrr�test_long_invalid_integer���z&TestStandard.test_long_invalid_integercCs|�gdddd�g�dS)N��ar.r`�r0rrrr�
test_empty��zTestStandard.test_emptycCs"|�gd�ddddgd�g�dS)N)r�roz
--foo=blahz--foo=ror�rArCrrrr�"test_shortopt_empty_longopt_append��
�z/TestStandard.test_shortopt_empty_longopt_appendcCs"|�gd�ddgd�d�g�dS)N)r0rar0roz--foo=x)raror�rArCrrrr�test_long_option_append�s
��z$TestStandard.test_long_option_appendcCs|�dgdddd�g�dS)Nz-abcZbcrArCrrrr�test_option_argument_joined��
�z(TestStandard.test_option_argument_joinedcC�|�ddgdddd�g�dS)Nr�Z34rArCrrrr�test_option_argument_split��

�z'TestStandard.test_option_argument_splitcC�|�dgdddd�g�dS)Nz-b34�"rArCrrrr�#test_option_argument_joined_integer�rJz0TestStandard.test_option_argument_joined_integercC�|�ddgdddd�g�dS)Nr^�-5���rArCrrrr�+test_option_argument_split_negative_integer�rMz8TestStandard.test_option_argument_split_negative_integercCrN)Nz--boo=13�
rArCrrrr� test_long_option_argument_joined�rJz-TestStandard.test_long_option_argument_joinedcCrQ)Nr-Z111�orArCrrrr�test_long_option_argument_split�rMz,TestStandard.test_long_option_argument_splitcC� |�ddgdddgd�g�dS)N�	--foo=bar�-axyz�xyzrarArCrrrr�test_long_option_short_option��
�z*TestStandard.test_long_option_short_optioncCrY)N�--f=barr[r\rarArCrrrr�test_abbrev_long_option�r^z$TestStandard.test_abbrev_long_optioncCs2|j�g�\}}|j��}|�t|�t|��dSr)r)r*r�r,r+)rr/r.r�rrr�
test_defaults�s
zTestStandard.test_defaultscCs&|jjddddd�|�dgd�dS)N�--fozrur�r`�rdrEr�r_z%ambiguous option: --f (--foo, --foz?)�r)r�rArrrr�test_ambiguous_option�s
��z"TestStandard.test_ambiguous_optioncCs |�gd�dddgd�g�dS)N)r�r\r0rar\rarArCrrrr� test_short_and_long_option_split�r^z-TestStandard.test_short_and_long_option_splitcC�"|�gd�ddddgd�g�dS)N)rZr^Z123r0r��{rar�rArCrrrr�*test_short_option_split_long_option_append�rGz7TestStandard.test_short_option_split_long_option_appendcCs |�gd�dddd�dg�dS)N)r�r`rar`rArarCrrrr�*test_short_option_split_one_positional_arg�s

�z7TestStandard.test_short_option_split_one_positional_argcCs>|�gd�dddd�ddg�|�gd�dddgd�g�dS)N)r�rZr`rarZrAr`ra)r�rZr0rarCrrrr�$test_short_option_consumes_separator�s

�
�z1TestStandard.test_short_option_consumes_separatorcCs$|�gd�dddd�ddg�fdS)N)�-abrZr0rarWrAr0rarCrrrr�&test_short_option_joined_and_separator�s


�z3TestStandard.test_short_option_joined_and_separatorcCs"|�gd�dddgd�dg�dS)N)rl�-r0rarWrarArnrCrrrr�"test_hyphen_becomes_positional_arg��
�z/TestStandard.test_hyphen_becomes_positional_argcCrg)N)�-b3r^�5rZr0r��rar�rArCrrrr�test_no_append_versus_append�rGz)TestStandard.test_no_append_versus_appendcCrK)Nr�rqrArCrrrr�&test_option_consumes_optionlike_stringrMz3TestStandard.test_option_consumes_optionlike_stringcCs"|jjddd�|�dgd�dS)Nr�r�r2z-testzno such option: -erdrrrr�#test_combined_single_invalid_options�z0TestStandard.test_combined_single_invalid_optionN)rrr rRr9r<r>r?rDrFrHrIrLrPrTrVrXr]r`rarerfrirjrkrmrortrurvrrrrr,�s8r,c@r�)�TestBoolcCs2tdddddd�tddd	dd
�g}t|d�|_dS)Nr�r�r�r�ro�rdr�r�r�r�r�r��r4)rrr)r6rrrrRs���	zTestBool.setUpcCs|�gddig�dS)Nr�rorCrrrr�test_bool_defaults�zTestBool.test_bool_defaultcC�,|�dgddig�\}}|�|jdu�dS)Nr�r�rF�r0r5r��rr/r.rrr�test_bool_false�
�zTestBool.test_bool_falsecCr{)Nr�r�rvTr|r}rrr�test_bool_true#rzTestBool.test_bool_truecC�|�gd�ddig�dS)N)z-qvqr�r�r�rvrCrrrr�test_bool_flicker_on_and_off)s
�z%TestBool.test_bool_flicker_on_and_offN)rrr rRrzr~r�r�rrrrrwsrwc@�,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
TestChoicecCs*ttd�|_|jjddddgd�d�dS)NrO�-crurm)�oneZtwoZthree)rdrEr�rq�r!r
r)r�rrrrrR/s
�zTestChoice.setUpcC�|�gd�ddidg�dS)N)r�r�r\rmr�r\rCrrrr�test_valid_choice4�
�zTestChoice.test_valid_choicecC�|�gd�d�dS)N)r��four�abczEoption -c: invalid choice: 'four' (choose from 'one', 'two', 'three')r8rrrr�test_invalid_choice9r=zTestChoice.test_invalid_choicecCsB|jjddgd�d�|j�d�}|�|jd�|�|jd�dS)Nr�z	--default)r�ZfiveZsix)rqrmru)r)r�r�r,rErd�rr�rrr�test_add_choice_option>s
�z!TestChoice.test_add_choice_optionN)rrr rRr�r�r�rrrrr�.s
r�c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�	TestCountcCsVttd�|_tdddd�|_|j�|j�|jjdddd�|jjd	d
dddd
�dS)NrOr�rir�r�r�rjr/r�r��store_constr�rdr�rw)r!r
r)r�v_optr�rrrrrRFs

�zTestCount.setUpcCs|�gddig�dS)Nr�rCrrrrrDNszTestCount.test_emptycC�|�dgddig�dS)Nr�r�rvrCrrrr�test_count_oneQr�zTestCount.test_count_onecCr�)N�-vvvr��rCrrrr�test_count_threeTr�zTestCount.test_count_threecCr�)N)r�r�r�r�r�rCrrrr�test_count_three_apartWrEz TestCount.test_count_three_apartcCs|�ddgddig�dS)Nr��--verbose=2r�ryrCrrrr�test_count_override_amountZrEz$TestCount.test_count_override_amountcCr�)N)r�r�r�r�rrCrrrr�test_count_override_quiet]rEz#TestCount.test_count_override_quietcCr�)N�r�r�r�r�r�rvrCrrrr�test_count_overriding`s
�zTestCount.test_count_overridingcCr�)N�r��3r�r�rvr�rCrrrr�test_count_interspersed_argsdr�z&TestCount.test_count_interspersed_argscCs(|j��|�gd�ddiddg�dS)Nr�r�rr�r�)r)Zdisable_interspersed_argsr0rrrr�test_count_no_interspersed_argsis


�z)TestCount.test_count_no_interspersed_argscCr;)Nz-q3r�zno such option: -3r8rrrr�test_count_no_such_optionor�z#TestCount.test_count_no_such_optioncCr;)Nz	--quiet=3r�z$--quiet option does not take a valuer8rrrr�test_count_option_no_valuerr=z$TestCount.test_count_option_no_valuecCs$|j�dd�|�gddig�dS)Nr�r�r)rr0rrrr�test_count_with_defaultvsz!TestCount.test_count_with_defaultcCs(|j�dd�|�gd�ddig�dS)Nr�rr�rvr�rrrr�test_count_overriding_defaultzs
�z'TestCount.test_count_overriding_defaultN)rrr rRrDr�r�r�r�r�r�r�r�r�r�r�r�rrrrr�Esr�c@r�)�TestMultipleArgscCs(ttd�|_|jjddddddd�dS)	NrOr%�--pointrur��float�point�rdrzrEr�r�rrrrrR�s

�zTestMultipleArgs.setUpcCs|�gd�ddiddg�dS)N)r`r%�1�2.5z-4.3r\r�)g�?�@g333333�r`r\rCrrrr�test_nargs_with_positional_args�s
�z0TestMultipleArgs.test_nargs_with_positional_argscCr�)N)r��-1r�z-0r\r�)g�r�g�r\rCrrrr�test_nargs_long_opt�r�z$TestMultipleArgs.test_nargs_long_optcCr�)N)r%�1.0Z2x�3.5z-option -p: invalid floating-point value: '2x'r8rrrr�test_nargs_invalid_float_value�r=z/TestMultipleArgs.test_nargs_invalid_float_valuecCr�)N)r�r�r�z#--point option requires 3 argumentsr8rrrr�test_nargs_required_values�r=z+TestMultipleArgs.test_nargs_required_valuesN)rrr rRr�r�r�r�rrrrr�sr�c@r�)�TestMultipleArgsAppendcCsVttd�|_|jjddddddd�|jjd	d
ddd
dd�|jjdddddd�dS)NrOr%r�rur�r�r�r�rr0r1ryrjr`�-z�--zeroZappend_const�rrr�r�rrrrrR�s��
�zTestMultipleArgsAppend.setUpcCs"|�gd�dddgd�dg�dS)N)r�4�-3r�r0r�Z666)����)rvi��r�r`r�rCrrrr�test_nargs_append�rpz(TestMultipleArgsAppend.test_nargs_appendcCr7)Nz-f4,3z-f option requires 2 argumentsr8rrrr�!test_nargs_append_required_values�r@z8TestMultipleArgsAppend.test_nargs_append_required_valuescCs|�ddgddgd�g�dS)Nz--foo=3r��r�r�r�rCrrrr�test_nargs_append_simple�rMz/TestMultipleArgsAppend.test_nargs_append_simplecCs |�gd�dgd�d�g�dS)N)r�r0r�r�r�)r�r�r�r�rCrrrr�test_nargs_append_const�r^z.TestMultipleArgsAppend.test_nargs_append_constN)rrr rRr�r�r�r�rrrrr��s	r�c@r�)�TestVersionc
Cshttdd�|_tjdd�}ztj�tjdd�tjd<|�	dgd�W|tjdd�<dS|tjdd�<w)Nr)rPr�r`rarr
zbar 0.1
)
r!r
r)rBrrrr�curdirrG)rrrrr�test_version�s�"zTestVersion.test_versioncCsttd�|_|�dgd�dS)NrOr
zno such option: --version)r!r
r)rArrrr�test_no_version�s�zTestVersion.test_no_versionN)rrr r�r�rrrrr��s
r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�TestConflictingDefaultsz4Conflicting default values: the last one should win.cCsttddddd�gd�|_dS)Nr�r�r�rvrxry)rrr)rrrrrR�s�zTestConflictingDefaults.setUpcCs*|jjddddd�|�gddig�dS)Nr�r�r�rrx�r)r�r0rrrr�test_conflict_default���z-TestConflictingDefaults.test_conflict_defaultcCs*|jjddddd�|�gddig�dS)Nr�r�r�rxr�rrrr�test_conflict_default_none�r�z2TestConflictingDefaults.test_conflict_default_noneN)rrr rrRr�r�rrrrr��s
r�c@�<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestOptionGroupcCrMrNrQrrrrrR�rzTestOptionGroup.setUpcCs@t|jd�}|j�|�|jdddd�|�dgddig�dS)N�Spamz--spamr�zspam spam spam spam�rdrZspamrv)r	r)�add_option_groupr�r0�r�grouprrr�!test_option_group_create_instance�s�z1TestOptionGroup.test_option_group_create_instancecCr�)Nz!not an OptionGroup instance: None�rIr)r�rrrr�test_add_group_no_group�rTz'TestOptionGroup.test_add_group_no_groupcCr�r�r�rrrr� test_add_group_invalid_arguments�r�z0TestOptionGroup.test_add_group_invalid_argumentscCs0t|jd�}t�|_|�|jj|fdtd�dS)Nr�z"invalid OptionGroup (wrong parser))r	r)rr=r�r�r�rrr�test_add_group_wrong_parser�s
�z+TestOptionGroup.test_add_group_wrong_parsercCs@|jjddd�}|�d�|jddd�|�|j�d�|�dS)NzGroup 2zSome more options)�descriptionZBaconz--baconrjr�)r)r�Z	set_titler�r5Zget_option_groupr�rrr�test_group_manipulate�s�
z%TestOptionGroup.test_group_manipulateN)	rrr rRr�r�r�r�r�rrrrr��sr�c@sDeZdZdd�Zdd�ZGdd�de�Zdd�Zd	d
�Zdd�Z	d
S)�TestExtendAddTypescCs<tt|jd�|_|jjddddd�|jjddddd�dS)	N)rPr�r�r�rBr/rrr)r!r
�MyOptionr)r�rrrrrR�s
�zTestExtendAddTypes.setUpcCs@tj�tj�rt�tj�dStj�tj�rt�tj�dSdSr)rr�isdirr�TESTFN�rmdir�isfile�unlinkrrrr�tearDowns
�zTestExtendAddTypes.tearDownc@s2eZdZdd�ZejdZe�ej�Zeed<dS)zTestExtendAddTypes.MyOptioncCs4tj�|�std|��tj�|�std|��|S)N�%s: file does not exist�%s: not a regular file)rr�existsrr�r�rrr�
check_files
z&TestExtendAddTypes.MyOption.check_filerrN)rrr r�rr�r�r�rrrrr�s

r�cCs.t�tj�|�dtjdgtjdd�g�dS)Nr�-afoor`)rrB)rZcreate_empty_filer�r0rrrr�test_filetype_oks

�z#TestExtendAddTypes.test_filetype_okcCs|�dtjdgdtj�dS)Nrr�r�)rArr�rrrr�test_filetype_noexists
��z(TestExtendAddTypes.test_filetype_noexistcCs*t�tj�|�dtjdgdtj�dS)Nrr�r�)r�mkdirrr�rArrrr�test_filetype_notfiles��z(TestExtendAddTypes.test_filetype_notfileN)
rrr rRr�rr�r�r�r�rrrrr��sr�c@s4eZdZdd�ZGdd�de�Zdd�Zdd�Zd	S)
�TestExtendAddActionscCs&|jdddddd�g}t|d�|_dS)Nr��--apple�extendr��applercry)r�rr)r6rrrrR%s
�zTestExtendAddActions.setUpc@s2eZdZejdZejdZejdZdd�ZdS)zTestExtendAddActions.MyOption)r�c	CsB|dkr|�d�}|�|g��|�dSt�|||||||�dS)Nr��,)�split�ensure_valuer�r�take_action)rrdr�r�r�r�r)Zlvaluerrrr�/s
�z)TestExtendAddActions.MyOption.take_actionN)rrr rZACTIONSZ
STORE_ACTIONSZ
TYPED_ACTIONSr�rrrrr�*s



r�cCs|�ddgdgd�ig�dS)Nz	-afoo,barz--apple=blahr�)r`rar�rCrrrr�test_extend_add_action7rMz+TestExtendAddActions.test_extend_add_actioncCs|�gd�dgd�ig�dS)N)r�r`z-abarz--apple=x,yr�)r`rar�r�rCrrrr�test_extend_add_action_normal<rMz2TestExtendAddActions.test_extend_add_action_normalN)rrr rRrr�r�r�rrrrr�$s

r�c@r�)
�TestCallbackc	Cs8tddd|jd�tddd|jddd�g}t|d	�|_dS)
Nr�r|r}rrr��filename)rdr|rEr�ry)r�process_optrr)r6rrrrRDs���
zTestCallback.setUpcCs�|dkr3|�|jdg�|�|jg�|�||ju�|�|du�|�t|j�ddi�d|j_dS|dkrk|�|jdg�|�|jdg�|�||ju�|�|d�|�t|j�ddd��t|j|j	|�dS|�
d|�dS)	Nr�r�r�rrr`�r�r�z!Unknown option %r in process_opt.)r,r�r�r5r)r+r�r��setattrr�r8�rr�r�r��parser_rrrr�QszTestCallback.process_optcCs|�ddgddd�g�dS)Nr�z
--file=foor`r�r�rCrrrr�
test_callbacke�
�zTestCallback.test_callbackcCsBttd�}|�d�|jddddd�dd	d
�d}|�||�dS)NrOr	r�z--testr|cSr�rrrrrr�<lambda>qsz1TestCallback.test_callback_help.<locals>.<lambda>r�r`)rdr|rErz%Options:
  -t TEST, --test=TEST  foo
)rr
r�r�rK)rr)rJrrr�test_callback_helpjs


�zTestCallback.test_callback_helpN)rrr rRr�r�rrrrrr�Cs

r�c@r�)�TestCallbackExtraArgsc
Cs0tddd|jdtfddgd�g}t|d�|_dS)	Nr%r�r|r�r��points)rdr|r�rEr�r�ry)r�
process_tuplerjrr)r6rrrrRzs�zTestCallbackExtraArgs.setUpcCsp|�|d�|�|tu�|dkr|�|d�n
|dkr"|�|d�tt||�d���}t|j|j��	|�dS)Nr�r%z1,2,3r��4,5,6r�)
r,r5rjrf�mapr��getattrr�r�r1)rr�r�r�r��lenrErrrr�sz#TestCallbackExtraArgs.process_tuplecCs|�gd�dddgig�dS)N)z-p1,2,3r�rr�rvryr�)r�rs�rCrrrr�test_callback_extra_args�rMz.TestCallbackExtraArgs.test_callback_extra_argsN)rrr rRrrrrrrrysrc@r�)
�TestCallbackMeddleArgscs*�fdd�tddd�D�}t|d��_dS)Ncs"g|]
}tt|�d�jdd��qS)r|�things�rdr|r�)rr1�	process_n)�.0r�rrr�
<listcomp>�s

�
�z0TestCallbackMeddleArgs.setUp.<locals>.<listcomp>r�i����ry)�rangerr)r6rrrrR�s

�zTestCallbackMeddleArgs.setUpcCstt|dd��}|j}t|�|kr|�d||f�|j�|jg�}|�t|d|���|j	�|�|d|�=dS)Nrvz$Expected %d arguments for %s option.r)
rj�rargsr	r8r�r�r�r1rfZlargs)rr�r�r�r�rzrr�rrrr�sz TestCallbackMeddleArgs.process_ncCs"|�gd�dddgiddg�dS)N)r�r`r�rar��quxrr�)rar�rrvr�rCrrrr�test_callback_meddle_args�s

�z0TestCallbackMeddleArgs.test_callback_meddle_argscCs|�gd�ddgidg�dS)N)z-2r`rZr)r`rZryrCrrrr�#test_callback_meddle_args_separator�s
�z:TestCallbackMeddleArgs.test_callback_meddle_args_separatorN)rrr rRrrrrrrrr
�s
r
c@r�)�TestCallbackManyArgsc	Cs<tdddd|jdd�tdddd	|jd
d�g}t|d�|_dS)Nr�r�r|ryr�)rdrzr|rEr^�--bobr�rjry)r�process_manyrr)r6rrrrR�s
�
��zTestCallbackManyArgs.setUpcCsd|dkr|�|d�dS|dkr|�|d�dS|dkr$|�|d�dS|dkr0|�|d�dSdS)	Nr�r_r�)�ding�dongr^r
r)if���r�r�r,r�rrrr�s�z!TestCallbackManyArgs.process_manycCs|�gd�ddd�g�dS)N)r�r`rar�rrr^r��2r�rz-666r��0)r�ZbobrCrrrr�test_many_args�s
�z#TestCallbackManyArgs.test_many_argsN)rrr rRrr rrrrr�s
rc@r�)�TestCallbackCheckAbbrevcCs t�|_|jjdd|jd�dS)N�	--foo-barr|r})rr)r��check_abbrevrrrrrR�s

�zTestCallbackCheckAbbrev.setUpcCs|�|d�dS)Nr"r�rr�r�r�r)rrrr#�rz$TestCallbackCheckAbbrev.check_abbrevcCs|�dgig�dS)Nr0rCrrrr�test_abbrev_callback_expansion�r�z6TestCallbackCheckAbbrev.test_abbrev_callback_expansionN)rrr rRr#r%rrrrr!�sr!c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TestCallbackVarArgsc	CsBtddddd�tdddd	�td
dd|jd
d�g}tt|d�|_dS)Nr�rjryrB)rErzr�r^r�rWr�r��
--callbackr|�crr3)r�
variable_argsr!r
r)r6rrrrR�s���zTestCallbackVarArgs.setUpcCs�|�|du�g}|j}|r?|d}|dd�dkr t|�dks4|dd�dkr5t|�dkr5|ddkr5n
|�|�|d=|st|j|j|�dS)NrryrZrvrn)r5rr	r1r�r�r�)rr�r�r�r)r�argrrrr)�s(
�z!TestCallbackVarArgs.variable_argscCs"|�gd�ddddgd�g�dS)N)z-a3rRr'r`ra)r�rSr`ra�rBrWr(rCrrrr�test_variable_args�rGz&TestCallbackVarArgs.test_variable_argscCs$|�gd�ddgd�d�dg�dS)N)r��37rZ�xxxr^�helloT)r-rZr.r+r/rCrrrr�%test_consume_separator_stop_at_option��
��z9TestCallbackVarArgs.test_consume_separator_stop_at_optioncCs$|�gd�ddgd�d�dg�dS)N)r/r�r`rnra)r`rnrar+r/rCrrrr�%test_positional_arg_and_variable_args�r1z9TestCallbackVarArgs.test_positional_arg_and_variable_argscCs |�gd�dddgd�g�dS)N)r�r`r^Tr`r+rCrrrr�test_stop_at_option�r^z'TestCallbackVarArgs.test_stop_at_optioncCr�)N)r�r�rRr�zno such option: -5r8rrrr�test_stop_at_invalid_optionr�z/TestCallbackVarArgs.test_stop_at_invalid_optionN)
rrr rRr)r,r0r2r3r4rrrrr&�sr&c@r�)�ConflictBasecCs&tdddddd�g}tt|d�|_dS)Nr�r�rir�zincrement verbosity�rdr�rr3r5r6rrrrR
s��zConflictBase.setUpcCsd|j_dS)Nrv)r��show_versionr$rrrr7r%zConflictBase.show_versionN)rrr rRr7rrrrr5	sr5c@r�)�TestConflictz9Use the default conflict resolution for Optik 1.2: error.cCs<|�|dd|jdd�td�}|�|jd�|�|jd�dS)N)r�r
r|�show version�rdr|rz5option -v/--version: conflicting option string(s): -vz conflicting option string(s): -vz-v/--version)r=r7rr,r#Z	option_id)rr9r<rrr�assertTrueconflict_errors��z%TestConflict.assertTrueconflict_errorcCs|�|jj�dSr)r;r)r�rrrr�test_conflict_error r:z TestConflict.test_conflict_errorcCst|jd�}|�|j�dS)NzGroup 1)r	r)r;r�r�rrr�test_conflict_error_group#sz&TestConflict.test_conflict_error_groupcCr�)Nr�z'invalid conflict_resolution value 'foo')r=r)�set_conflict_handlerr�rrrr�test_no_such_conflict_handler's
�z*TestConflict.test_no_such_conflict_handlerN)rrr rr;r<r=r?rrrrr8sr8c@r�)�TestConflictResolvecCs2t�|�|j�d�|jjddd|jdd�dS)N�resolver�r
r|r9r:)r5rRr)r>r�r7rrrrrR.s


�zTestConflictResolve.setUpcCs�|j�d�}|j�d�}|j�d�}|�||u�|�||u�|�|jdg�|�|jdg�|�|jdg�|�|jg�|�|jdg�dS)Nr�r�r
)r)r�r5r,r�r�)rr�Zverbose_optZversion_optrrr�test_conflict_resolve4sz)TestConflictResolve.test_conflict_resolvecCr7)Nr	z}Options:
  --verbose      increment verbosity
  -h, --help     show this help message and exit
  -v, --version  show version
�rGrrrr�test_conflict_resolve_helpAr:z.TestConflictResolve.test_conflict_resolve_helpcCs|�dgddd�g�dS)Nr�rv�r�r7rCrrrr�test_conflict_resolve_short_optIs�z3TestConflictResolve.test_conflict_resolve_short_optcCr�)Nr�r�rvrCrrrr�test_conflict_resolve_long_optN��z2TestConflictResolve.test_conflict_resolve_long_optcCs|�ddgddd�g�dS)Nr�r
rvrErCrrrr�test_conflict_resolve_long_optsSrz3TestConflictResolve.test_conflict_resolve_long_optsN)	rrr rRrBrDrFrGrIrrrrr@-s
r@c@r�)
�TestConflictOverridecCsJttd�|_|j�d�|jjdddddd�|jjddd	d
ddd�dS)
NrOrAr��	--dry-runr��dry_runzdon't do anythingr6r�r�zdry run mode)rdrwr�r)r!r
r)r>r�rrrrrRYs
�

�zTestConflictOverride.setUpcCs0|j�d�}|�|jdg�|�|jdg�dS)NrKr�)r)r�r,r�r�r�rrr�test_conflict_override_optscsz0TestConflictOverride.test_conflict_override_optscCr7)Nr	zXOptions:
  -h, --help     show this help message and exit
  -n, --dry-run  dry run mode
rCrrrr�test_conflict_override_helphr:z0TestConflictOverride.test_conflict_override_helpcCr�)Nr�rLr�rCrrrr�test_conflict_override_argsorHz0TestConflictOverride.test_conflict_override_argsN)rrr rRrMrNrOrrrrrJXs

rJaSUsage: bar.py [options]

Options:
  -a APPLE           throw APPLEs at basket
  -b NUM, --boo=NUM  shout "boo!" NUM times (in order to frighten away all the
                     evil spirits that cause trouble and mayhem)
  --foo=FOO          store FOO in the foo list for later fooing
  -h, --help         show this help message and exit
aSUsage: bar.py [options]

Options:
  -a APPLE           throw APPLEs at basket
  --boo=NUM, -b NUM  shout "boo!" NUM times (in order to frighten away all the
                     evil spirits that cause trouble and mayhem)
  --foo=FOO          store FOO in the foo list for later fooing
  --help, -h         show this help message and exit
aWUsage
=====
  bar.py [options]

Options
=======
-a APPLE           throw APPLEs at basket
--boo=NUM, -b NUM  shout "boo!" NUM times (in order to frighten away all the
                   evil spirits that cause trouble and mayhem)
--foo=FOO          store FOO in the foo list for later fooing
--help, -h         show this help message and exit
a}Usage: bar.py [options]

Options:
  -a APPLE           throw APPLEs at basket
  -b NUM, --boo=NUM  shout "boo!" NUM times (in order to
                     frighten away all the evil spirits
                     that cause trouble and mayhem)
  --foo=FOO          store FOO in the foo list for later
                     fooing
  -h, --help         show this help message and exit
a~Usage: bar.py [options]

Options:
  -a APPLE
    throw
    APPLEs at
    basket
  -b NUM, --boo=NUM
    shout
    "boo!" NUM
    times (in
    order to
    frighten
    away all
    the evil
    spirits
    that cause
    trouble and
    mayhem)
  --foo=FOO
    store FOO
    in the foo
    list for
    later
    fooing
  -h, --help
    show this
    help
    message and
    exit
c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�TestHelpcCs|�d�|_dS)N�P)�make_parserr)rrrrrR�rzTestHelp.setUpc	Csxtdddddd�tddd	d
ddd�td
ddddd�g}t���}t|�|d<t|d�Wd�S1s5wYdS)Nr�r�rBZAPPLEzthrow APPLEs at basket)rEr��metavarrr^r-rjr.ZNUMzeshout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem)r0r1r`z*store FOO in the foo list for later fooing)rdrEr�r�COLUMNSry)rr�EnvironmentVarGuardr1r!)r�columnsr/�envrrrrR�s�
�
��
$�zTestHelp.make_parserc
CsVtjdd�}ztj�dd�tjd<|�dg|�W|tjdd�<dS|tjdd�<w)Nr`zbar.pyrr	)rBrrrrrG)rr@rrrr�assertHelpEquals�s
"zTestHelp.assertHelpEqualscCs|�t�dSr)rX�_expected_help_basicrrrr�	test_help�szTestHelp.test_helpcCs|j�d�|�t�dS)NzUsage: %prog [options])r)Z	set_usagerXrYrrrr�test_help_old_usage�szTestHelp.test_help_old_usagecCsd|jj_|�t�dS)Nr)r)r(Zshort_firstrX�_expected_help_long_opts_firstrrrr�test_help_long_opts_first�s
z"TestHelp.test_help_long_opts_firstcCsJt���}d|d<t�|j_|�t�Wd�dS1swYdS)NZ80rT)rrUrr)r(rX�_expected_help_title_formatter)rrWrrr�test_help_title_formatter�s


"�z"TestHelp.test_help_title_formattercCs0|�d�|_|�t�|�d�|_|�t�dS)Nr�r)rRr)rX�_expected_help_short_lines�_expected_very_help_short_linesrrrr�test_wrap_columns�s
zTestHelp.test_wrap_columnscCs0ttd�|_|jjdddd�d}|�|�dS)NrOr�r��olé!r�uKOptions:
  -h, --help  show this help message and exit
  -a          olé!
)r!r
r)r�rX�r�expectrrr�test_help_unicodeszTestHelp.test_help_unicodecCs ttdd�|_d}|�|�dS)Nrc)rPr�u>olé!

Options:
  -h, --help  show this help message and exit
)r!r
r)rXrdrrr�test_help_unicode_descriptions
�z&TestHelp.test_help_unicode_descriptioncCs^|j�d�t|jdd�}|jdddd�|j�|�d}|�|�d	|j_|�|d
�dS)Nz`This is the program description for %prog.  %prog has an option group as well as single options.zDangerous OptionszZCaution: use of these options is at your own risk.  It is believed that some of them bite.z-gr�z
Group option.r�aTUsage: bar.py [options]

This is the program description for bar.py.  bar.py has an option group as
well as single options.

Options:
  -a APPLE           throw APPLEs at basket
  -b NUM, --boo=NUM  shout "boo!" NUM times (in order to frighten away all the
                     evil spirits that cause trouble and mayhem)
  --foo=FOO          store FOO in the foo list for later fooing
  -h, --help         show this help message and exit

  Dangerous Options:
    Caution: use of these options is at your own risk.  It is believed
    that some of them bite.

    -g               Group option.
z Please report bugs to /dev/null.z"
Please report bugs to /dev/null.
)r)Zset_descriptionr	r�r�rXZepilog)rr�rerrr�test_help_description_groupss��
z%TestHelp.test_help_description_groupsN)rrr rRrRrXrZr[r]r_rbrfrgrhrrrrrP�s		
rPc@r�)�TestMatchAbbrevc	Cs |�tdddddd��d�dS)N�--f)rbr0�--fierj)r,rrrrr�test_match_abbrev@s���z!TestMatchAbbrev.test_match_abbrevcCs*d}dddd�}|�t||fdtd�dS)Nrj)rbr0rkz,ambiguous option: --f (--fie, --foo, --foz?))r=rr
)rr�Zwordmaprrr�test_match_abbrev_errorHs
�z'TestMatchAbbrev.test_match_abbrev_errorN)rrr rlrmrrrrri?sric@r�)
�TestParseNumbercCs,t�|_|jjdtd�|jjdtd�dS)Nr�r��-l)r!r)r�rjrrrrrRQszTestParseNumber.setUpc	Cs<|�tdtfitt�d��|�tdtfitt�d��dS)Nroz!invalid literal for int().*: '?'?Z0xOoopsz*invalid literal for int().*: s?'?0xOoops'?)r=rrjr�r3�compilerrrr�test_parse_num_failVs
�
�z#TestParseNumber.test_parse_num_failcCsp|�tdt�d�|�tdt�d�|�tdt�d�|�tdt�d�|�td	t�d
�|�tdt�d�dS)NrrZ0x10�Z0XA�
Z010�Z0b11r�Z0b)r,rrjrrrr�test_parse_num_ok`sz!TestParseNumber.test_parse_num_okcCs`|�gd�ddd�g�|�gd�ddd�g�|�dgd	�|�d
gd�|�dd
gd�dS)N)r�r�roZ0x20r�� )r��l)r�Z0b0101z-l010rsrtz-n008z'option -n: invalid integer value: '008'z-l0b0123z*option -l: invalid integer value: '0b0123'roZ0x12xz)option -l: invalid integer value: '0x12x')r0rArrrr�test_numeric_optionshs

�

���
�z$TestParseNumber.test_numeric_optionsN)rrr rRrqrurxrrrrrnPs

rnc@seZdZdd�ZdS)�MiscTestCasecCshd�}tj|t|d�dS)N>Z
check_builtinZ
NO_DEFAULTZAmbiguousOptionError)�not_exported)rZcheck__all__�optparse)rrzrrr�test__all__vszMiscTestCase.test__all__N)rrr r|rrrrryusry�__main__)HrBrr3r�Zunittest�iorrrZtest.supportrr{rrrrr	r
rrr
rrrr�	Exceptionrr!ZTestCaser(rLr�r�r�r�r�r�r�r�r
r,rwr�r�r�r�r�r�r�r�r�r�rr
rr!r&r5r8r@rJrYr\r^r`rarPrirnryr�mainrrrr�<module>sz4
O
3*N#:"+65
+
!w%
�