Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/tkinter/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/tkinter/test/__pycache__/widget_tests.cpython-35.pyc



��YfeN�@s4ddlZddlZddlZddlmZddlmZmZmZm	Z	m
Z
mZddlZ
dZe	�dddfkr�eZeZe	�dd�dddfkr�eZe�ZGd	d
�d
e�ZGdd�d�ZGd
d�d�ZGdd�d�Zdd�Zdd�ZdS)�N)�Scale)�AbstractTkTest�tcl_version�requires_tcl�get_tk_patchlevel�pixels_conv�
tcl_obj_eqF����c@sTeZdZee�ZdZdZedd��Z	dd�Z
dejdd�Z
d	ed
ddddd
�Zddddd�Zdd�Zdd�Zd
edd�Zdd�Zdddd�Zdd�Zdd �Zd!dd"d#�Zd
dddd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�ZdS)0�AbstractWidgetTestNFcCsIy|jSWn7tk
rDt|jjdd��|_|jSYnXdS)N�tk�scaling)Z_scaling�AttributeError�float�root�call)�self�r�>/opt/alt/python35/lib64/python3.5/tkinter/test/widget_tests.pyrs

zAbstractWidgetTest.scalingcCsU|jr#|jr#tdkr#|St|t�rKdjt|j|��St|�S)Nr	�� )r	r)	�
_stringify�wantobjectsr�
isinstance�tuple�join�map�_str�str)r�valuerrrr&s
zAbstractWidgetTest._strcCs*|||�rdS|j|||�dS)N)�assertEqual)rZactual�expected�msg�eqrrr�assertEqual2-szAbstractWidgetTest.assertEqual2r#�convr%cCs|||<|tkr|}|r.||�}|jsA|jrnt|t�rbtj|�}nt|�}|dkr�t}|j	|||d|�|j	|j
|�|d|�t|t�s|j|�}|j
t|�d�|j	|d|d|�dS)Nr%r
�)�	_sentinelrrrr�tkinterZ_joinr rr&Zcgetr�	configurer"�len)r�widget�namer!r#r'r%�trrr�
checkParam2s"
zAbstractWidgetTest.checkParam�	keep_origTcCs||}|dk	r%|j|�}|jtj��}|||<WdQRX|dk	rp|jt|j�|�|r�|j|||�n
|||<|jtj��}|j||i�WdQRX|dk	r�|jt|j�|�|r|j|||�n
|||<dS)N)�formatZassertRaisesr*ZTclErrorr"r Z	exceptionr+)rr-r.r!�errmsgr1Zorig�cmrrr�checkInvalidParamHs"

z$AbstractWidgetTest.checkInvalidParamcOs+x$|D]}|j||||�qWdS)N)r0)rr-r.�values�kwargsr!rrr�checkParams^s
zAbstractWidgetTest.checkParamscOse|j||||�|j||ddd�|j||ddd�|j||ddd�dS)N�r3zexpected integer but got ""�10pzexpected integer but got "10p"g������	@zexpected integer but got "3.2")r8r5)rr-r.r6r7rrr�checkIntegerParambsz$AbstractWidgetTest.checkIntegerParamcOscx*|D]"}|j|||d||�qW|j||ddd�|j||ddd�dS)Nr'r9r3z)expected floating-point number but got ""�spamz-expected floating-point number but got "spam")r0r5)rr-r.r'r6r7r!rrr�checkFloatParamks
 z"AbstractWidgetTest.checkFloatParamcCs�x'dD]}|j|||dd�qWx'dD]}|j|||dd�q1W|j||dd
d�|j||dd
d�dS)NFr�false�no�offr#T��true�yes�onr9r3z!expected boolean value but got ""r<z%expected boolean value but got "spam")Frr>r?r@)TrArBrCrD)r0r5)rr-r.r!rrr�checkBooleanParamss

