
    daf%M                         d dl Z d dlmZmZmZmZ d dlZ e       Z	 G d de      Z
 G d d      Z G d d      Z G d	 d
      Zd Zd Zy)    N)AbstractTkTest
tk_versionpixels_conv
tcl_obj_eqc                       e Zd ZeZdZdZed        Zd Z	de
j                  fdZeddddZddZd	 Zd
 ZeddZd ZdddZd Zd ZdddZdddZd Zd Zd Zd Zd Zy)AbstractWidgetTestNFc                     	 | j                   S # t        $ r9 t        | j                  j	                  dd            | _         | j                   cY S w xY w)Ntkscaling)_scalingAttributeErrorfloatrootcall)selfs    9/root/Python-3.12.4/Lib/test/test_tkinter/widget_tests.pyr   zAbstractWidgetTest.scaling   sE    	!==  	!!$))..y"ABDM== 	!s    ?AAc                     | j                   s| j                  rt        dk\  r|S t        |t              r%dj                  t        | j                  |            S t        |      S )N       )	
_stringifywantobjectsr   
isinstancetuplejoinmap_strstr)r   values     r   r   zAbstractWidgetTest._str   sK    4#3#3
f8LLeU#88C		51225z    c                 >     |||      ry | j                  |||       y N)assertEqual)r   actualexpectedmsgeqs        r   assertEqual2zAbstractWidgetTest.assertEqual2   s!    fh3/r!   )r&   convr(   c                   |||<   |t         u r|}|r ||      }| j                  s| j                  s1t        |t              rt        j                  |      }nt        |      }|t        }| j                  ||   ||       | j                  |j                  |      ||       |j                  |      }| j                  t        |      d       | j                  |d   ||       y )N)r(         )	_sentinelr   r   r   r   tkinter_joinr   r   r)   cget	configurer$   len)r   widgetnamer    r&   r*   r(   ts           r   
checkParamzAbstractWidgetTest.checkParam$   s    ty HH~H??$"2"2(E*"==2x=:B&,R8&++d+X"=T"Q#!A$R0r!   c                 $   ||   }||j                  |      }| j                  t        j                        5 }|||<   d d d        |%| j	                  t        j                        |       | j	                  ||   |       | j                  t        j                        5 }|j                  ||i       d d d        |%| j	                  t        j                        |       | j	                  ||   |       y # 1 sw Y   xY w# 1 sw Y   RxY wr#   )formatassertRaisesr/   TclErrorr$   r   	exceptionr2   )r   r4   r5   r    errmsgorigcms          r   checkInvalidParamz$AbstractWidgetTest.checkInvalidParam8   s    d|]]5)Fw//0 	!B F4L	!S.7t,w//0 	,BdE]+	,S.7t,	! 	!
	, 	,s   C:!D:DDc                 <    |D ]  } | j                   |||fi |  y r#   )r7   )r   r4   r5   valueskwargsr    s         r   checkParamszAbstractWidgetTest.checkParamsG   s(     	;EDOOFD%:6:	;r!   c                      | j                   ||g|i | | j                  ||dd       | j                  ||dd       | j                  ||dd       y )N zexpected integer but got ""r=   10pzexpected integer but got "10p"g	@zexpected integer but got "3.2"rD   r@   )r   r4   r5   rB   rC   s        r   checkIntegerParamz$AbstractWidgetTest.checkIntegerParamK   sr    99&9vtR4 	 	6vtU7 	 	9vtS7 	 	9r!   r*   c                    |D ]  } | j                   |||fd|i|  | j                  ||dd       | j                  ||dd       y )Nr*   rF   z)expected floating-point number but got ""rG   spamz-expected floating-point number but got "spam"r7   r@   )r   r4   r5   r*   rB   rC   r    s          r   checkFloatParamz"AbstractWidgetTest.checkFloatParamT   si     	FEDOOFD%EdEfE	FvtRB 	 	DvtVF 	 	Hr!   c                     dD ]  }| j                  |||d        dD ]  }| j                  |||d        | j                  ||dd       | j                  ||d	d
       y )N)Fr   falsenooffr   )r&   )T   trueyesonrT   rF   z!expected boolean value but got ""rG   rM   z%expected boolean value but got "spam"rN   )r   r4   r5   r    s       r   checkBooleanParamz$AbstractWidgetTest.checkBooleanParam\   s    5 	=EOOFD%!O<	=3 	=EOOFD%!O<	=vtR: 	 	<vtV> 	 	@r!   )allow_emptyc                j     | j                   ||ddddddddd	d
