
    <eB                        d dl mZ  ej        d           d dlZd dlmZ  G d d          Z G d de          Z G d	 d
e          Z	 G d dej
                  Z G d dej
                  Zedk    r ej                     dS dS )    )import_helper_tkinterN)ttkc                       e Zd Zd Zd ZdS )	MockTkAppc                 Z    t          |t                    r|S |                    d          S )N:)
isinstancetuplesplit)selfargs     -/usr/lib/python3.11/test/test_ttk_textonly.py	splitlistzMockTkApp.splitlist   s)    c5!! 	Jyy~~    c                     dS )NT r   s    r   wantobjectszMockTkApp.wantobjects   s    tr   N)__name__
__module____qualname__r   r   r   r   r   r   r   
   s2          
    r   r   c                       e Zd ZdZd Zd ZdS )
MockTclObjtestc                     || _         d S Nval)r   r   s     r   __init__zMockTclObj.__init__   s    r   c                 *    t          | j                  S r   )strr   r   s    r   __str__zMockTclObj.__str__   s    48}}r   Nr   r   r   typenamer    r#   r   r   r   r   r      s7        H      r   r   c                       e Zd ZdZd Zd ZdS )MockStateSpec	StateSpecc                     || _         d S r   r   )r   argss     r   r    zMockStateSpec.__init__"   s    r   c                 6    d                     | j                  S N )joinr   r   s    r   r#   zMockStateSpec.__str__%   s    xx!!!r   Nr$   r   r   r   r'   r'      s7        H  " " " " "r   r'   c                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )InternalFunctionsTestc                      fd}                      t          j        i                       |t          j        dg dd          ddd            |t          j        ddi          d	d
i            |t          j        dddii          d	ddii            |t          j        g ddddddddd          dddddddd           ddd}|                                } |t          j        |          ddd                                 ||            |t          j        d!d"i          d#d$i            |t          j        d!d%i          d#d&i            |t          j        d!d'i          d#d(i            |t          j        d!d)i          d#d*i            |t          j        d!d+i          d#d,i            |t          j        d!d-i          d#d.i           t          t          j        |d/0                    d1z  }                     |t          |          d2z
             t          t          j        |d30                    d1z  }                     |t          |          d2z
                                   t          j        |t          |                                          0                     d S )4Nc                     t          dt          |           d          D ]:}                    |                    | |                   | |dz                       ;|r                    d|z             d S d S )Nr         zresult still got elements: %s)rangelenassertEqualpopfail)fmt_optsresultir   s      r   check_againstz@InternalFunctionsTest.test_format_optdict.<locals>.check_against,   s    1c(mmQ// K K  HQK!8!8(1q5/JJJJ D		9FBCCCCCD Dr   bluer4   r3         )fgpaddingz1 2 3 4)z-fgz-paddingr   )r4   r3    r   -testz1 2 {} 0leftzas is)r4   rD   2mr   r@   rD   zabc defz"abc"z{}z	} -spam {)r   test2test3test4test5test6test7Tscriptz{1 -1 {} 2m 0}3z	{abc def}z{"abc"}z\{\}z\}\ -spam\ \{)rE   z-test2z-test3z-test4z-test5z-test6z-test7Fu   αβγ   á)u   -αβγu   -áoption)zone twothree-optionz{one two} three)zone	tworU   z{one	two} three)rD   onez{} one)z	one} {tworU   zone\}\ \{two three)z"one"twoz{"one"} two)z{one}rX   z\{one\} tworS   )ignorer3   r4   )rS   b)assertFalser   _format_optdictcopyr7   r6   listkeys)r   r=   opts	orig_optsamount_optss   `    r   test_format_optdictz)InternalFunctionsTest.test_format_optdict+   s   	D 	D 	D 	D 	D 	,R00111 	v,,, G GHH	22	4 	4 	4
 	 788j!	# 	# 	#
 	&'): ;<<vw'(	* 	* 	*
 	---y!D%' ' 04	5 5 5
 '#{ G') )		* 		* 		* e,,IIKK	c)$//T%1P1PQQQy))) 	/02 2)*	, 	, 	, 	013 3*+	- 	- 	- 	;') )!	# 	# 	# 	124 4-.	0 	0 	0 	+,. .&	( 	( 	( 	+,. .'	) 	) 	) #-dDBBBCCaGc$ii!m444 #-d;GGGHH1Lc$ii!m444 	,T$tyy{{:K:KLLLMMMMMr   c           	         dg di}t          j        |          }|                     t          |          t          t	          |                                                    dz             |                     |d           |                     t          j        |d          d           |                     t          j        dg i          d           d	d