z$AbstractWidgetTest.checkBooleanParam�allow_emptycKsN|j||ddddddddd	d
|�|j||ddd
�dS)Nz#ff0000z#00ff00z#0000ffz#123456ZredZgreenZblueZwhiteZblackZgreyr<r3zunknown color name "spam")r8r5)rr-r.rFr7rrr�checkColorParam}sz"AbstractWidgetTest.checkColorParamcKs[|j||dddd|�tdkr>|j||d�|j||dd	d
�dS)NZarrowZwatchZcrossr9r	r
�noner<r3zbad cursor spec "spam")r	r
)r8rr0r5)rr-r.r7rrr�checkCursorParam�s
z#AbstractWidgetTest.checkCursorParamcCs>dd�}|||<|j||�|j||d�dS)NcWsdS)Nr)�argsrrr�command�sz5AbstractWidgetTest.checkCommandParam.<locals>.commandr9)Z
assertTruer8)rr-r.rKrrr�checkCommandParam�s
z$AbstractWidgetTest.checkCommandParamr3cOs�|j||||�|dkr�d|dj|dd��t|�dkrVdnd|df}|j||ddd|�d	|}|j||d
d|�dS)
Nz %s "{}": must be %s%s or %sz, rA��,r9r3Z	ambiguousZbadr<���rO)r8rr,r5)rr-r.r3r6r7Zerrmsg2rrr�checkEnumParam�s
z!AbstractWidgetTest.checkEnumParamc

Os�|dkr|j}xv|D]n}t}|}	t|t�rh|	rh|	tk	rht|�|j}t}	|j|||d|d|	|�qW|j||dddd|�|j||dddd|�dS)	Nr#r'Z6xr3zbad screen distance "6x"r1r<zbad screen distance "spam")	�_conv_pixelsr)rr rr�roundr0r5)
rr-r.r'r1r6r7r!r#Zconv1rrr�checkPixelsParam�s	

z#AbstractWidgetTest.checkPixelsParamc	CsW|j||dddddd�d}tdkr:d}|j||d
d|�dS)
NZflatZgrooveZraisedZridgeZsolidZsunkenzHbad relief "spam": must be flat, groove, raised, ridge, solid, or sunkenr	rr<r3)r	r)r8rr5)rr-r.r3rrr�checkReliefParam�sz#AbstractWidgetTest.checkReliefParamcCs[tjd|jdd�}|j|||dt�|j||ddd�d||<dS)	NZmasterr.Zimage1r'r<r3zimage "spam" doesn't existr9)r*Z
PhotoImagerr0r r5)rr-r.�imagerrr�checkImageParam�s
z"AbstractWidgetTest.checkImageParamcCs|j|||dt�dS)Nr')r0r )rr-r.�varrrr�checkVariableParam�sz%AbstractWidgetTest.checkVariableParamcCs||j|�|j|t�t|�dkrC|jd|f�x2|D]*}t|t�sJ|jd|f�PqJWdS)Nr(zInvalid bounding box: %r)ZassertIsNotNoneZassertIsInstancerr,Zfailr�int)rZbbox�itemrrr�assertIsBoundingBox�s

