
    0hh                     P   S SK r S SKrS SKrS SKrS SKJrJr  S SKJr  \	" 5       r
 " S S\R                  5      rS r " S S\5      rS	 r\S
:X  aU  \" \R$                  5      S:  a-  \R$                  S   S:X  a  \" \5        \R&                  " S 5        \R(                  " 5         gg)    N)TestTranslationsBaseupdate_translation_snapshots)EnvironmentVarGuardc                   J    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rSrg)GetoptTests   c                 Z    U R                  [        5       5      U l        U R                  S	 g )NPOSIXLY_CORRECT)enterContextr   envselfs    9/opt/python-3.13.8/usr/lib/python3.13/test/test_getopt.pysetUpGetoptTests.setUp   s%    $$%8%:;HH&'    c                 L    U R                   " [        R                  /UQ70 UD6  g N)assertRaisesgetoptGetoptError)r   argskwargss      r   assertErrorGetoptTests.assertError   s     &,,>t>v>r   c                     U R                  [        R                  " SS5      5        U R                  [        R                  " SS5      5        U R	                  [        R                  SS5        g )Naa:b)
assertTruer   short_has_argassertFalser   r   s    r   test_short_has_argGetoptTests.test_short_has_arg   sN    ,,S$78--c378--sC8r   c                 >   [         R                  " SS/5      u  pU R                  U5        U R                  US5        [         R                  " SS/5      u  pU R	                  U5        U R                  US5        [         R                  " SS/5      u  pU R	                  U5        U R                  US5        U R                  [         R                  SS/5        U R                  [         R                  S/ 5        U R                  [         R                  SSS/5        g )Nabcabc=abcddefabcde)r   long_has_argsr    assertEqualr"   r   )r   has_argoptions      r   test_long_has_argsGetoptTests.test_long_has_args   s     ..uvh? ' ..uug>!' ..uvh?!(--uug>--ub9--uvg6FGr   c                    [         R                  " / SS/ 5      u  pU R                  US/5        U R                  U/ 5        [         R                  " / SS/ 5      u  pU R                  US/5        U R                  U/ 5        [         R                  " / SSS/5      u  pU R                  US/5        U R                  U/ 5        [         R                  " / SSSS/5      u  pU R                  US/5        U R                  US/5        U R                  [         R                  / SS/ 5        U R                  [         R                  / SS/ 5        g )Nr   -a a1r   r3   1r7   2)r   	do_shortsr,   r   r   optsr   s      r   test_do_shortsGetoptTests.test_do_shorts+   s,   %%b#sB7

|,r"%%b$b9
}-r" %%b#tcU;
}-r"%%b#tc3Z@
}-u%))2tS"=))2sD"=r   c                 "   [         R                  " / SS// 5      u  pU R                  US/5        U R                  U/ 5        [         R                  " / SS// 5      u  pU R                  US/5        U R                  U/ 5        [         R                  " / SS// 5      u  pU R                  US/5        U R                  U/ 5        [         R                  " / S/ SQ/ 5      u  pU R                  US/5        U R                  U/ 5        [         R                  " / S	S
S// 5      u  pU R                  US/5        U R                  U/ 5        U R                  [         R                  / SS// 5        U R                  [         R                  / SS// 5        g )Nr&   )--abcr4   zabc=1r'   )r?   r7   zabcd=)z--abcdr7   )abr&   r(   zfoo=42zfoo-barzfoo=)z--foo42)r   do_longsr,   r   r:   s      r   test_do_longsGetoptTests.test_do_longsC   sc   __R<
/r"__R6(B?
/0r"__R7)R@
01r"__R0ErJ
/r"
 __RIv3GL
01r""gwC"efXrBr   c                     / SQn[         R                   " USSS/5      u  p#U R                  U/ SQ5        U R                  USS/5        U R                  [         R                   USSS/5        g )	N)r3   r7   -bz	--alpha=2--betar3   3r3   r4   rG   arg1arg2za:bzalpha=beta)r6   )rF   r4   )--alphar8   rG   r4   )r3   rH   r2   rM   rI   rJ   alpha)r   r,   r   r   cmdliner;   r   s       r   test_getoptGetoptTests.test_getopt^   so    1 ]]7EHf3EF
  I 	J
 	/0&8IJr   c                 B   / SQn[         R                  " USSS/5      u  p#U R                  US/5        U R                  U/ SQ5        [         R                  " / SQS/ 5      u  p#U R                  US/5        U R                  US	S
/5        [         R                  " USSS/5      u  p#U R                  US	/5        U R                  U/ SQ5        SU R                  S'   [         R                  " USSS/5      u  p#U R                  US	/5        U R                  U/ SQ5        g )N)r3   rI   rF   r7   rL   --beta=2zab:rN   zbeta=rI   )r2   )rF   r7   )rL   r4   )rG   r8   )r3   -rF   rU   rU   r2   )rF   rU   z+ab:)rI   rF   r7   rL   rT   r7   r
   )r   
gnu_getoptr,   r   rO   s       r   test_gnu_getoptGetoptTests.test_gnu_getopto   s   B &&w7IJ
x(  B 	C &&'=ubI
u%
K89 &&w'8JK

|,IJ '*"#&&w7IJ

|,IJr   c                 &   [         R                   " S/SS/5      u  pU R                  US/5        [         R                   " S/SS/5      u  pU R                  US/5        U R                  [         R                  [         R                   S/SS/5        g )Nz--help=r4   zhelp=)--helpr4   z--help=x)rZ   xhelp)r   r,   r   r   )r   longopts	shortoptss      r   test_issue4629GetoptTests.test_issue4629   s~    $mmYKgYGN#34$mmZL"wiHO#45&,,fmmi["vhWr   )r   N)__name__
__module____qualname____firstlineno__r   r   r#   r/   r<   rC   rQ   rW   r_   __static_attributes__ r   r   r   r      s4    (?9
H">0C6K"K4Xr   r   c                      g)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']
Nrf   rf   r   r   test_libref_examplesrh      s    r   c                       \ rS rSrS rSrg)TestTranslations   c                 .    U R                  [        5        g r   )assertMsgidsEqualr   r   s    r   test_translations"TestTranslations.test_translations   s    v&r   rf   N)ra   rb   rc   rd   rn   re   rf   r   r   rj   rj      s    'r   rj   c                 N    UR                  [        R                  " 5       5        U$ r   )addTestdoctestDocTestSuite)loadertestspatterns      r   
load_testsrw      s    	MM'&&()Lr   __main__   z--snapshot-update)rr   r   sysunittesttest.support.i18n_helperr   r   test.support.os_helperr   objectsentinelTestCaser   rh   rj   rw   ra   lenargvexitmainrf   r   r   <module>r      s      
  W 68AX(## AXFB'+ '

 z
388}qSXXa[,??$V,MMO r   