fi | | j                  ||dd       y )Nz#ff0000z#00ff00z#0000ffz#123456redgreenbluewhiteblackgreyrM   zunknown color name "spam"rG   rI   )r   r4   r5   rY   rC   s        r   checkColorParamz"AbstractWidgetTest.checkColorParamf   sT    "Iy)'6	# "	# 	vtV2 	 	4r!   c                      | j                   ||ddddfi | | j                  ||d       | j                  ||dd       y )	NarrowwatchcrossrF   nonerM   zbad cursor spec "spam"rG   )rD   r7   r@   )r   r4   r5   rC   s       r   checkCursorParamz#AbstractWidgetTest.checkCursorParamn   sM    w"NvNf-vtV/ 	 	1r!   c                 b    d }|||<   | j                  ||          | j                  ||d       y )Nc                       y r#    )argss    r   commandz5AbstractWidgetTest.checkCommandParam.<locals>.commandu   s    r!   rF   )
assertTruerD   )r   r4   r5   rl   s       r   checkCommandParamz$AbstractWidgetTest.checkCommandParamt   s2    	tt%r*r!   rG   c                     | j                   ||g|i | |Od|ddj                  |d d       t        |      dkD  rdndd|d   }| j                  ||dd	|z   
       d|z   }| j                  ||d|
       y )Nr   z "{}": must be z,    ,rF   z or 	ambiguousrG   badrM   )rD   r   r3   r@   )r   r4   r5   r=   rB   rC   errmsg2s          r   checkEnumParamz!AbstractWidgetTest.checkEnumParam{   s    99&9>IIfSbk*v;?C22J	 G
 ""64*5*? # AW_FvtVFCr!   c                2   || j                   }|D ]Z  }t        }|}t        |t              r(|r&|t        urt	        |      | j
                  z  }t        } | j                  |||f||d| \ | j                  ||dd       | j                  ||dd       y )Nr&   r*   6xzbad screen distance "6x"rG   rM   zbad screen distance "spam")	_conv_pixelsr.   r   r   r   r   roundr7   r@   )	r   r4   r5   r*   rB   rC   r    r&   conv1s	            r   checkPixelsParamz#AbstractWidgetTest.checkPixelsParam   s    <$$D 	2E HE%%U#-*51DLL@H!EDOOFD% 2(!&2*02	2 	vtT1 	 	3vtV3 	 	5r!   c           
      x    | j                  ||dddddd       d}t        dk  rd }| j                  ||d	|
       y )NflatgrooveraisedridgesolidsunkenzHbad relief "spam": must be flat, groove, raised, ridge, solid, or sunkenr   rM   rG   )rD   r   r@   )r   r4   r5   r=   s       r   checkReliefParamz#AbstractWidgetTest.checkReliefParam   sR    8Wgx	Q?FvtV 	 	r!   c                     t        j                  | j                  d      }| j                  |||t               | j                  ||dd       d||<   y )Nimage1)masterr5   rK   rM   zimage "spam" doesn't existrG   rF   )r/   
PhotoImager   r7   r   r@   )r   r4   r5   images       r   checkImageParamz"AbstractWidgetTest.checkImageParam   sQ    ""$))(Ce#6vtV4 	 	6tr!   c                 6    | j                  |||t               y )NrK   )r7   r   )r   r4   r5   vars       r   checkVariableParamz%AbstractWidgetTest.checkVariableParam   s    c4r!   c                     | j                  |       | j                  |t               t        |      dk7  r| j	                  d|       |D ](  }t        |t              r| j	                  d|        y  y )Nr-   zInvalid bounding box: )assertIsNotNoneassertIsInstancer   r3   failr   int)r   bboxitems      r   assertIsBoundingBoxz&AbstractWidgetTest.assertIsBoundingBox   se    T"dE*t9>IID:; 	DdC(		>?	r!   c                    | j                         }|j                         }| j                  t        |      t        |j	                                      |D ]  }||    	 t
        j                  j                  rtdddddd}t        |      }t        | j                        }t        ||z
        D ]:  }||v r||   |v r||   |v rt        | j                  j                  d|d       < y y )	Nborderwidth