z&AbstractWidgetTest.assertIsBoundingBoxc
Cs|j�}|j�}t|t�sI|jt|�t|j���x|D]}||qPWtjj	rddddddddd	d
i}t
|�}t
|j�}x^t||�D]L}||ko�|||ko�|||ks�td|j
j|f�q�WdS)N�bd�borderwidth�bg�
background�fg�
foregroundZinvcmdZinvalidcommandZvcmdZvalidatecommandz%s.OPTIONS doesn't contain "%s")�create�keysrrr"�sortedr+�test�support�verbose�set�OPTIONS�print�	__class__�__name__)rr-rc�k�aliasesr#rrr�	test_keys�s("
zAbstractWidgetTest.test_keys) rl�
__module__�__qualname__�staticmethod�pixels_roundrQ�_conv_pad_pixelsr�propertyrr�object�__eq__r&r)r0r5r8r;rr=rErGrIrLrPrSrTrVrXr[rorrrrr
s2		


r
c*@s�eZdZd�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Z	d7d8�Z
d9d:�Zd;d<�Zd=d>�Z
d?d@�ZdAdB�ZdCdD�ZdEdF�ZdGdH�ZdIdJ�ZejejdKkdL�dMdN��ZdOdP�ZdQdR�ZdSdT�ZdUdV�ZdWdX�ZdYdZ�Zd[d\�Zd]d^�Z d_d`�Z!dadb�Z"dcdd�Z#dedf�Z$dgdh�Z%didj�Z&dkdl�Z'dmdn�Z(dodp�Z)dqdr�Z*dsdt�Z+dudv�Z,dwdx�Z-dydz�Z.d{d|�Z/d}d~�Z0dd��Z1d�d��Z2d�d��Z3d�d��Z4d�d��Z5d�d��Z6d�d��Z7d�d��Z8e9d�d��d�d���Z:e9d�d��d�d���Z;d�d��Z<d�S)��StandardOptionsTests�activebackground�activeborderwidth�activeforeground�anchorr_�bitmapr]�compound�cursor�disabledforeground�exportselection�fontra�highlightbackground�highlightcolor�highlightthicknessrU�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 |j�}|j|d�dS)Nry)rbrG)rr-rrr�test_activebackground�sz*StandardOptionsTests.test_activebackgroundc	Cs2|j�}|j|ddddddd�dS)	Nrzrg�������?g333333@rrMr:���)rbrS)rr-rrr�test_activeborderwidth�sz+StandardOptionsTests.test_activeborderwidthcCs |j�}|j|d�dS)Nr{)rbrG)rr-rrr�test_activeforegroundsz*StandardOptionsTests.test_activeforegroundcCs;|j�}|j|ddddddddd	d
�dS)Nr|�n�ne�eZse�sZsw�wZnw�center)rbrP)rr-rrr�test_anchorsz StandardOptionsTests.test_anchorcCs?|j�}|j|d�d|jkr;|j|d�dS)Nr_r^)rbrGri)rr-rrr�test_background
sz$StandardOptionsTests.test_backgroundcCs�|j�}|j|dd�|j|dd�tjjddd�}|j|dd|�d|jjjd	d
�ko�d|jj�ks�|j	|ddd
d�dS)Nr}Z	questheadZgray50z
python.xbmZsubdirZ
imghdrdata�@ZaquarZwindowingsystemZAppKitr<r3zbitmap "spam" not defined)
rbr0rerfZfindfilerrrZwinfo_serverr5)rr-�filenamerrr�test_bitmapsz StandardOptionsTests.test_bitmapc	Csc|j�}|j|dddddd	d�d|jkr_|j|dddddd
d�dS)Nr]rg�������?g������@rrMr:r\r�r�)rbrSri)rr-rrr�test_borderwidth s
z%StandardOptionsTests.test_borderwidthc	Cs2|j�}|j|ddddddd�dS)Nr~Zbottomr��leftrH�right�top)rbrP)rr-rrr�
test_compound'sz"StandardOptionsTests.test_compoundcCs |j�}|j|d�dS)Nr)rbrI)rr-rrr�test_cursor,sz StandardOptionsTests.test_cursorcCs |j�}|j|d�dS)Nr�)rbrG)rr-rrr�test_disabledforeground0sz,StandardOptionsTests.test_disabledforegroundcCs |j�}|j|d�dS)Nr�)rbrE)rr-rrr�test_exportselection4sz)StandardOptionsTests.test_exportselectioncCs<|j�}|j|dd�|j|dddd�dS)Nr�z3-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*r9r3zfont "" doesn't exist)rbr0r5)rr-rrr�	test_font8s
zStandardOptionsTests.test_fontcCs?|j�}|j|d�d|jkr;|j|d�dS)Nrar`)rbrGri)rr-rrr�test_foreground?sz$StandardOptionsTests.test_foregroundcCs |j�}|j|d�dS)Nr�)rbrG)rr-rrr�test_highlightbackgroundEsz-StandardOptionsTests.test_highlightbackgroundcCs |j�}|j|d�dS)Nr�)rbrG)rr-rrr�test_highlightcolorIsz(StandardOptionsTests.test_highlightcolorcCsQ|j�}|j|dddddd�|j|dd
ddd	|j�dS)Nr�rg�������?g������@rr:rMr#r'r�)rbrSr0rQ)rr-rrr�test_highlightthicknessMs
z,StandardOptionsTests.test_highlightthickness�darwinz"crashes with Cocoa Tk (issue19733)cCs |j�}|j|d�dS)NrU)rbrV)rr-rrr�
test_imageTszStandardOptionsTests.test_imagecCs |j�}|j|d�dS)Nr�)rbrG)rr-rrr�test_insertbackgroundZsz*StandardOptionsTests.test_insertbackgroundc	Cs2|j�}|j|ddddddd�dS)	Nr�rg�������?g������@rrMr:r�)rbrS)rr-rrr�test_insertborderwidth^sz+StandardOptionsTests.test_insertborderwidthcCs#|j�}|j|dd�dS)Nr��d)rbr;)rr-rrr�test_insertofftimecsz'StandardOptionsTests.test_insertofftimecCs#|j�}|j|dd�dS)Nr�r�)rbr;)rr-rrr�test_insertontimegsz&StandardOptionsTests.test_insertontimecCs,|j�}|j|ddddd�dS)Nr�g�������?g������@rMr:r�)rbrS)rr-rrr�test_insertwidthksz%StandardOptionsTests.test_insertwidthcCs |j�}|j|d�dS)Nr�)rbrE)rr-rrr�	test_jumposzStandardOptionsTests.test_jumpcCsH|j�}|j|dddddd�|j|dddd�dS)	Nr�r�r�r�r3z6bad justification "{}": must be left, right, or centerr9z:ambiguous justification "": must be left, right, or center)rbrPr5)rr-rrr�test_justifyss
z!StandardOptionsTests.test_justifycCsC|j�}|jt|d�|j�|j|ddd�dS)Nr�Z
horizontalZvertical)rbr"r Zdefault_orientrP)rr-rrr�test_orient|sz StandardOptionsTests.test_orientc
Cs8|j�}|j|ddddddd|j�dS)	Nr�rg������@gffffff@rM�12mr'r�)rbrSrt)rr-rrr�	test_padx�szStandardOptionsTests.test_padxc
Cs8|j�}|j|ddddddd|j�dS)	Nr�rg������@gffffff@rMr�r'r�)rbrSrt)rr-rrr�	test_pady�szStandardOptionsTests.test_padycCs |j�}|j|d�dS)Nr�)rbrT)rr-rrr�test_relief�sz StandardOptionsTests.test_reliefcCs&|j�}|j|ddd�dS)Nr�i�i���)rbr;)rr-rrr�test_repeatdelay�sz%StandardOptionsTests.test_repeatdelaycCs&|j�}|j|ddd�dS)Nr�i�i���)rbr;)rr-rrr�test_repeatinterval�sz(StandardOptionsTests.test_repeatintervalcCs |j�}|j|d�dS)Nr�)rbrG)rr-rrr�test_selectbackground�sz*StandardOptionsTests.test_selectbackgroundcCs,|j�}|j|ddddd�dS)Nr�g�������?g������@rMr:r�)rbrS)rr-rrr�test_selectborderwidth�sz+StandardOptionsTests.test_selectborderwidthcCs |j�}|j|d�dS)Nr�)rbrG)rr-rrr�test_selectforeground�sz*StandardOptionsTests.test_selectforegroundcCs |j�}|j|d�dS)Nr�)rbrE)rr-rrr�test_setgrid�sz!StandardOptionsTests.test_setgridcCs)|j�}|j|dddd�dS)N�stateZactiveZdisabledZnormal)rbrP)rr-rrr�
test_state�szStandardOptionsTests.test_statecCs)|j�}|j|dddd�dS)Nr��0�1r9)rbr8)rr-rrr�test_takefocus�sz#StandardOptionsTests.test_takefocuscCs&|j�}|j|ddd�dS)Nr�r9z
any string)rbr8)rr-rrr�	test_text�szStandardOptionsTests.test_textcCs5|j�}tj|j�}|j|d|�dS)Nr�)rbr*Z	StringVarrrX)rr-rWrrr�test_textvariable�sz&StandardOptionsTests.test_textvariablecCs |j�}|j|d�dS)Nr�)rbrG)rr-rrr�test_troughcolor�sz%StandardOptionsTests.test_troughcolorcCs)|j�}|j|dddd�dS)Nr�rrA�
)rbr;)rr-rrr�test_underline�sz#StandardOptionsTests.test_underlinecCs#|j�}|j|dd�dS)Nr�r�)rbrS)rr-rrr�test_wraplength�sz$StandardOptionsTests.test_wraplengthcCs |j�}|j|d�dS)Nr�)rbrL)rr-rrr�test_xscrollcommand�sz(StandardOptionsTests.test_xscrollcommandcCs |j�}|j|d�dS)Nr�)rbrL)rr-rrr�test_yscrollcommand�sz(StandardOptionsTests.test_yscrollcommandcCs |j�}|j|d�dS)NrK)rbrL)rr-rrr�test_command�sz!StandardOptionsTests.test_commandcCs |j�}|j|d�dS)NZindicatoron)rbrE)rr-rrr�test_indicatoron�sz%StandardOptionsTests.test_indicatoroncCs |j�}|j|d�dS)NZ	offrelief)rbrT)rr-rrr�test_offrelief�sz#StandardOptionsTests.test_offreliefcCs |j�}|j|d�dS)NZ
overrelief)rbrT)rr-rrr�test_overrelief�sz$StandardOptionsTests.test_overreliefcCs |j�}|j|d�dS)NZselectcolor)rbrG)rr-rrr�test_selectcolor�sz%StandardOptionsTests.test_selectcolorcCs |j�}|j|d�dS)NZselectimage)rbrV)rr-rrr�test_selectimage�sz%StandardOptionsTests.test_selectimager	r
cCs |j�}|j|d�dS)NZ
tristateimage)rbrV)rr-rrr�test_tristateimage�sz'StandardOptionsTests.test_tristateimagecCs#|j�}|j|dd�dS)NZ
tristatevalueZ
unknowable)rbr0)rr-rrr�test_tristatevalue�sz'StandardOptionsTests.test_tristatevaluecCs5|j�}tj|j�}|j|d|�dS)NZvariable)rbr*Z	DoubleVarrrX)rr-rWrrr�
test_variable�sz"StandardOptionsTests.test_variableN)*ryrzr{r|r_r}r]r~rr�r�r�rar�r�r�rUr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�)=rlrprqZSTANDARD_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�rrrrrx�s�
	rxc@s(eZdZdd�Zdd�ZdS)�IntegerSizeTestscCs)|j�}|j|dddd�dS)N�heightr�ri����)rbr;)rr-rrr�test_height�szIntegerSizeTests.test_heightcCs)|j�}|j|dddd�dS)N�widthi�rin���)rbr;)rr-rrr�
