Your IP : 216.73.217.129


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_getopt.cpython-35.opt-2.pyc



���]��@spddlmZmZmZddlZddlZe�ZGdd�dej�Z	e
dkrlej�dS)�)�verbose�run_doctest�EnvironmentVarGuardNc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�GetoptTestscCs)t�|_d|jkr%|jd=dS)N�POSIXLY_CORRECT)r�env)�self�r	�0/opt/alt/python35/lib64/python3.5/test_getopt.py�setUpszGetoptTests.setUpcCs|jj�|`dS)N)r�__exit__)rr	r	r
�tearDowns
zGetoptTests.tearDowncOs|jtj||�dS)N)�assertRaises�getopt�GetoptError)r�args�kwargsr	r	r
�assertErrorszGetoptTests.assertErrorcCsL|jtjdd��|jtjdd��|jtjdd�dS)N�aza:�b)�
assertTruerZ
short_has_arg�assertFalser)rr	r	r
�test_short_has_argszGetoptTests.test_short_has_argcCs�tjddg�\}}|j|�|j|d�tjddg�\}}|j|�|j|d�tjddg�\}}|j|�|j|d�|jtjddg�|jtjdg�|jtjdddg�dS)N�abczabc=�abcd�defZabcde)rZ
long_has_argsr�assertEqualrr)rZhas_arg�optionr	r	r
�test_long_has_argss


zGetoptTests.test_long_has_argscCsLtjgddg�\}}|j|dg�|j|g�tjgddg�\}}|j|d	g�|j|g�tjgdddg�\}}|j|d
g�|j|g�tjgddddg�\}}|j|dg�|j|dg�|jtjgddg�|jtjgddg�dS)Nr�-a�Za1za:�1�2)rr )rr!)rr!)rr!)rZ	do_shortsrr)r�optsrr	r	r
�test_do_shorts.s!$zGetoptTests.test_do_shortscCs�tjgddgg�\}}|j|dg�|j|g�tjgddgg�\}}|j|dg�|j|g�tjgddgg�\}}|j|dg�|j|g�tjgdd	dd
gg�\}}|j|dg�|j|g�tjgddd
gg�\}}|j|dg�|j|g�|jtjgddgg�|jtjgddgg�dS)Nr�--abcr zabc=1zabc=r!zabcd=�--abcd�abrzfoo=42zfoo-barzfoo=�--foo�42)r%r )r%r!)r&r!)r%r )r(r))rZdo_longsrr)rr#rr	r	r
�
test_do_longsFs"!!!'$zGetoptTests.test_do_longscCs�dddddddddddd	g}tj|d
ddg�\}}|j|dddddddg�|j|dd	g�|jtj|d
ddg�dS)N�-ar!�-bz	--alpha=2�--beta�3r �arg1Zarg2za:bzalpha=�beta�--alphar"�alpha)r+r!)r,r )r1r")r-r )r+r.)r+r )r-r )rrr)r�cmdliner#rr	r	r
�test_getoptas!zGetoptTests.test_getoptcCsoddddddg}tj|ddd	g�\}}|j|dg�|j|ddddg�tjdd
dd
gdg�\}}|j|d
g�|j|ddg�tj|ddd	g�\}}|j|dg�|j|dddddg�d|jd<tj|ddd	g�\}}|j|dg�|j|dddddg�dS)N�-ar/�-br!�--alphaz--beta=2zab:r2zbeta=r �--betar"�-z+ab:r)r5r )r6r!)r7r )r8r")r5r )r6r9)r5r )r5r )rZ
gnu_getoptrr)rr3r#rr	r	r
�test_gnu_getoptrs!
'!
!zGetoptTests.test_gnu_getoptcCs5d}ddl}|jd|�}t|t�dS)Na�
        Examples from the Library Reference:  Doc/lib/libgetopt.tex

        An example using only Unix style options:


        >>> import getopt
        >>> args = '-a -b -cfoo -d bar a1 a2'.split()
        >>> args
        ['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']
        >>> optlist, args = getopt.getopt(args, 'abc:d:')
        >>> optlist
        [('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]
        >>> args
        ['a1', 'a2']

        Using long option names is equally easy:


        >>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'
        >>> args = s.split()
        >>> args
        ['--condition=foo', '--testing', '--output-file', 'abc.def', '-x', 'a1', 'a2']
        >>> optlist, args = getopt.getopt(args, 'x', [
        ...     'condition=', 'output-file=', 'testing'])
        >>> optlist
        [('--condition', 'foo'), ('--testing', ''), ('--output-file', 'abc.def'), ('-x', '')]
        >>> args
        ['a1', 'a2']
        rZ
libreftest)�types�
ModuleTyperr)r�sr;�mr	r	r
�test_libref_examples�sz GetoptTests.test_libref_examplescCs�tjdgddg�\}}|j|dg�tjdgddg�\}}|j|d	g�|jtjtjdgddg�dS)
Nz--help=r zhelp=�--helpz--help=x�x�help)r@r )r@rA)rrrr)rZlongoptsZ	shortoptsr	r	r
�test_issue4629�s
!!zGetoptTests.test_issue4629N)�__name__�
__module__�__qualname__rr
rrrr$r*r4r:r?rCr	r	r	r
rs$r�__main__)Ztest.supportrrrZunittestr�object�sentinelZTestCaserrD�mainr	r	r	r
�<module>s	