background
foregroundinvalidcommandvalidatecommand)bdbgfginvcmdvcmdz.OPTIONS doesn't contain "")createkeysr$   sortedr2   testsupportverbosesetOPTIONSprint	__class____name__)r   r4   r   kaliasesr&   s         r   	test_keyszAbstractWidgetTest.test_keys   s    {{}vf.>.>.@'AB 	A1I	 <<#""*)G t9D4<<(HD8O, 8W
d*
h.>>22A7 8	8  r!   r#   )r   
__module____qualname__r{   rz   _conv_pad_pixelsr   propertyr   r   object__eq__r)   r.   r7   r@   rD   rJ   r   rO   rX   ra   rg   rn   rv   r}   r   r   r   r   r   rj   r!   r   r   r      s    LJ! ! 26&-- 0
 ;D$1(-;9 ;@ H@ <@ 41+ <@ D #5$58r!   r   c                   H   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 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7y6)7StandardOptionsTests)*activebackgroundactiveborderwidthactiveforegroundanchorr   bitmapr   compoundcursordisabledforegroundexportselectionfontr   highlightbackgroundhighlightcolorhighlightthicknessr   insertbackgroundinsertborderwidthinsertofftimeinsertontimeinsertwidthjumpjustifyorientpadxpadyreliefrepeatdelayrepeatintervalselectbackgroundselectborderwidthselectforegroundsetgrid	takefocustexttextvariabletroughcolor	underline
wraplengthxscrollcommandyscrollcommandc                 H    | j                         }| j                  |d       y )Nr   r   ra   r   r4   s     r   test_configure_activebackgroundz4StandardOptionsTests.test_configure_activebackground       V%78r!   c           
      T    | j                         }| j                  |ddddddd       y )Nr   r   ?g333333@r   rH   r   r}   r   s     r    test_configure_activeborderwidthz5StandardOptionsTests.test_configure_activeborderwidth   -    f&9c1b%	9r!   c                 H    | j                         }| j                  |d       y )Nr   r   r   s     r   test_configure_activeforegroundz4StandardOptionsTests.test_configure_activeforeground   r   r!   c                 Z    | j                         }| j                  |ddddddddd	d
       y )Nr   nneesesswwnwcenterr   rv   r   s     r   test_configure_anchorz*StandardOptionsTests.test_configure_anchor   s3    FHT3c4dH	Fr!   c                     | j                         }| j                  |d       d| j                  v r| j                  |d       y y )Nr   r   r   ra   r   r   s     r   test_configure_backgroundz.StandardOptionsTests.test_configure_background   >    V\24<<  .  r!   c                    | j                         }| j                  |dd       | j                  |dd       t        j                  j	                  dd      }| j                  |dd|z          d| j
                  j                  j                  d	d
      v rd| j
                  j                         v s| j                  |ddd       y y )Nr   	questheadgray50z
python.xbm
imghdrdata)subdir@aquar
   windowingsystemAppKitrM   zbitmap "spam" not definedrG   )
