
    ^hi.                         S SK r S SKJr  S SKrS SKrS SKJr  S SKrS SKJrJ	r	  S SK
Jr  S SKr\R                  (       a  S SKJr   " S S5      r " S	 S
\R                   5      rg)    N)StringIO)mock)OptionParserError)basestring_type)Listc                   *    \ rS rSrS r\S 5       rSrg)Email   c                 Z    [        U[        5      (       a  SU;   a  Xl        g [        5       e)N@)
isinstancestr_value
ValueError)selfvalues     S/home/james-whalen/.local/lib/python3.13/site-packages/tornado/test/options_test.py__init__Email.__init__   s"    eS!!cUlK,    c                     U R                   $ Nr   r   s    r   r   Email.value   s    {{r   r   N)__name__
__module____qualname____firstlineno__r   propertyr   __static_attributes__ r   r   r
   r
      s      r   r
   c                       \ 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S 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S rS rS rS rSrg)OptionsTest   c                     [        5       nUR                  SSS9  UR                  SS/5        U R                  UR                  S5        g )NportP   defaultmain.pyz
--port=443  )r   defineparse_command_lineassertEqualr(   r   optionss     r   test_parse_command_line#OptionsTest.test_parse_command_line   s@    .vr*""I|#<=s+r   c                     [        5       nUR                  SSS9  UR                  SSS9  UR                  S5        [        R                  R	                  [        R                  R                  [        R                  R                  [        5      5      S5      nUR                  U5        U R                  UR                  S5        U R                  UR                  S	5        U R                  UR                  U5        g )
Nr(   r)   r*   usernamefoomy_pathoptions_test.cfgr-   u   李康)r   r.   ospathjoindirnameabspath__file__parse_config_filer0   r(   r6   r8   )r   r2   config_paths      r   test_parse_config_file"OptionsTest.test_parse_config_file$   s    .vr*z51y!ggllGGOOBGGOOH568J
 	!!+.s+))84+6r   c                 p  ^  [        5       nST l        U 4S jnUR                  U5        UR                  S/SS9  T R	                  T R                  5        UR                  S/5        T R                  T R                  5        ST l        UR                  S/5        T R                  T R                  5        g )NFc                     > ST l         g )NTcalledr   s   r   callback2OptionsTest.test_parse_callbacks.<locals>.callback5   s
    DKr   r,   )final)r   rG   add_parse_callbackr/   assertFalse
assertTrue)r   r2   rH   s   `  r   test_parse_callbacks OptionsTest.test_parse_callbacks1   s    .	 	""8, 	""I;e"<% 	""I;/$ ""I;/$r   c                 z   [        5       n [        R                  n[        5       [        l        U R	                  [
        5         UR                  SS/5        S S S 5        [        R                  R                  5       nU[        l        U R                  SU5        g ! , (       d  f       NJ= f! W[        l        f = f)Nr,   z--helpzUsage:)	r   sysstderrr   assertRaises
SystemExitr/   getvalueassertIn)r   r2   orig_stderrusages       r   	test_helpOptionsTest.test_helpH   s    .	%**K!CJ"":.**Ix+@A /JJ'')E$CJh& /. %CJs#   8B- B&B- 
B*&B- -B:c                 x   [        5       nUR                  SSS9  [        5       nUR                  S[        S9  UR                  / SQ5      nU R	                  USS/5        U R                  UR                  5        UR                  U5      nU R	                  U/ 5        U R	                  UR                  S	5         [        R                  n[        5       [        l	        U R                  [        5         UR                  SS
/5        S S S 5        U[        l	        g ! , (       d  f       N= f! W[        l	        f = f)NverboseFr*   r7   type)r,   	--verbose
subcommand	--foo=barr`   ra   barr_   )r   r.   r   r/   r0   rM   r\   r7   rQ   rR   r   rS   r   )r   base_optionssub_optionsrestrest2rW   s         r   test_subcommandOptionsTest.test_subcommandT   s    #~Iu5"n5s+..?
 	k:;,,-..t4#%0	%**K!CJ""5)..k/JK * %CJ *) %CJs$   ;8D, 3DD, 
