Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_getopt.cpython-311.opt-2.pyc
�

�Ke����ddlmZmZddlmZddlZddlZe��ZGd�dej	��Z
edkrej��dSdS)�)�verbose�run_doctest)�EnvironmentVarGuardNc�J�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZdS)�GetoptTestsc�x�|�t����|_d|jvr
|jd=dSdS)N�POSIXLY_CORRECT)�enterContextr�env��selfs �:/usr/local/apps/python3/lib/python3.11/test/test_getopt.py�setUpzGetoptTests.setUp
sD���$�$�%8�%:�%:�;�;������(�(���*�+�+�+�)�(�c�<�|jtjg|�Ri|��dS)N)�assertRaises�getopt�GetoptError)r
�args�kwargss   r�assertErrorzGetoptTests.assertErrors.�����&�,�>�t�>�>�>�v�>�>�>�>�>rc���|�tjdd����|�tjdd����|�tjdd��dS)N�a�a:�b)�
assertTruer�
short_has_arg�assertFalserrs r�test_short_has_argzGetoptTests.test_short_has_argsc������,�S�$�7�7�8�8�8�����-�c�3�7�7�8�8�8�����-�s�C�8�8�8�8�8rc�j�tjddg��\}}|�|��|�|d��tjddg��\}}|�|��|�|d��tjddg��\}}|�|��|�|d��|�tjddg��|�tjdg��|�tjdddg��dS)N�abc�abc=�abcd�def�abcde)r�
long_has_argsr�assertEqualrr)r
�has_arg�options   r�test_long_has_argszGetoptTests.test_long_has_argss$�� �.�u�v�h�?�?�������� � � ������'�'�'� �.�u�u�g�>�>��������!�!�!������'�'�'� �.�u�v�h�?�?��������!�!�!������(�(�(�����-�u�u�g�>�>�>�����-�u�b�9�9�9�����-�u�v�g�6F�G�G�G�G�Grc���tjgddg��\}}|�|dg��|�|g��tjgddg��\}}|�|dg��|�|g��tjgdddg��\}}|�|dg��|�|g��tjgddddg��\}}|�|dg��|�|dg��|�tjgddg��|�tjgddg��dS)Nr��-a��a1r�r-�1r1�2)r�	do_shortsr'r�r
�optsrs   r�test_do_shortszGetoptTests.test_do_shorts+sp���%�b�#�s�B�7�7�
��d�����
�|�,�,�,�����r�"�"�"��%�b�$��b�9�9�
��d������}�-�-�-�����r�"�"�"��%�b�#�t�c�U�;�;�
��d������}�-�-�-�����r�"�"�"��%�b�#�t�c�3�Z�@�@�
��d������}�-�-�-������u�%�%�%�����)�2�t�S�"�=�=�=�����)�2�s�D�"�=�=�=�=�=rc�j�tjgddgg��\}}|�|dg��|�|g��tjgddgg��\}}|�|dg��|�|g��tjgddgg��\}}|�|dg��|�|g��tjgdgd�g��\}}|�|dg��|�|g��tjgd	d
dgg��\}}|�|dg��|�|g��|�tjgddgg��|�tjgddgg��dS)
Nr!)�--abcr.zabc=1r")r8r1zabcd=)z--abcdr1)�abr!r#zfoo=42zfoo-barzfoo=)z--foo�42)r�do_longsr'rr4s   r�
test_do_longszGetoptTests.test_do_longsCs����_�R�����<�<�
��d�����
��/�/�/�����r�"�"�"��_�R��6�(�B�?�?�
��d������/�0�0�0�����r�"�"�"��_�R��7�)�R�@�@�
��d������0�1�1�1�����r�"�"�"��_�R��0E�0E�0E�r�J�J�
��d�����
��/�/�/�����r�"�"�"�
�_�R��I�v�3G��L�L�
��d������0�1�1�1�����r�"�"�"������"�g��w��C�C�C������"�e�f�X�r�B�B�B�B�Brc���gd�}tj|dddg��\}}|�|gd���|�|ddg��|�tj|dddg��dS)	N)r-r1�-bz	--alpha=2�--betar-�3r-r.r?�arg1�arg2za:bzalpha=�beta)r0)r>r.)�--alphar2�r?r.)r-r@r,rErArB�alpha)rr'r�r
�cmdliner5rs    r�test_getoptzGetoptTests.test_getopt^s���1�1�1���]�7�E�H�f�3E�F�F�
��d����� I� I� I�	J�	J�	J�
	
������/�0�0�0���������&�8I�J�J�J�J�Jrc�r�gd�}tj|dddg��\}}|�|dg��|�|gd���tjgd�dg��\}}|�|dg��|�|d	d
g��tj|dddg��\}}|�|d	g��|�|gd���d
|jd<tj|dddg��\}}|�|d	g��|�|gd���dS)N)r-rAr>r1rD�--beta=2zab:rFzbeta=rA)r,)r>r1)rDr.)r?r2)r-�-r>rLrLr,)r>rLz+ab:)rAr>r1rDrKr1r	)r�
gnu_getoptr'rrGs    r�test_gnu_getoptzGetoptTests.test_gnu_getoptos���B�B�B���&�w����7I�J�J�
��d������x�(�(�(����� B� B� B�	C�	C�	C��&�'=�'=�'=�u�b�I�I�
��d������u�%�%�%�����
�K�8�9�9�9��&�w���'�8J�K�K�
��d�����
�|�,�,�,�����I�I�I�J�J�J�'*���"�#��&�w����7I�J�J�
��d�����
�|�,�,�,�����I�I�I�J�J�J�J�Jrc�h�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']
        r�
libreftest)�types�
ModuleTyperr)r
�srQ�ms    r�test_libref_examplesz GetoptTests.test_libref_examples�s?��
��>	�������\�1�-�-���A�w�����rc�,�tjdgddg��\}}|�|dg��tjdgddg��\}}|�|dg��|�tjtjdgddg��dS)Nz--help=r.zhelp=)�--helpr.z--help=x)rW�x�help)rr'rr)r
�longopts�	shortoptss   r�test_issue4629zGetoptTests.test_issue4629�s���$�m�Y�K��g�Y�G�G���)�����N�#3�4�4�4�$�m�Z�L�"�w�i�H�H���)�����O�#4�5�5�5����&�,�f�m�i�[�"�v�h�W�W�W�W�WrN)
�__name__�
__module__�__qualname__rrrr*r6r<rIrNrUr\�rrrrs�������,�,�,�
?�?�?�9�9�9�
H�H�H�">�>�>�0C�C�C�6K�K�K�"K�K�K�4" �" �" �HX�X�X�X�Xrr�__main__)
�test.supportrr�test.support.os_helperr�unittestr�object�sentinel�TestCaserr]�mainr`rr�<module>ris���.�-�-�-�-�-�-�-�6�6�6�6�6�6�����
�
�
�
��6�8�8��fX�fX�fX�fX�fX�(�#�fX�fX�fX�P�z����H�M�O�O�O�O�O��r