r   r7   r   r   findfiler   r
   r   winfo_serverr@   )r   r4   filenames      r   test_configure_bitmapz*StandardOptionsTests.test_configure_bitmap   s    +6(3<<((l(K#.9 $)),,++D2CDDDII2244""68V6 # 8 5r!   c           
          | j                         }| j                  |ddddddd       d| j                  v r| j                  |ddddddd       y y )	Nr   r   r   @r   r   rH   r   )r   r}   r   r   s     r   test_configure_borderwidthz/StandardOptionsTests.test_configure_borderwidth  sY    fmc1b%	94<<!!&$3QEJ  r!   c           
      T    | j                         }| j                  |ddddddd       y )Nr   bottomr   leftrf   righttopr   r   s     r   test_configure_compoundz,StandardOptionsTests.test_configure_compound  s-    FJ(FFGU	Dr!   c                 H    | j                         }| j                  |d       y )Nr   )r   rg   r   s     r   test_configure_cursorz*StandardOptionsTests.test_configure_cursor      fh/r!   c                 H    | j                         }| j                  |d       y )Nr   r   r   s     r   !test_configure_disabledforegroundz6StandardOptionsTests.test_configure_disabledforeground  s    V%9:r!   c                 H    | j                         }| j                  |d       y )Nr   r   rX   r   s     r   test_configure_exportselectionz3StandardOptionsTests.test_configure_exportselection  s    v'89r!   c                 t    | j                         }| j                  |dd       | j                  |ddd       y )Nr   z3-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*rF   zfont "" doesn't existrG   )r   r7   r@   r   s     r   test_configure_fontz(StandardOptionsTests.test_configure_font  s>    M	Ovvr&> 	 	@r!   c                     | j                         }| j                  |d       d| j                  v r| j                  |d       y y )Nr   r   r   r   s     r   test_configure_foregroundz.StandardOptionsTests.test_configure_foreground%  r   r!   c                 H    | j                         }| j                  |d       y )Nr   r   r   s     r   "test_configure_highlightbackgroundz7StandardOptionsTests.test_configure_highlightbackground+  s    V%:;r!   c                 H    | j                         }| j                  |d       y )Nr   r   r   s     r   test_configure_highlightcolorz2StandardOptionsTests.test_configure_highlightcolor/  s    V%56r!   c           	          | j                         }| j                  |dddddd       | j                  |ddd| j                         y )	Nr   r   r   r
  r   rH   r   rx   )r   r}   r7   rz   r   s     r   !test_configure_highlightthicknessz6StandardOptionsTests.test_configure_highlightthickness3  sN    f&:c1e	5 4b1!.. 	 	0r!   c                 H    | j                         }| j                  |d       y )Nr   r   r   r   s     r   test_configure_imagez)StandardOptionsTests.test_configure_image:  s    VW-r!   c                 H    | j                         }| j                  |d       y )Nr   r   r   s     r   test_configure_insertbackgroundz4StandardOptionsTests.test_configure_insertbackground>  r   r!   c           
      T    | j                         }| j                  |ddddddd       y )Nr   r   r   r
  r   r   rH   r   r   s     r    test_configure_insertborderwidthz5StandardOptionsTests.test_configure_insertborderwidthB  r   r!   c                 J    | j                         }| j                  |dd       y )Nr   d   r   rJ   r   s     r   test_configure_insertofftimez1StandardOptionsTests.test_configure_insertofftimeG  s    v<r!   c                 J    | j                         }| j                  |dd       y )Nr   r,  r-  r   s     r   test_configure_insertontimez0StandardOptionsTests.test_configure_insertontimeK  s    v~s;r!   c                 P    | j                         }| j                  |ddddd       y )Nr   r   r
  r   rH   r   r   s     r   test_configure_insertwidthz/StandardOptionsTests.test_configure_insertwidthO  s%    fmS#r5Ir!   c                 H    | j                         }| j                  |d       y )Nr   r  r   s     r   test_configure_jumpz(StandardOptionsTests.test_configure_jumpS  s    vv.r!   c                 |    | j                         }| j                  |ddddd       | j                  |ddd       y )	Nr   r  r  r   z6bad justification "{}": must be left, right, or centerrG   rF   z:ambiguous justification "": must be left, right, or center)r   rv   r@   r   s     r   test_configure_justifyz+StandardOptionsTests.test_configure_justifyW  sO    FIvw0 	 	1 	vy"0 	 	1r!   c                     | j                         }| j                  t        |d         | j                         | j	                  |ddd       y )Nr   