gi}t          j        |          }|                     |d           |                     t          j        ddgi          d           ddgi}|                     t          j        |          d           ddgi}|                     t          t           j        |           ddgddfgi}|                     t          t           j        |           dddggi}|                     t          j        |          d           d dddt                      fD ]1}d|dfgi}|                     t          j        |          d           2dd i}|                     t          t           j        |           d S )Na))rZ   cr   )dotherval)rD   singler3   )-az{b c} val d otherval {} singleTrO   )rj   z {{b c} val d otherval {} single})z-2rD      üñíćódèrS   u   vãl)u   -üñíćódèu   á vãlopt)value)-optz{} value)rD   rD   hi)ro   z{ } hi)r4   r3   	valid valr4   2rq   rn   )ro   z1 valuer   FrD   )	r   _format_mapdictr7   r6   r^   r_   assertRaises	TypeErrorset)r   r`   r;   validinvalidstatevals         r   test_format_mapdictz)InternalFunctionsTest.test_format_mapdict   sr   KKKL$T**Vc$tyy{{*;*;&<&<q&@AAA!IJJJ,T$???6	8 	8 	8 	,aW55zBBB.!12$T**!>???,ej\-BCC-	/ 	/ 	/ (),U335GHHH ./0)S%8'BBBQCk234)S%8'BBB!W',U335HIIIq%SUU3 	& 	&Hh012ES077$& & & & T{)S%8$?????r   c                 b   |                      t          j        d           d           |                     t          t          j        d           |                     t          j        ddd          d           |                     t          j        dddd          d           |                     t          j        dddd          d	           |                     t          j        dddd
d          d           |                     t          j        ddddddg          d           |                     t          t          j        d           |                     t          j        dddd          d           |                     t          j        ddddd          d           |                     t          j        ddddd
d          d           |                     t          j        ddddddddgfd          d           |                     t          t          j        d           |                     t          j        ddd          d           |                     t          j        dddd          d           |                     t          j        dddd          d            d S )!N)Nr   imageFr   )ztest r   )rD   re   )z	test {} ar   re   rZ   rf   )ztest {a b} cr   re   rZ   x)re   )ztest a b)rj   r   T)re   rZ   rf   rg   r3   r@   )r   )z{test {a b c} d}z-x {2 3}vsapire   rZ   )za b r   )za b {a b} cr   )rm   )za b a b)ro   r   r4   )z{a b {a b} {1 2}}z-opt xfrom)re   r   )re   )rZ   )z{a}rZ   )
assertTruer   _format_elemcreatert   
IndexErrorr7   
ValueErrorr   s    r   test_format_elemcreatez,InternalFunctionsTest.test_format_elemcreate   s   .t44jAAA
 	*c&<gFFF 	/GG	 	 	 	/ )	+ 	+ 	+ 	/ 2	4 	4 	4 	/#   9	; 	; 	; 	/v QF, , ,-M	O 	O 	O 	*c&<gFFF 	/SII	 	 	 	/S 1	3 	3 	3 	/SC! ! !"<	> 	> 	> 	/sC#1vC) ) )*I	K 	K 	K
 	*c&<fEEE/sCC	 	 	/sCHH	 	 	/c3GG	 	 	 	 	r   c                    dd}dd}|                      t          j        g           d         d           |                     t          t          j        dg           t          j        dgd          }|                      |t          j        d	gd                     |                      |d         d
           |                       |             |                       t          d          D ]T}|                       ||           ||                     |                       |||           |||                     U|                     t          t          j        ddg           |                     t          t          j        dg           |                     t          t          j        ddd
d iifg           d S )Nr   r3   c           
      l    t          j        dg dddddddifgd	d
fgifgdfg| |          d         S )Nre   )r4   r3   r@   rZ   childrenrf   rg   nicerm   )r4   r3   )r   	something)otherr   indentindent_sizer   )r   _format_layoutlistr   s     r   samplez<InternalFunctionsTest.test_format_layoutlist.<locals>.sample   s    )YYY
/0v         K9 9 9 :;< <r   c                      d fd	} |            d ||          d |d|z            d |d|z            d |d|z            d	 ||          d	 |            d
S )Nr   c                     d| z   z  S r,   r   )amountr   s    r   <lambda>zWInternalFunctionsTest.test_format_layoutlist.<locals>.sample_expected.<locals>.<lambda>   s    cVf_&= r   za -other {1 2 3} -children {
zb -children {
r3   zc -something {1 2} -children {
r@   zd -nice opt
z}
})r   r   )r   r   spacess   `  r   sample_expectedzEInternalFunctionsTest.test_format_layoutlist.<locals>.sample_expected   s    =====F  66+#6#6#6#6F1{?++++VVAO-D-D-D-DF1{?++++VVK-@-@-@-@&&((((L	Mr   rD   r~   )re   N)r   )re   rD   re   rA   badformat)namer   r   r   )r   r3   )r7   r   r   rt   AttributeErrorr5   r   )r   r   r   smallestr<   s        r   test_format_layoutlistz,InternalFunctionsTest.test_format_layoutlist   s   	< 	< 	< 	<	M 	M 	M 	M 	/33A6;;; 	."ZL	2 	2 	2 );-BBB"I;q999	; 	; 	;!c*** 	??#4#4555q 	B 	BAVVAYY(:(:;;;VVAq\\??1a+@+@AAAA 	*c&<H	 	 	 	.#*@	 	 	 	*c&<zC;/01	3 	3 	3 	3 	3r   c           	         |                      t          j        dd d d di                     |                     t          j        ddd ii          d           ddd}|                     t          j        dd|ii                     d	d
gi}|                     t          j        dd|ii                     |                     t          t          j        dddgii           |                     t          j        ddddgii                     ddg dii}|                     t          j        |          d           |d         d                             ddi           |                     t          j        |          d           t          d          t          d          g|d         d         d         d<   |                     t          j        |          d           d S )Nr   )	configuremapelement createlayoutzttk::style layout name {
null
}TFrR   r   rk   rl   r   r   r|   thing)r|   r   )state1state2r   zAttk::style element create thing image {name {state1 state2} val} rm      zHttk::style element create thing image {name {state1 state2} val} -opt 30r@   rH   rG   zLttk::style element create thing image {name {state1 state2} val} -opt {3 2m})	r[   r   _script_from_settingsr7   r   rt   r   appendr   )r   
configdictmapdictr|   s       r   test_script_from_settingsz/InternalFunctionsTest.test_script_from_settings  sc   2FttDD4F G G 	H 	H 	H 	%v$/?&@AA/	1 	1 	1 !%E22
%vZ/H&IJJ	L 	L 	L #^$45%vw/?&@AA	C 	C 	C 	*%1AG90M'N	P 	P 	P 	160133 4 4 	5 	5 	5 +:::< =2599O	Q 	Q 	Q 	g'(//<<<2599	 	 	 8B!}}t7g'(,U32599	 	 	 	 	r   c           	         |                      t          j        t          dd          df          dg           |                      t          j        t	          d          dt	          d          g          g d           d S )	Nre   rZ   r   )re   rZ   r   1r3   3m)r4   r3   r   )r7   r   _tclobj_to_pyr'   r   r   s    r   test_tclobj_to_pyz'InternalFunctionsTest.test_tclobj_to_pyJ  s    }S#66>??	! 	! 	! 	z#:d3C3CDEELL	 	 	 	 	r   c                 r     fd}t          d t          d          D                       }t          | } ||dd|            ||t          d          d|           t          d t          d          D                       }t          | } ||dd|            |dt          d          dd           d S )Nc                 f                         t          j        | |f          ||fz   g           d S r   )r7   r   _list_from_statespec)sspecrn   	res_valuestatesr   s       r   test_itz?InternalFunctionsTest.test_list_from_statespec.<locals>.test_itT  sH    S5   "(I="8!9; ; ; ; ;r   c              3       K   | ]	}d |z  V  
dS zstate%dNr   .0r<   s     r   	<genexpr>zAInternalFunctionsTest.test_list_from_statespec.<locals>.<genexpr>X  s&      <<aIM<<<<<<r      r   c              3       K   | ]	}d |z  V  
dS r   r   r   s     r   r   zAInternalFunctionsTest.test_list_from_statespec.<locals>.<genexpr>]  s&      ;;Q9q=;;;;;;r      r}   )r   r5   r'   r   )r   r   states_even	statespec
states_odds   `    r   test_list_from_statespecz.InternalFunctionsTest.test_list_from_statespecS  s    	; 	; 	; 	; 	; <<588<<<<<!;/		5%555	:e,,e[AAA;;%((;;;;;
!:.		5%444E!2!2E?KKKKKr   c           	         t                      }|                     t          j        |d                     |                     t          j        |d          di fg           d}|                     t          j        ||          dddifg           |                     t          j        |d          dd	g ifg           d
}|                     t          j        ||          dddddi fgdfgdfg           |                     t          t          j        |d           |                     t          t          j        |d           |                     t          t          j        |d           d S )Nr   )r   r   )r   rV   rn   rT   rn   )r   	-childrenr   r   r   )r   rV   niceoner   )otheroner   )childz	-otheropt
othervaluer   r   r   r   )otheroptr   )rT   r   )r   no_minus)r   r   rn   )r   r   )r   r[   r   _list_from_layouttupler7   rt   r   )r   tksample_ltupleltuples       r   test_list_from_layouttuplez0InternalFunctionsTest.test_list_from_layouttupled  s   [[ 	3B;;<<< 	3B
CCb\N	 	 	 53BFFx)*+	- 	- 	- 	3B*, ,J+,-	
 	
 	

 	3B??<r]O      	
 	
 	
 	*c&@" 	" 	" 	"*c&@")	+ 	+ 	+*c&@"&	( 	( 	( 	( 	(r   c                    d	d}t                      }||_        |                     t          j        |i d          ddi           |                     t          j        |i d          ddi           |                     t          j        |dd id          d           |                     t          j        |ddid          ddi           d S )
Nc                     || S |dS ||fS )Ntest valr   )resrm   r   s      r   funcz4InternalFunctionsTest.test_val_or_dict.<locals>.func  s     {
{!z:r   z-test:3r   rQ   )rE   r@   r@   zx:yr   )NN)r   callr7   r   _val_or_dict)r   r   r   s      r   test_val_or_dictz&InternalFunctionsTest.test_val_or_dict  s    	 	 	 	 [[)"b)<< #	( 	( 	()"b,?? !	& 	& 	& 	)"vtneDD#	% 	% 	% 	)"vqk5AA !	& 	& 	& 	& 	&r   c                 z    ddddg dfdf}|D ]-\  }}|                      t          j        |          |           .d S )N)r   r   )09	   )re   re   )   áÚr   z[])NNone)r7   r   _convert_stringval)r   testsorigexpecteds       r   test_convert_stringvalz,InternalFunctionsTest.test_convert_stringval  sc    Iz+;b$Z
 $ 	E 	END(S3D998DDDD	E 	Er   N)r   r   r   rc   rz   r   r   r   r   r   r   r   r   r   r   r   r0   r0   )   s        UN UN UNp%@ %@ %@P8 8 8v63 63 63r( ( (V  L L L"+( +( +(\& & &.E E E E Er   r0   c                        e Zd Zd Zd Zd ZdS )TclObjsToPyTestc                     ddi}|                      t          j        |          ddi           t          |d                   |d<   |                      t          j        |          ddi           d S )Nrm   u   välúè)r7   r   tclobjs_to_pyr   r   adicts     r   test_unicodezTclObjsToPyTest.test_unicode  ss    
#*511E:3FGGG!%,//e*511E:3FGGGGGr   c                    dg di}|                      t          j        |          dg di           g d|d<   |                      t          j        |          dg di           t          dd          df|d<   |                      t          j        |          ddgi           |                      t          j        dd	gi          dd	gi           d S )
Nrm   r?   )r4   xmr@   re   rZ      válũè)re   rZ   r   r   zy z)r7   r   r   r'   r   s     r   test_multivaluesz TclObjsToPyTest.test_multivalues  s    %*511E<<<3HIII#||e*511E<<<3HIII%c3//<e*511+,-	/ 	/ 	/ 	*C%>::5'N	 	 	 	 	r   c                 ^    |                      t          j        ddi          ddi           d S )Ntextz	some text)r7   r   r   r   s    r   test_nosplitzTclObjsToPyTest.test_nosplit  s>    *FK+@AA[!	# 	# 	# 	# 	#r   N)r   r   r   r   r   r   r   r   r   r   r     sD        H H H  # # # # #r   r   __main__)test.supportr   import_moduleunittesttkinterr   r   objectr   r'   TestCaser0   r   r   mainr   r   r   <module>r      sT   & & & & & &  J ' ' '                     " " " " "F " " "FE FE FE FE FEH- FE FE FER# # # # #h' # # #8 zHMOOOOO r   