Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/tkinter/test/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/tkinter/test/__pycache__/widget_tests.cpython-37.pyc

B

� f�M�@s�ddlZddlZddlZddlmZmZmZmZmZm	Z	ddl
ZdZe�dkrRe
ZeZe�dd�dkrleZe�ZGdd�de�ZGdd	�d	�ZGd
d�d�ZGdd
�d
�Zdd�Zdd�ZdS)�N)�AbstractTkTest�tcl_version�requires_tcl�get_tk_patchlevel�pixels_conv�
tcl_obj_eqF)����c@s�eZdZee�ZdZdZedd��Z	dd�Z
dejfdd�Z
eddd	�d
d�Zd0dd
�dd�Zdd�Zdd�Zed�dd�Zdd�Zdd�dd�Zdd�Zdd�Zdd �d!d"�Zddd#�d$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�ZdS)1�AbstractWidgetTestNFcCs6y|jStk
r0t|j�dd��|_|jSXdS)N�tk�scaling)Z_scaling�AttributeError�float�root�call)�self�r�>/opt/alt/python37/lib64/python3.7/tkinter/test/widget_tests.pyrs
zAbstractWidgetTest.scalingcCs<|js|jrtdkr|St|t�r4d�t|j|��St|�S)N)r�� )	�
_stringify�wantobjectsr�
isinstance�tuple�join�map�_str�str)r�valuerrrr%s

zAbstractWidgetTest._strcCs |||�rdS|�|||�dS)N)�assertEqual)rZactual�expected�msg�eqrrr�assertEqual2,s
zAbstractWidgetTest.assertEqual2)r"�convr$cCs�|||<|tkr|}|r ||�}|js,|jsJt|t�rBt�|�}nt|�}|dkrVt}|j	||||d�|j	|�
|�||d�|�|�}|�t
|�d�|j	|d||d�dS)N)r$r	�)�	_sentinelrrrr�tkinterZ_joinrrr%Zcget�	configurer!�len)r�widget�namer r"r&r$�trrr�
checkParam1s 

zAbstractWidgetTest.checkParamT)�	keep_origc	Cs�||}|dk	r|�|�}|�tj��}|||<WdQRX|dk	rT|�t|j�|�|rj|�|||�n|||<|�tj��}|�||i�WdQRX|dk	r�|�t|j�|�|r�|�|||�n|||<dS)N)�formatZassertRaisesr)ZTclErrorr!rZ	exceptionr*)rr,r-r �errmsgr0Zorig�cmrrr�checkInvalidParamEs"
z$AbstractWidgetTest.checkInvalidParamcOs$x|D]}|j|||f|�qWdS)N)r/)rr,r-�values�kwargsr rrr�checkParams[s
zAbstractWidgetTest.checkParamscOsN|j||f|�|�|j||ddd�|j||ddd�|j||ddd�dS)N�zexpected integer but got "")r2�10pzexpected integer but got "10p"g������	@zexpected integer but got "3.2")r7r4)rr,r-r5r6rrr�checkIntegerParam_s


z$AbstractWidgetTest.checkIntegerParam)r&cOsPx&|D]}|j|||fd|i|��qW|j||ddd�|j||ddd�dS)Nr&r8z)expected floating-point number but got "")r2�spamz-expected floating-point number but got "spam")r/r4)rr,r-r&r5r6r rrr�checkFloatParamhs


z"AbstractWidgetTest.checkFloatParamcCshxdD]}|j|||dd�qWxdD]}|j|||dd�q&W|j||ddd�|j||d	d
d�dS)N)FrZfalseZnoZoffr)r")T��trueZyesZonr=r8z!expected boolean value but got "")r2r;z%expected boolean value but got "spam")r/r4)rr,r-r rrr�checkBooleanParamps



z$AbstractWidgetTest.checkBooleanParam)�allow_emptyc
Ks:|j||ddddddddd	d
f|�|j||ddd
�dS)Nz#ff0000z#00ff00z#0000ffz#123456ZredZgreenZblueZwhiteZblackZgreyr;zunknown color name "spam")r2)r7r4)rr,r-r@r6rrr�checkColorParamzs
z"AbstractWidgetTest.checkColorParamcKsD|j||ddddf|�tdkr.|�||d�|j||ddd	�dS)
NZarrowZwatchZcrossr8)rr	�noner;zbad cursor spec "spam")r2)r7rr/r4)rr,r-r6rrr�checkCursorParam�s