horizontalvertical)r   r$   r   default_orientrv   r   s     r   test_configure_orientz*StandardOptionsTests.test_configure_orient`  sA    VH-.0C0CDFHlJGr!   c           
      j    | j                         }| j                  |dddddd| j                         y )Nr      皙@ffffff@r   12mrK   r   r}   r   r   s     r   test_configure_padxz(StandardOptionsTests.test_configure_padxe  7    ffac2u#'#8#8 	 	:r!   c           
      j    | j                         }| j                  |dddddd| j                         y )Nr   r=  r>  r?  r   r@  rK   rA  r   s     r   test_configure_padyz(StandardOptionsTests.test_configure_padyj  rC  r!   c                 H    | j                         }| j                  |d       y )Nr   r   r   r   s     r   test_configure_reliefz*StandardOptionsTests.test_configure_reliefo  r  r!   c                 L    | j                         }| j                  |ddd       y )Nr     r-  r   s     r   test_configure_repeatdelayz/StandardOptionsTests.test_configure_repeatdelays  s!    v}dC@r!   c                 L    | j                         }| j                  |ddd       y )Nr   rJ  rK  r-  r   s     r   test_configure_repeatintervalz2StandardOptionsTests.test_configure_repeatintervalw  s"    v'7sCr!   c                 H    | j                         }| j                  |d       y )Nr   r   r   s     r   test_configure_selectbackgroundz4StandardOptionsTests.test_configure_selectbackground{  r   r!   c                 P    | j                         }| j                  |ddddd       y )Nr   r   r
  r   rH   r   r   s     r    test_configure_selectborderwidthz5StandardOptionsTests.test_configure_selectborderwidth  s&    f&93ROr!   c                 H    | j                         }| j                  |d       y )Nr   r   r   s     r   test_configure_selectforegroundz4StandardOptionsTests.test_configure_selectforeground  r   r!   c                 H    | j                         }| j                  |d       y )Nr   r  r   s     r   test_configure_setgridz+StandardOptionsTests.test_configure_setgrid      vy1r!   c                 N    | j                         }| j                  |dddd       y )Nstateactivedisablednormalr   r   s     r   test_configure_statez)StandardOptionsTests.test_configure_state  s#    FGXz8Lr!   c                 N    | j                         }| j                  |dddd       y )Nr   01rF   r   rD   r   s     r   test_configure_takefocusz-StandardOptionsTests.test_configure_takefocus  s#    c3;r!   c                 L    | j                         }| j                  |ddd       y )Nr   rF   z
any stringra  r   s     r   test_configure_textz(StandardOptionsTests.test_configure_text  s!    \:r!   c                     | j                         }t        j                  | j                        }| j	                  |d|       y )Nr   )r   r/   	StringVarr   r   r   r4   r   s      r   test_configure_textvariablez0StandardOptionsTests.test_configure_textvariable  s3    		*<r!   c                 H    | j                         }| j                  |d       y )Nr   r   r   s     r   test_configure_troughcolorz/StandardOptionsTests.test_configure_troughcolor      V]3r!   c                 N    | j                         }| j                  |dddd       y )Nr   r   rT   
   r-  r   s     r   test_configure_underlinez-StandardOptionsTests.test_configure_underline  s#    v{Aq"=r!   c                 J    | j                         }| j                  |dd       y )Nr   r,  r   r   s     r   test_configure_wraplengthz.StandardOptionsTests.test_configure_wraplength  s    flC8r!   c                 H    | j                         }| j                  |d       y )Nr   r   rn   r   s     r   test_configure_xscrollcommandz2StandardOptionsTests.test_configure_xscrollcommand      v'78r!   c                 H    | j                         }| j                  |d       y )Nr   rr  r   s     r   test_configure_yscrollcommandz2StandardOptionsTests.test_configure_yscrollcommand  rt  r!   c                 H    | j                         }| j                  |d       y )Nrl   rr  r   s     r   test_configure_commandz+StandardOptionsTests.test_configure_command  rW  r!   c                 H    | j                         }| j                  |d       y )Nindicatoronr  r   s     r   test_configure_indicatoronz/StandardOptionsTests.test_configure_indicatoron  s    v}5r!   c                 H    | j                         }| j                  |d       y )N	offreliefrG  r   s     r   test_configure_offreliefz-StandardOptionsTests.test_configure_offrelief  s    fk2r!   c                 H    | j                         }| j                  |d       y )N
overreliefrG  r   s     r   test_configure_overreliefz.StandardOptionsTests.test_configure_overrelief  s    fl3r!   c                 H    | j                         }| j                  |d       y )Nselectcolorr   r   s     r   test_configure_selectcolorz/StandardOptionsTests.test_configure_selectcolor  rk  r!   c                 H    | j                         }| j                  |d       y )Nselectimager%  r   s     r   test_configure_selectimagez/StandardOptionsTests.test_configure_selectimage  rk  r!   c                 H    | j                         }| j                  |d       y )Ntristateimager%  r   s     r   test_configure_tristateimagez1StandardOptionsTests.test_configure_tristateimage  s    V_5r!   c                 J    | j                         }| j                  |dd       y )Ntristatevalue
unknowable)r   r7   r   s     r   test_configure_tristatevaluez1StandardOptionsTests.test_configure_tristatevalue  s    >r!   c                     | j                         }t        j                  | j                        }| j	                  |d|       y )Nvariable)r   r/   	DoubleVarr   r   rg  s      r   test_configure_variablez,StandardOptionsTests.test_configure_variable  s3    		*
C8r!   N)8r   r   r   STANDARD_OPTIONSr   r   r   r   r   r  r  r  r  r  r  r  r  r  r!  r#  r&  r(  r*  r.  r0  r2  r4  r6  r;  rB  rE  rH  rL  rN  rP  rR  rT  rV  r]  rb  rd  rh  rj  rn  rp  rs  rv  rx  r{  r~  r  r  r  r  r  r  rj   r!   r   r   r      s   99
9F
/8KD
0;:@/<70.99
=<J/1H
:
:
0AD9P92M<;=
4>9992634446?9r!   r   c                       e Zd Zd Zd Zy)IntegerSizeTestsc                 N    | j                         }| j                  |dddd       y )Nheightr,  r   r-  r   s     r   test_configure_heightz&IntegerSizeTests.test_configure_height  s#    vxdA>r!   c                 N    | j                         }| j                  |dddd       y )Nwidth  nr   r-  r   s     r   test_configure_widthz%IntegerSizeTests.test_configure_width  s#    vwT1=r!   Nr   r   r   r  r  rj   r!   r   r  r    s    ?>r!   r  c                       e Zd Zd Zd Zy)PixelSizeTestsc           
      T    | j                         }| j                  |ddddddd       y )Nr  r,  gLY@gfffffY@r  r   3cr   r   s     r   r  z$PixelSizeTests.test_configure_height  s)    fhUE4DQr!   c           
      T    | j                         }| j                  |ddddddd       y )Nr  r  gfffff6y@gIy@r  r   5ir   r   s     r   r  z#PixelSizeTests.test_configure_width  s)    fgsE5$4Pr!   Nr  rj   r!   r   r  r    s    RQr!   r  c                        fd}|S )Nc           
            j                   D ][  }d|z   }t         |      rD ]'  }t        ||      st         |t        ||              @ |f fd	}||_        t         ||       ]  S )Ntest_configure_c                 d    | j                         }||    t        d|dj                        )NzOption "z" is not tested in )r   AssertionErrorr   )r   optionr4   clss      r   r   z5add_standard_options.<locals>.decorator.<locals>.test  s3    !%v,.4cll.D E Er!   )r   hasattrsetattrgetattrr   )r  r  
methodnamesource_classr   source_classess   `    r   	decoratorz'add_standard_options.<locals>.decorator  s    kk 	3F*V3J3
+$2 3L|Z8Z 'j AC	3 +1 E
 %/DMCT2	3  
r!   rj   )r  r  s   ` r   add_standard_optionsr    s    $ r!   c                      t         j                  j                  r3t        j                         } t        d| j                  dd      d       y y )Nzpatchlevel =info
patchlevelT)flush)r   r   r   r/   Tclr   r   )tcls    r   setUpModuler    s6    ||kkmnchhv|<DI r!   )r/   test.test_tkinter.supportr   r   r   r   test.supportr   r   r.   r   r   r  r  r  r  rj   r!   r   <module>r     s]    ; ;  H	D8 D8NC9 C9L> >Q Q0Jr!   