Your IP : 216.73.216.85


Current Path : /opt/alt/python38/lib64/python3.8/test/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/test/__pycache__/test_getopt.cpython-38.opt-1.pyc

U

i�f��@sPddlmZmZmZddlZddlZe�ZGdd�dej�Z	e
dkrLe��dS)�)�verbose�run_doctest�EnvironmentVarGuardNc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�GetoptTestscCst�|_d|jkr|jd=dS)N�POSIXLY_CORRECT)r�env��self�r
�5/opt/alt/python38/lib64/python3.8/test/test_getopt.py�setUps
zGetoptTests.setUpcCs|j��|`dS�N)r�__exit__rr
r
r�tearDowns
zGetoptTests.tearDowncOs|jtjf|�|�dSr
)�assertRaises�getopt�GetoptError)r	�args�kwargsr
r
r�assertErrorszGetoptTests.assertErrorcCs8|�t�dd��|�t�dd��|�tjdd�dS)N�a�a:�b)�
assertTruerZ
short_has_arg�assertFalserrr
r
r�test_short_has_argszGetoptTests.test_short_has_argcCs�t�ddg�\}}|�|�|�|d�t�ddg�\}}|�|�|�|d�t�ddg�\}}|�|�|�|d�|�tjddg�|�tjdg�|�tjdddg�dS)N�abc�abc=�abcd�defZabcde)rZ
long_has_argsr�assertEqualrr)r	Zhas_argZoptionr
r
r�test_long_has_argss


zGetoptTests.test_long_has_argscCs�t�gddg�\}}|�|dg�|�|g�t�gddg�\}}|�|dg�|�|g�t�gdddg�\}}|�|dg�|�|g�t�gddddg�\}}|�|dg�|�|dg�|�tjgddg�|�tjgddg�dS)Nr��-a�Za1r�r#�1r&�2)rZ	do_shortsr r�r	�optsrr
r
r�test_do_shorts.szGetoptTests.test_do_shortscCs&t�gddgg�\}}|�|dg�|�|g�t�gddgg�\}}|�|dg�|�|g�t�gddgg�\}}|�|dg�|�|g�t�gdddd	gg�\}}|�|dg�|�|g�t�gd
ddgg�\}}|�|d
g�|�|g�|�tjgddgg�|�tjgddgg�dS)Nr)�--abcr$zabc=1r)r+r&zabcd=)z--abcdr&Zabrzfoo=42zfoo-barzfoo=)z--fooZ42)rZdo_longsr rr(r
r
r�
test_do_longsFs"zGetoptTests.test_do_longscCsvdddddddddddd	g}t�|d
ddg�\}}|�|d
ddddddg�|�|dd	g�|�tj|d
ddg�dS)Nr#r&�-bz	--alpha=2�--beta�3r$�arg1Zarg2za:bzalpha=Zbetar%)r-r$)�--alphar')r.r$)r#r/r"�alpha)rr r�r	Zcmdliner)rr
r
r�test_getoptas �
�zGetoptTests.test_getoptcCsddddddg}t�|ddd	g�\}}|�|dg�|�|d
ddd
g�t�ddddgdg�\}}|�|dg�|�|d
dg�t�|ddd	g�\}}|�|d
g�|�|dddddg�d|jd<t�|ddd	g�\}}|�|d
g�|�|dddddg�dS)Nr#r0r-r&r1z--beta=2zab:r2zbeta=r")r-r&)r1r$)r.r'�-)r-r5z+ab:r)rZ
gnu_getoptr rr3r
r
r�test_gnu_getoptrs"
�
zGetoptTests.test_gnu_getoptcCs&d}ddl}|�d|�}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	�sr7�mr
r
r�test_libref_examples�sz GetoptTests.test_libref_examplescCsft�dgddg�\}}|�|dg�t�dgddg�\}}|�|dg�|�tjtjdgddg�dS)Nz--help=r$zhelp=)�--helpr$z--help=x)r<�x�help)rr rr)r	ZlongoptsZ	shortoptsr
r
r�test_issue4629�s
zGetoptTests.test_issue4629N)�__name__�
__module__�__qualname__rrrrr!r*r,r4r6r;r?r
r
r
rrs$r�__main__)Ztest.supportrrrZunittestr�object�sentinelZTestCaserr@�mainr
r
r
r�<module>s-