D)%D, ,D9c                     [        5       nUR                  SS[        S9  SUl        U R	                  UR                  S5        g Nr7      r+   r^      )r   r.   intr7   r0   r1   s     r   test_setattrOptionsTest.test_setattrk   s6    .uac2a(r   c                     [        5       nUR                  SS[        S9  U R                  [        5         SUl        S S S 5        g ! , (       d  f       g = f)Nr7   rk   rl   2)r   r.   rn   rS   r   r7   r1   s     r   test_setattr_type_check#OptionsTest.test_setattr_type_checkq   s>     .uac2u%GK &%%s   A
Ac                     / n[        5       nUR                  SS[        UR                  S9  SUl        U R                  US/5        g )Nr7   rk   )r+   r^   rH   rm   )r   r.   rn   appendr7   r0   )r   valuesr2   s      r   test_setattr_with_callback&OptionsTest.test_setattr_with_callbacky   s?    .uacFMMJ!%r   c                 Z    [        5       nUR                  SSS9  UR                  SSS9  U$ )Nark   r*   brm   )r   r.   r1   s     r   _sample_optionsOptionsTest._sample_options   s.    .sA&sA&r   c                 p    U R                  5       nU R                  1 Sk[        [        U5      5      5        g )N>   r{   r|   help)r}   r0   setiterr1   s     r   	test_iterOptionsTest.test_iter   s*    &&(+Sg-?@r   c                 N    U R                  5       nU R                  SUS   5        g )Nrk   r{   )r}   r0   r1   s     r   test_getitemOptionsTest.test_getitem   s$    &&(GCL)r   c                 v    [        5       nUR                  SS[        S9  SUS'   U R                  US   S5        g rj   )r   r.   rn   r0   r1   s     r   test_setitemOptionsTest.test_setitem   s8    .uac2+r   c                     U R                  5       nSSSUR                  4/n[        UR                  5       5      nU R	                  X#5        g )N)r{   rk   )r|   rm   r   )r}   r   sorteditemsr0   )r   r2   expectedactuals       r   
test_itemsOptionsTest.test_items   sC    &&(h(>?(*r   c                     U R                  5       nSSUR                  S.nU R                  X!R                  5       5        g )Nrk   rm   )r{   r|   r   )r}   r   r0   as_dict)r   r2   r   s      r   test_as_dictOptionsTest.test_as_dict   s5    &&(GLL9??#45r   c                    [        5       nUR                  SSS9  UR                  SSSS9  [        R                  " S5      nUR                  R
                  nU R                  SS	U1UR                  5       5        UR                  S5      nU R                  SS0U5        U R                  0 UR                  S
5      5        g )Nr{   rk   r*   r|   b_grouprm   )groupr+   r    nonexistent)	r   r.   rQ   	_getframef_codeco_filenamer0   groups
group_dict)r   r2   frame	this_fileb_group_dicts        r   test_group_dictOptionsTest.test_group_dict   s    .sA&s)Q7a LL,,	)R3W^^5EF)))4#q<0W//>?r   c                    [        5       nUR                  SSS9  UR                  SS/5        U R                  UR                  S5        [
        R                  R                  UR                  5       SS5         U R                  UR                  S5        S S S 5        U R                  UR                  S5        [
        R                  R                  UR                  5       SS5         U R                  UR                  S5        S	Ul        U R                  UR                  S	5        [
        R                  R                  UR                  5       SS
5         U R                  UR                  S
5        S S S 5        U R                  UR                  S	5        S S S 5        U R                  UR                  S5        g ! , (       d  f       GN/= f! , (       d  f       Na= f! , (       d  f       NN= f)Nr7   rk   r*   r,   z--foo=2rm               )	r   r.   r/   r0   r7   r   patchobjectmockabler1   s     r   test_mock_patchOptionsTest.test_mock_patch   s`   .ua(""Iy#9:a(ZZw//15!<W[[!, =a( ZZw//15!<W[[!,GKW[[!,""7#3#3#5ua@  a0 AW[[!, = 	a( =< A@	 =<s1   9F>)A/G!G5$G!>
G
G	G!!
G/c                    [        5       nUR                  S[        S9  UR                  S[        S9  UR                  S[        S9  UR                  S[
        S9  UR                  S[        R                  S9  UR                  S[        R                  S9  UR                  S[        S9  UR                  S	[        S
S9  UR                  S[        S
S9  U$ )Nr   r]   
basestringrn   floatdatetime	timedeltaemailzlist-of-intTr^   multiplezlist-of-str)	r   r.   r   r   rn   r   r   r   r
   r1   s     r   _define_optionsOptionsTest._define_options   s    .u3'|/:u3'wU+z(9(9:{););<wU+}3>}3>r   c           
         U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR
                  [
        R
                  " SSSSS	5      5        U R                  UR                  [
        R                  " S
S95        U R                  UR                  R                  S5        U R                  [        UR                  [        5      5        U R                  UR                  / SQ5        U R                  UR                  / SQ5        g )Nasdfqwer*   g      ?i  r      r      -   )secondsztornado@web.com)rk   rm   r   r{   r|   c)r0   r   r   rn   r   r   r   r   r   rM   r   r
   list_of_intlist_of_strr1   s     r   _check_options_values!OptionsTest._check_options_values   s    f-++V4b),))8+<+<T1b!R+PQ**H,>,>r,JK,,.?@
7==%89,,i8,,o>r   c                 l    U R                  5       nUR                  / SQ5        U R                  U5        g )N)
r,   z
--str=asdfz--basestring=qwerz--int=42z--float=1.5z--datetime=2013-04-28 05:16z--timedelta=45sz--email=tornado@web.comz--list-of-int=1,2,3z--list-of-str=a,b,c)r   r/   r   r1   s     r   
test_typesOptionsTest.test_types   s3    &&(""	
 	""7+r   c                     S Ht  nU R                  5       nUR                  [        R                  R	                  [        R                  R                  [        5      U5      5        U R                  U5        Mv     g )N)zoptions_test_types.cfgzoptions_test_types_str.cfg)r   r@   r:   r;   r<   r=   r?   r   )r   config_file_namer2   s      r   test_types_with_conf_file%OptionsTest.test_types_with_conf_file   s]    !
 **,G%%RWW__X68HI &&w/!
r   c                     [        5       nUR                  S[        SS9  UR                  SS/5        U R	                  UR
                  / SQ5        g )Nr7   Tr   r,   z--foo=a,b,cr   )r   r.   r   r/   r0   r7   r1   s     r   test_multiple_string OptionsTest.test_multiple_string   sB    .u36""I}#=>o6r   c                     [        5       nUR                  S[        SS9  UR                  SS/5        U R	                  UR
                  / SQ5        g )Nr7   Tr   r,   z--foo=1,3,5:7)rk   r   r   r      )r   r.   rn   r/   r0   r7   r1   s     r   test_multiple_intOptionsTest.test_multiple_int   sB    .u36""I#?@o6r   c                    [        5       nUR                  S5        U R                  [        5       nUR                  S5        S S S 5        U R	                  [        WR                  5      S5        g ! , (       d  f       N4= f)Nr7   zOption.*foo.*already defined)r   r.   rS   r   assertRegexr   	exception)r   r2   cms      r   test_error_redefineOptionsTest.test_error_redefine  sY    .uu%NN5! &R\\*,JK &%s   A11
A?c                 x   / SQnU H  u  p#U R                  XUS9   [        5       nUR                  U5        U R                  [        5       nUR                  U5        S S S 5        U R                  [        WR                  5      S5        S S S 5        M     g ! , (       d  f       N@= f! , (       d  f       M  = f)N))foo-barr   )foo_barr   r   r   )r   r   )r{   r|   z Option.*foo.bar.*already defined)subTestr   r.   rS   r   r   r   r   )r   testsr{   r|   r2   r   s         r   test_error_redefine_underscore*OptionsTest.test_error_redefine_underscore  s    
 DAd1-&.q!&&u-NN1% .  R\\!24VW .-  .- .-s#   1B*B-B*
B'#B**
B9	c                    S H  nS Hw  n[        5       nUR                  U5        UR                  SU/5        U R                  UR                  S5        U R                  US   S5        U R                  US   S5        My     M     g )Nr   )z--foo-bar=az--foo_bar=ar,   r{   r   r   )r   r.   r/   r0   r   )r   defined_nameflagr2   s       r   test_dash_underscore_cli$OptionsTest.test_dash_underscore_cli  sz    2L6&.|,**It+<=  #6  !3S9  !3S9 7 3r   c                 $   S H  n[        5       nUR                  U5        UR                  [        R                  R                  [        R                  R                  [        5      S5      5        U R                  UR                  S5        M     g )Nr   r9   r{   )
r   r.   r@   r:   r;   r<   r=   r?   r0   r   )r   r   r2   s      r   test_dash_underscore_file%OptionsTest.test_dash_underscore_file+  se     3L"nGNN<(%%RWW__X68JK W__c2 3r   c                 r   [        5       nUR                  SSS9  UR                  SSS9  / SQnU R                  [        U5      U5        U R                  [        S UR	                  5        5       5      U5        U R                  [        UR                  5       R                  5       5      U5        U R                  [        UR                  S5      5      SS/5        [        5       nUR                  U5        U R                  SUR                  5       5        U R                  SUR                  5       5        g )	N	with-dashg)r   with_underscore)r   r   r   c              3   *   #    U  H	  u  pUv   M     g 7fr   r#   ).0kvs      r   	<genexpr>AOptionsTest.test_dash_underscore_introspection.<locals>.<genexpr>=  s     @fqs   z--with-dashz--with-underscore)r   r.   r0   r   r   r   keysr   r   
print_helprV   rU   )r   r2   all_optionsbufs       r   "test_dash_underscore_introspection.OptionsTest.test_dash_underscore_introspection6  s    .{#.(4>+6@@@+N 1 6 6 89;G7%%c*+k;L-M	

 j3mS\\^4)3<<>:r   rF   N) r   r   r   r    r3   rB   rN   rY   rg   ro   rs   rx   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r#   r   r   r%   r%      s    ,7%.
'%.)&A
*,+6
@)*
?,$	077LX":	3;r   r%   )r   ior   r:   rQ   unittestr   tornado.optionsr   r   tornado.utilr   typingTYPE_CHECKINGr   r
   TestCaser%   r#   r   r   <module>r     sJ      	 
   / ( 		 	k;(## k;r   