z#AbstractWidgetTest.checkCursorParamcCs0dd�}|||<|�||�|�||d�dS)NcWsdS)Nr)�argsrrr�command�sz5AbstractWidgetTest.checkCommandParam.<locals>.commandr8)Z
assertTruer7)rr,r-rErrr�checkCommandParam�sz$AbstractWidgetTest.checkCommandParam)r2cOs�|j||f|�|�|dkrld|d�|dd��t|�dkr@dnd|df}|j||dd|d�d	|}|j||d
|d�dS)Nz %s "{}": must be %s%s or %sz, �����,r8Z	ambiguous)r2Zbadr;)r7rr+r4)rr,r-r2r5r6Zerrmsg2rrr�checkEnumParam�s
z!AbstractWidgetTest.checkEnumParam)r&r0c
Os�|dkr|j}xX|D]P}t}|}	t|t�rH|	rH|	tk	rHt|�|j}t}	|j|||f||	d�|��qW|j||dd|d�|j||dd|d�dS)N)r"r&Z6xzbad screen distance "6x")r2r0r;zbad screen distance "spam")	�_conv_pixelsr(rrrr�roundr/r4)
rr,r-r&r0r5r6r r"Zconv1rrr�checkPixelsParam�s




z#AbstractWidgetTest.checkPixelsParamc
Cs>|�||dddddd�d}tdkr(d}|j||d	|d
�dS)NZflatZgrooveZraisedZridgeZsolidZsunkenzHbad relief "spam": must be flat, groove, raised, ridge, solid, or sunken)rrr;)r2)r7rr4)rr,r-r2rrr�checkReliefParam�s
z#AbstractWidgetTest.checkReliefParamcCs@tj|jdd�}|j|||td�|j||ddd�d||<dS)NZimage1)Zmasterr-)r&r;zimage "spam" doesn't exist)r2r8)r)Z
PhotoImagerr/rr4)rr,r-�imagerrr�checkImageParam�s

z"AbstractWidgetTest.checkImageParamcCs|j|||td�dS)N)r&)r/r)rr,r-�varrrr�checkVariableParam�sz%AbstractWidgetTest.checkVariableParamcCs`|�|�|�|t�t|�dkr2|�d|f�x(|D] }t|t�s8|�d|f�Pq8WdS)Nr'zInvalid bounding box: %r)ZassertIsNotNoneZassertIsInstancerr+Zfailr�int)rZbbox�itemrrr�assertIsBoundingBox�s


z&AbstractWidgetTest.assertIsBoundingBoxcCs�|��}|��}|�t|�t|����x|D]}||q.Wtjjr�dddddd�}t|�}t|j	�}xHt||�D]8}||kr�|||kr�|||ksvt
d|jj|f�qvWdS)N�borderwidth�
background�
foregroundZinvalidcommandZvalidatecommand)�bd�bg�fgZinvcmdZvcmdz%s.OPTIONS doesn't contain "%s")
�create�keysr!�sortedr*�test�support�verbose�set�OPTIONS�print�	__class__�__name__)rr,r]�k�aliasesr"rrr�	test_keys�s&