test_width�szIntegerSizeTests.test_widthN)rlrprqr�r�rrrrr��sr�c@s(eZdZdd�Zdd�ZdS)�PixelSizeTestsc	Cs2|j�}|j|ddddddd�dS)Nr�r�g�����LY@gfffff�Y@rZ3ci����)rbrS)rr-rrrr�szPixelSizeTests.test_heightc	Cs2|j�}|j|ddddddd�dS)Nr�i�gfffff6y@g�����Iy@rZ5iin���)rbrS)rr-rrrr�szPixelSizeTests.test_widthN)rlrprqr�r�rrrrr�sr�cs�fdd�}|S)Ncs�x��jD]�}d|}t�|�s
xe�D]/}t||�r0t�|t||��Pq0W|�fdd�}||_t�||�q
W�S)NZtest_cs1|j�}||td|�jf��dS)NzOption "%s" is not tested in %s)rb�AssertionErrorrl)r�optionr-)�clsrrresz5add_standard_options.<locals>.decorator.<locals>.test)ri�hasattr�setattr�getattrrl)r�r�Z
methodnameZsource_classre)�source_classes)r�r�	decorator
s

		z'add_standard_options.<locals>.decoratorr)r�r�r)r�r�add_standard_options
sr�cCs5tjjr1tj�}td|jdd��dS)Nzpatchlevel =�infoZ
patchlevel)rerfrgr*ZTclrjr)Ztclrrr�setUpModule!sr�)r�r�r*Ztkinter.ttkrZtkinter.test.supportrrrrrrZtest.supportreZnoconvr rRrsrYrvr)r
rxr�r�r�r�rrrr�<module>s&."	��