Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_getopt.cpython-34.pyo

�
g f8�@s�ddlmZmZmZmZddlZddlZe�ZGdd�dej	�Z
dd�Zedkr~e�ndS)�)�verbose�run_doctest�run_unittest�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=ndS)N�POSIXLY_CORRECT)r�env)�self�r
�5/opt/alt/python34/lib64/python3.4/test/test_getopt.py�setUpszGetoptTests.setUpcCs|jj�|`dS)N)r�__exit__)r	r
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)r	r
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)r	Zhas_argZoptionr
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=�--abcdZabrzfoo=42zfoo-barzfoo=�--foo�42)r%r )r%r!)r&r!)r%r )r'r()rZdo_longsrr)r	r#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=Zbeta�--alphar"�alpha)r*r!)r+r )r/r")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:r0zbeta=r �--betar"�-z+ab:r)r3r )r4r!)r5r )r6r")r3r )r4r7)r3r )r3r )rZ
gnu_getoptrr)r	r1r#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	�sr9�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>r?)rrrr)r	ZlongoptsZ	shortoptsr
r
r�test_issue4629�s
!!zGetoptTests.test_issue4629N)�__name__�
__module__�__qualname__rrrrrr$r)r2r8r=rAr
r
r
rrs$rcCstt�dS)N)rrr
r
r
r�	test_main�srE�__main__)
Ztest.supportrrrrZunittestr�object�sentinelZTestCaserrErBr
r
r
r�<module>s"	