zAbstractWidgetTest.test_keys)N) rf�
__module__�__qualname__�staticmethod�pixels_roundrK�_conv_pad_pixelsr�propertyrr�object�__eq__r%r(r/r4r7r:rr<r?rArCrFrJrMrNrPrRrUrirrrrrs0	

rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Ze�ejd"kd#�d$d%��Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Z d6d7�Z!d8d9�Z"d:d;�Z#d<d=�Z$d>d?�Z%d@dA�Z&dBdC�Z'dDdE�Z(dFdG�Z)dHdI�Z*dJdK�Z+dLdM�Z,dNdO�Z-dPdQ�Z.dRdS�Z/dTdU�Z0dVdW�Z1dXdY�Z2dZd[�Z3d\d]�Z4d^d_�Z5d`da�Z6dbdc�Z7ddde�Z8e9dfdg�dhdi��Z:e9dfdg�djdk��Z;dldm�Z<dnS)o�StandardOptionsTests)*�activebackground�activeborderwidth�activeforeground�anchorrW�bitmaprV�compound�cursor�disabledforeground�exportselection�fontrX�highlightbackground�highlightcolor�highlightthicknessrO�insertbackground�insertborderwidth�
insertofftime�insertontime�insertwidth�jump�justify�orient�padx�pady�relief�repeatdelay�repeatinterval�selectbackground�selectborderwidth�selectforeground�setgrid�	takefocus�text�textvariable�troughcolor�	underline�
wraplength�xscrollcommand�yscrollcommandcCs|��}|�|d�dS)Nrs)r\rA)rr,rrr�test_activebackground�sz*StandardOptionsTests.test_activebackgroundc
Cs$|��}|�|ddddddd�dS)Nrtrg�������?g333333@r���r9)r\rM)rr,rrr�test_activeborderwidth�sz+StandardOptionsTests.test_activeborderwidthcCs|��}|�|d�dS)Nru)r\rA)rr,rrr�test_activeforeground�sz*StandardOptionsTests.test_activeforegroundc
Cs*|��}|�|ddddddddd	d
�dS)Nrv�n�ne�eZse�s�sw�wZnw�center)r\rJ)rr,rrr�test_anchorsz StandardOptionsTests.test_anchorcCs.|��}|�|d�d|jkr*|�|d�dS)NrWrZ)r\rArc)rr,rrr�test_backgrounds
z$StandardOptionsTests.test_backgroundcCs~|��}|�|dd�|�|dd�tjjddd�}|�|dd|�d|jj�d	d
�krhd|j��ksz|j	|ddd
d�dS)NrwZ	questheadZgray50z
python.xbmZ
imghdrdata)Zsubdir�@Zaquar
ZwindowingsystemZAppKitr;zbitmap "spam" not defined)r2)
r\r/r_r`Zfindfilerr
rZwinfo_serverr4)rr,�filenamerrr�test_bitmaps
z StandardOptionsTests.test_bitmapc
CsF|��}|�|ddddddd�d|jkrB|�|ddddddd�dS)	NrVrg�������?g������@rr�r9rY)r\rMrc)rr,rrr�test_borderwidths

z%StandardOptionsTests.test_borderwidthc
Cs$|��}|�|ddddddd�dS)NrxZbottomr��leftrB�right�top)r\rJ)rr,rrr�
test_compound"sz"StandardOptionsTests.test_compoundcCs|��}|�|d�dS)Nry)r\rC)rr,rrr�test_cursor'sz StandardOptionsTests.test_cursorcCs|��}|�|d�dS)Nrz)r\rA)rr,rrr�test_disabledforeground+sz,StandardOptionsTests.test_disabledforegroundcCs|��}|�|d�dS)Nr{)r\r?)rr,rrr�test_exportselection/sz)StandardOptionsTests.test_exportselectioncCs,|��}|�|dd�|j|dddd�dS)Nr|z3-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*r8zfont "" doesn't exist)r2)r\r/r4)rr,rrr�	test_font3s

zStandardOptionsTests.test_fontcCs.|��}|�|d�d|jkr*|�|d�dS)NrXr[)r\rArc)rr,rrr�test_foreground:s
z$StandardOptionsTests.test_foregroundcCs|��}|�|d�dS)Nr})r\rA)rr,rrr�test_highlightbackground@sz-StandardOptionsTests.test_highlightbackgroundcCs|��}|�|d�dS)Nr~)r\rA)rr,rrr�test_highlightcolorDsz(StandardOptionsTests.test_highlightcolorc	Cs8|��}|�|dddddd�|j|ddd|jd�dS)	Nrrg�������?g������@rr9r�)r"r&)r\rMr/rK)rr,rrr�test_highlightthicknessHs
z,StandardOptionsTests.test_highlightthickness�darwinz"crashes with Cocoa Tk (issue19733)cCs|��}|�|d�dS)NrO)r\rP)rr,rrr�
test_imageOszStandardOptionsTests.test_imagecCs|��}|�|d�dS)Nr�)r\rA)rr,rrr�test_insertbackgroundUsz*StandardOptionsTests.test_insertbackgroundc
Cs$|��}|�|ddddddd�dS)Nr�rg�������?g������@rr�r9)r\rM)rr,rrr�test_insertborderwidthYsz+StandardOptionsTests.test_insertborderwidthcCs|��}|�|dd�dS)Nr��d)r\r:)rr,rrr�test_insertofftime^sz'StandardOptionsTests.test_insertofftimecCs|��}|�|dd�dS)Nr�r�)r\r:)rr,rrr�test_insertontimebsz&StandardOptionsTests.test_insertontimecCs |��}|�|ddddd�dS)Nr�g�������?g������@r�r9)r\rM)rr,rrr�test_insertwidthfsz%StandardOptionsTests.test_insertwidthcCs|��}|�|d�dS)Nr�)r\r?)rr,rrr�	test_jumpjszStandardOptionsTests.test_jumpcCs4|��}|j|dddddd�|j|dddd�dS)	Nr�r�r�r�z6bad justification "{}": must be left, right, or center)r2r8z:ambiguous justification "": must be left, right, or center)r\rJr4)rr,rrr�test_justifyns

z!StandardOptionsTests.test_justifycCs2|��}|�t|d�|j�|�|ddd�dS)Nr�Z
horizontalZvertical)r\r!rZdefault_orientrJ)rr,rrr�test_orientwsz StandardOptionsTests.test_orientc
Cs(|��}|j|dddddd|jd�dS)Nr�rg������@gffffff@r��12m)r&)r\rMrn)rr,rrr�	test_padx|szStandardOptionsTests.test_padxc
Cs(|��}|j|dddddd|jd�dS)Nr�rg������@gffffff@r�r�)r&)r\rMrn)rr,rrr�	test_pady�szStandardOptionsTests.test_padycCs|��}|�|d�dS)Nr�)r\rN)rr,rrr�test_relief�sz StandardOptionsTests.test_reliefcCs|��}|�|ddd�dS)Nr�i���i�)r\r:)rr,rrr�test_repeatdelay�sz%StandardOptionsTests.test_repeatdelaycCs|��}|�|ddd�dS)Nr�i���i�)r\r:)rr,rrr�test_repeatinterval�sz(StandardOptionsTests.test_repeatintervalcCs|��}|�|d�dS)Nr�)r\rA)rr,rrr�test_selectbackground�sz*StandardOptionsTests.test_selectbackgroundcCs |��}|�|ddddd�dS)Nr�g�������?g������@r�r9)r\rM)rr,rrr�test_selectborderwidth�sz+StandardOptionsTests.test_selectborderwidthcCs|��}|�|d�dS)Nr�)r\rA)rr,rrr�test_selectforeground�sz*StandardOptionsTests.test_selectforegroundcCs|��}|�|d�dS)Nr�)r\r?)rr,rrr�test_setgrid�sz!StandardOptionsTests.test_setgridcCs|��}|�|dddd�dS)N�stateZactiveZdisabledZnormal)r\rJ)rr,rrr�
test_state�szStandardOptionsTests.test_statecCs|��}|�|dddd�dS)Nr��0�1r8)r\r7)rr,rrr�test_takefocus�sz#StandardOptionsTests.test_takefocuscCs|��}|�|ddd�dS)Nr�r8z
any string)r\r7)rr,rrr�	test_text�szStandardOptionsTests.test_textcCs&|��}t�|j�}|�|d|�dS)Nr�)r\r)Z	StringVarrrR)rr,rQrrr�test_textvariable�sz&StandardOptionsTests.test_textvariablecCs|��}|�|d�dS)Nr�)r\rA)rr,rrr�test_troughcolor�sz%StandardOptionsTests.test_troughcolorcCs|��}|�|dddd�dS)Nr�rr=�
)r\r:)rr,rrr�test_underline�sz#StandardOptionsTests.test_underlinecCs|��}|�|dd�dS)Nr�r�)r\rM)rr,rrr�test_wraplength�sz$StandardOptionsTests.test_wraplengthcCs|��}|�|d�dS)Nr�)r\rF)rr,rrr�test_xscrollcommand�sz(StandardOptionsTests.test_xscrollcommandcCs|��}|�|d�dS)Nr�)r\rF)rr,rrr�test_yscrollcommand�sz(StandardOptionsTests.test_yscrollcommandcCs|��}|�|d�dS)NrE)r\rF)rr,rrr�test_command�sz!StandardOptionsTests.test_commandcCs|��}|�|d�dS)NZindicatoron)r\r?)rr,rrr�test_indicatoron�sz%StandardOptionsTests.test_indicatoroncCs|��}|�|d�dS)NZ	offrelief)r\rN)rr,rrr�test_offrelief�sz#StandardOptionsTests.test_offreliefcCs|��}|�|d�dS)NZ
overrelief)r\rN)rr,rrr�test_overrelief�sz$StandardOptionsTests.test_overreliefcCs|��}|�|d�dS)NZselectcolor)r\rA)rr,rrr�test_selectcolor�sz%StandardOptionsTests.test_selectcolorcCs|��}|�|d�dS)NZselectimage)r\rP)rr,rrr�test_selectimage�sz%StandardOptionsTests.test_selectimagerr	cCs|��}|�|d�dS)NZ
tristateimage)r\rP)rr,rrr�test_tristateimage�sz'StandardOptionsTests.test_tristateimagecCs|��}|�|dd�dS)NZ
tristatevalueZ
unknowable)r\r/)rr,rrr�test_tristatevalue�sz'StandardOptionsTests.test_tristatevaluecCs&|��}t�|j�}|�|d|�dS)NZvariable)r\r)Z	DoubleVarrrR)rr,rQrrr�
test_variable�sz"StandardOptionsTests.test_variableN)=rfrjrkZSTANDARD_OPTIONSr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��unittestZskipIf�sys�platformr�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�r�r�r�r�r�r�r�rr�r�r�rrrrrr�sl

	rrc@seZdZdd�Zdd�ZdS)�IntegerSizeTestscCs|��}|�|dddd�dS)N�heightr�i����r)r\r:)rr,rrr�test_height�szIntegerSizeTests.test_heightcCs|��}|�|dddd�dS)N�widthi�in���r)r\r:)rr,rrr�
test_width�szIntegerSizeTests.test_widthN)rfrjrkr�r�rrrrr��sr�c@seZdZdd�Zdd�ZdS)�PixelSizeTestsc
Cs$|��}|�|ddddddd�dS)Nr�r�g�����LY@gfffff�Y@i����rZ3c)r\rM)rr,rrrr��szPixelSizeTests.test_heightc
Cs$|��}|�|ddddddd�dS)Nr�i�gfffff6y@g�����Iy@in���rZ5i)r\rM)rr,rrrr�szPixelSizeTests.test_widthN)rfrjrkr�r�rrrrr��sr�cs�fdd�}|S)Ncstxn�jD]d}d|}t�|�sxL�D]"}t||�r$t�|t||��Pq$W|f�fdd�	}||_t�||�qW�S)NZtest_cs&|��}||td|�jf��dS)NzOption "%s" is not tested in %s)r\�AssertionErrorrf)r�optionr,)�clsrrr_sz5add_standard_options.<locals>.decorator.<locals>.test)rc�hasattr�setattr�getattrrf)r�r�Z
methodnameZsource_classr_)�source_classes)r�r�	decorators


z'add_standard_options.<locals>.decoratorr)r�r�r)r�r�add_standard_optionssr�cCs&tjjr"t��}td|�dd��dS)Nzpatchlevel =�infoZ
patchlevel)r_r`rar)ZTclrdr)Ztclrrr�setUpModulesr�)r�r�r)Ztkinter.test.supportrrrrrrZtest.supportr_ZnoconvrrLrmrSrpr(rrrr�r�r�r�rrrr�<module>s( 
P