HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_getopt.cpython-37.pyc
B

��g��@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	�,/usr/local/lib/python3.7/test/test_getopt.py�setUps
zGetoptTests.setUpcCs|j��|`dS)N)r�__exit__)rr	r	r
�tearDowns
zGetoptTests.tearDowncOs|jtjf|�|�dS)N)�assertRaises�getopt�GetoptError)r�args�kwargsr	r	r
�assertErrorszGetoptTests.assertErrorcCs8|�t�dd��|�t�dd��|�tjdd�dS)N�aza:�b)�
assertTruerZ
short_has_arg�assertFalser)rr	r	r
�test_short_has_argszGetoptTests.test_short_has_argcCs�t�ddg�\}}|�|�|�|d�t�ddg�\}}|�|�|�|d�t�ddg�\}}|�|�|�|d�|�tjddg�|�tjdg�|�tjdddg�dS)N�abczabc=�abcd�defZabcde)rZ
long_has_argsr�assertEqualrr)rZhas_arg�optionr	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)z-a�Za1za:)z-a�1r �2)rZ	do_shortsrr)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)z--abcrzabc=1zabc=)z--abcr zabcd=)z--abcdr Zabrzfoo=42zfoo-barzfoo=)z--fooZ42)rZdo_longsrr)rr"rr	r	r
�
test_do_longsFs"zGetoptTests.test_do_longscCsvdddddddddddd	g}t�|d
ddg�\}}|�|d
ddddddg�|�|dd	g�|�tj|d
ddg�dS)Nz-ar z-bz	--alpha=2z--beta�3r�arg1Zarg2za:bzalpha=Zbeta)z-ar )z-br)z--alphar!)z--betar)z-ar%)z-ar�alpha)rrr)r�cmdliner"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)Nz-ar&z-br z--alphaz--beta=2zab:r'zbeta=)z-ar)z-br )z--alphar)z--betar!�-)z-br*z+ab:r)rZ
gnu_getoptrr)rr(r"rr	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�sr,�mr	r	r
�test_libref_examples�sz GetoptTests.test_libref_examplescCsft�dgddg�\}}|�|dg�t�dgddg�\}}|�|dg�|�tjtjdgddg�dS)Nz--help=rzhelp=)z--helprz--help=x)z--help�x�help)rrrr)rZlongoptsZ	shortoptsr	r	r
�test_issue4629�s
zGetoptTests.test_issue4629N)�__name__�
__module__�__qualname__rr
rrrr#r$r)r+r0r3r	r	r	r
rs$r�__main__)Ztest.supportrrrZunittestr�object�sentinelZTestCaserr4�mainr	r	r	r
�<module>s-