Sindbad~EG File Manager
�
'Μgg���ddlmZddlZddlZddlZe�ZGd�dej�Zd�Z d�Z
edk(rej�yy)�)�EnvironmentVarGuardNc�B�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d �Zy
)�GetoptTestsc�x�|jt��|_d|jvr|jd=yy)N�POSIXLY_CORRECT)�enterContextr�env��selfs �-/usr/local/lib/python3.12/test/test_getopt.py�setUpzGetoptTests.setUp
s6���$�$�%8�%:�;�������(����*�+�)�c�L�|jtjg|��i|��y�N)�assertRaises�getopt�GetoptError)r�args�kwargss r�assertErrorzGetoptTests.assertErrors"������&�,�,�>�t�>�v�>rc���|jtjdd��|jtjdd��|j tjdd�y)N�a�a:�b)�
assertTruer�
short_has_arg�assertFalserr
s r�test_short_has_argzGetoptTests.test_short_has_argsN������,�,�S�$�7�8�����-�-�c�3�7�8�����-�-�s�C�8rc�>�tjddg�\}}|j|�|j|d�tjddg�\}}|j |�|j|d�tjddg�\}}|j |�|j|d�|jtjddg�|jtjdg�|jtjdddg�y)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�����-�-�u�v�g�6F�Grc��tjgddg�\}}|j|dg�|j|g�tjgddg�\}}|j|dg�|j|g�tjgdddg�\}}|j|dg�|j|g�tjgddddg�\}}|j|dg�|j|dg�|jtjgddg�|jtjgddg�y)Nr��-a��a1r�r,�1r0�2)r� do_shortsr&r�r�optsrs r�test_do_shortszGetoptTests.test_do_shorts+s4���%�%�b�#�s�B�7�
��d�����
�|�,�����r�"��%�%�b�$��b�9�
��d������}�-�����r�"��%�%�b�#�t�c�U�;�
��d������}�-�����r�"��%�%�b�#�t�c�3�Z�@�
��d������}�-������u�%�����)�)�2�t�S�"�=�����)�)�2�s�D�"�=rc�"�tjgddgg�\}}|j|dg�|j|g�tjgddgg�\}}|j|dg�|j|g�tjgddgg�\}}|j|dg�|j|g�tjgdgd�g�\}}|j|dg�|j|g�tjgd d
dgg�\}}|j|dg�|j|g�|jtjgddgg�|jtjgddgg�y)
Nr )�--abcr-zabc=1r!)r7r0zabcd=)z--abcdr0)�abr r"zfoo=42zfoo-barzfoo=)z--foo�42)r�do_longsr&rr3s r�
test_do_longszGetoptTests.test_do_longsCsm���_�_�R�����<�
��d�����
��/�����r�"��_�_�R��6�(�B�?�
��d������/�0�����r�"��_�_�R��7�)�R�@�
��d������0�1�����r�"��_�_�R��0E�r�J�
��d�����
��/�����r�"�
�_�_�R��I�v�3G��L�
��d������0�1�����r�"�������"�g��w��C�������"�e�f�X�r�Brc���gd�}tj|dddg�\}}|j|gd��|j|ddg�|jtj|dddg�y) N)r,r0�-bz --alpha=2�--betar,�3r,r-r>�arg1�arg2za:bzalpha=�beta)r/)r=r-)�--alphar1�r>r-)r,r?r+rDr@rA�alpha)rr&r�r�cmdliner4rs r�test_getoptzGetoptTests.test_getopt^sq��1���]�]�7�E�H�f�3E�F�
��d����� I� J�
������/�0����������&�8I�Jrc�B�gd�}tj|dddg�\}}|j|dg�|j|gd��tjgd�dg�\}}|j|dg�|j|d d
g�tj|dddg�\}}|j|d g�|j|gd��d
|jd<tj|dddg�\}}|j|d g�|j|gd��y)N)r,r@r=r0rC�--beta=2zab:rEzbeta=r@)r+)r=r0)rCr-)r>r1)r,�-r=rKrKr+)r=rKz+ab:)r@r=r0rCrJr0r)r�
gnu_getoptr&r rFs r�test_gnu_getoptzGetoptTests.test_gnu_getoptos$��B���&�&�w����7I�J�
��d������x�(����� B� C��&�&�'=�u�b�I�
��d������u�%�����
�K�8�9��&�&�w���'�8J�K�
��d�����
�|�,�����I�J�'*����"�#��&�&�w����7I�J�
��d�����
�|�,�����I�Jrc�&�tjdgddg�\}}|j|dg�tjdgddg�\}}|j|dg�|jtjtjdgddg�y)Nz--help=r-zhelp=)�--helpr-z--help=x)rO�x�help)rr&rr)r�longopts� shortoptss r�test_issue4629zGetoptTests.test_issue4629�s���$�m�m�Y�K��g�Y�G���)�����N�#3�4�$�m�m�Z�L�"�w�i�H���)�����O�#4�5����&�,�,�f�m�m�i�[�"�v�h�WrN)�__name__�
__module__�__qualname__r
rrr)r5r;rHrMrT�rrrrs4��,�
?�9�
H�">�0C�6K�"K�4Xrrc��y)a~
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']
NrXrXrr�test_libref_examplesrZ�s�rc�L�|jtj��|Sr)�addTest�doctest�DocTestSuite)�loader�tests�patterns r�
load_testsrb�s�� �M�M�'�&�&�(�)��Lr�__main__)
�test.support.os_helperrr]�unittestr�object�sentinel�TestCaserrZrbrU�mainrXrr�<module>rjsV��7���
��8��BX�(�#�#�BX�H�@�
�z���H�M�M�O�r
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists