Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/tkinter/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/tkinter/test/__pycache__/widget_tests.cpython-34.pyc

�
h f�J�@s:ddlZddlZddlZddlmZddlmZmZmZm	Z	m
Z
mZddlZ
dZe	�dddfkr�eZneZe	�dd�dddfkr�eZne�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@sHeZdZee�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-�ZdS).�AbstractWidgetTestNFcCsIy|jSWn7tk
rDt|jjdd��|_|jSYnXdS)N�tk�scaling)Z_scaling�AttributeError�float�root�call)�self�r�>/opt/alt/python34/lib64/python3.4/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|}n|r4||�}n|jsG|jrwt|t�rhtj|�}qwt|�}n|dkr�t}n|j	|||d|�|j	|j
|�|d|�t|t�s|j|�}|j
t|�d�|j	|d|d|�ndS)Nr%r
�)�	_sentinelrrrr�tkinterZ_joinr rr&Zcgetr�	configurer"�len)r�widget�namer!r#r'r%�trrr�
checkParam2s"
		zAbstractWidgetTest.checkParam�	keep_origTcCs||}|dk	r(|j|�}n|jtj��}|||<WdQX|dk	ru|jt|j�|�n|r�|j|||�n
|||<|jtj��}|ji||6�WdQX|dk	r�|jt|j�|�n|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>znor@)TrAztruezyesrD)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|�tdkrA|j||d�n|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	|}n|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}nx||D]t}t}|}	t|t�rq|	rq|	tk	rqt|�|j}t}	qqn|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	CsZ|j||dddddd�d}tdkr=d}n|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|�dkrF|jd|f�nx5|D]-}t|t�sM|jd|f�PqMqMWdS)Nr(zInvalid bounding box: %r)ZassertIsNotNoneZassertIsInstancerr,Zfailr�int)rZbbox�itemrrr�assertIsBoundingBox�s

z&AbstractWidgetTest.assertIsBoundingBox)�__name__�
__module__�__qualname__�staticmethod�pixels_roundrQ�_conv_pad_pixelsr�propertyrr�object�__eq__r&r)r0r5r8r;rr=rErGrIrLrPrSrTrVrXr[rrrrr
s0		


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�anchor�
background�bitmap�borderwidth�compound�cursor�disabledforeground�exportselection�font�
foreground�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)Nrf)�createrG)rr-rrr�test_activebackground�sz*StandardOptionsTests.test_activebackgroundc	Cs2|j�}|j|ddddddd�dS)	Nrgrg�������?g333333@rrMr:���)r�rS)rr-rrr�test_activeborderwidth�sz+StandardOptionsTests.test_activeborderwidthcCs |j�}|j|d�dS)Nrh)r�rG)rr-rrr�test_activeforeground�sz*StandardOptionsTests.test_activeforegroundcCs;|j�}|j|ddddddddd	d
�dS)Nri�n�ne�eZse�sZsw�wZnw�center)r�rP)rr-rrr�test_anchor�sz StandardOptionsTests.test_anchorcCsB|j�}|j|d�d|jkr>|j|d�ndS)NrjZbg)r�rG�OPTIONS)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�ndS)NrkZ	questheadZgray50z
python.xbmZsubdirZ
imghdrdata�@ZaquarZwindowingsystemZAppKitr<r3zbitmap "spam" not defined)
r�r0�test�supportZfindfilerrrZwinfo_serverr5)rr-�filenamerrr�test_bitmap�sz StandardOptionsTests.test_bitmapc	Csf|j�}|j|dddddd	d�d|jkrb|j|dddddd
d�ndS)Nrlrg�������?g������@rrMr:Zbdr�r�)r�rSr�)rr-rrr�test_borderwidths
z%StandardOptionsTests.test_borderwidthc	Cs2|j�}|j|ddddddd�dS)NrmZbottomr��leftrH�right�top)r�rP)rr-rrr�
test_compoundsz"StandardOptionsTests.test_compoundcCs |j�}|j|d�dS)Nrn)r�rI)rr-rrr�test_cursorsz StandardOptionsTests.test_cursorcCs |j�}|j|d�dS)Nro)r�rG)rr-rrr�test_disabledforegroundsz,StandardOptionsTests.test_disabledforegroundcCs |j�}|j|d�dS)Nrp)r�rE)rr-rrr�test_exportselectionsz)StandardOptionsTests.test_exportselectioncCs<|j�}|j|dd�|j|dddd�dS)Nrqz3-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*r9r3zfont "" doesn't exist)r�r0r5)rr-rrr�	test_fonts
zStandardOptionsTests.test_fontcCsB|j�}|j|d�d|jkr>|j|d�ndS)NrrZfg)r�rGr�)rr-rrr�test_foreground$sz$StandardOptionsTests.test_foregroundcCs |j�}|j|d�dS)Nrs)r�rG)rr-rrr�test_highlightbackground*sz-StandardOptionsTests.test_highlightbackgroundcCs |j�}|j|d�dS)Nrt)r�rG)rr-rrr�test_highlightcolor.sz(StandardOptionsTests.test_highlightcolorcCsQ|j�}|j|dddddd�|j|dd
ddd	|j�dS)Nrurg�������?g������@rr:rMr#r'r�)r�rSr0rQ)rr-rrr�test_highlightthickness2s
z,StandardOptionsTests.test_highlightthickness�darwinz"crashes with Cocoa Tk (issue19733)cCs |j�}|j|d�dS)NrU)r�rV)rr-rrr�
test_image9szStandardOptionsTests.test_imagecCs |j�}|j|d�dS)Nrv)r�rG)rr-rrr�test_insertbackground?sz*StandardOptionsTests.test_insertbackgroundc	Cs2|j�}|j|ddddddd�dS)	Nrwrg�������?g������@rrMr:r�)r�rS)rr-rrr�test_insertborderwidthCsz+StandardOptionsTests.test_insertborderwidthcCs#|j�}|j|dd�dS)Nrx�d)r�r;)rr-rrr�test_insertofftimeHsz'StandardOptionsTests.test_insertofftimecCs#|j�}|j|dd�dS)Nryr�)r�r;)rr-rrr�test_insertontimeLsz&StandardOptionsTests.test_insertontimecCs,|j�}|j|ddddd�dS)Nrzg�������?g������@rMr:r�)r�rS)rr-rrr�test_insertwidthPsz%StandardOptionsTests.test_insertwidthcCs |j�}|j|d�dS)Nr{)r�rE)rr-rrr�	test_jumpTs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)r�rPr5)rr-rrr�test_justifyXs
z!StandardOptionsTests.test_justifycCsC|j�}|jt|d�|j�|j|ddd�dS)Nr}Z
horizontalZvertical)r�r"r Zdefault_orientrP)rr-rrr�test_orientasz StandardOptionsTests.test_orientc
Cs8|j�}|j|ddddddd|j�dS)	Nr~rg������@gffffff@rM�12mr'r�)r�rSra)rr-rrr�	test_padxfszStandardOptionsTests.test_padxc
Cs8|j�}|j|ddddddd|j�dS)	Nrrg������@gffffff@rMr�r'r�)r�rSra)rr-rrr�	test_padykszStandardOptionsTests.test_padycCs |j�}|j|d�dS)Nr�)r�rT)rr-rrr�test_reliefpsz StandardOptionsTests.test_reliefcCs&|j�}|j|ddd�dS)Nr�i�i���)r�r;)rr-rrr�test_repeatdelaytsz%StandardOptionsTests.test_repeatdelaycCs&|j�}|j|ddd�dS)Nr�i�i���)r�r;)rr-rrr�test_repeatintervalxsz(StandardOptionsTests.test_repeatintervalcCs |j�}|j|d�dS)Nr�)r�rG)rr-rrr�test_selectbackground|sz*StandardOptionsTests.test_selectbackgroundcCs,|j�}|j|ddddd�dS)Nr�g�������?g������@rMr:r�)r�rS)rr-rrr�test_selectborderwidth�sz+StandardOptionsTests.test_selectborderwidthcCs |j�}|j|d�dS)Nr�)r�rG)rr-rrr�test_selectforeground�sz*StandardOptionsTests.test_selectforegroundcCs |j�}|j|d�dS)Nr�)r�rE)rr-rrr�test_setgrid�sz!StandardOptionsTests.test_setgridcCs)|j�}|j|dddd�dS)N�stateZactiveZdisabledZnormal)r�rP)rr-rrr�
test_state�szStandardOptionsTests.test_statecCs)|j�}|j|dddd�dS)Nr��0�1r9)r�r8)rr-rrr�test_takefocus�sz#StandardOptionsTests.test_takefocuscCs&|j�}|j|ddd�dS)Nr�r9z
any string)r�r8)rr-rrr�	test_text�szStandardOptionsTests.test_textcCs5|j�}tj|j�}|j|d|�dS)Nr�)r�r*Z	StringVarrrX)rr-rWrrr�test_textvariable�sz&StandardOptionsTests.test_textvariablecCs |j�}|j|d�dS)Nr�)r�rG)rr-rrr�test_troughcolor�sz%StandardOptionsTests.test_troughcolorcCs)|j�}|j|dddd�dS)Nr�rrA�
)r�r;)rr-rrr�test_underline�sz#StandardOptionsTests.test_underlinecCs#|j�}|j|dd�dS)Nr�r�)r�rS)rr-rrr�test_wraplength�sz$StandardOptionsTests.test_wraplengthcCs |j�}|j|d�dS)Nr�)r�rL)rr-rrr�test_xscrollcommand�sz(StandardOptionsTests.test_xscrollcommandcCs |j�}|j|d�dS)Nr�)r�rL)rr-rrr�test_yscrollcommand�sz(StandardOptionsTests.test_yscrollcommandcCs |j�}|j|d�dS)NrK)r�rL)rr-rrr�test_command�sz!StandardOptionsTests.test_commandcCs |j�}|j|d�dS)NZindicatoron)r�rE)rr-rrr�test_indicatoron�sz%StandardOptionsTests.test_indicatoroncCs |j�}|j|d�dS)NZ	offrelief)r�rT)rr-rrr�test_offrelief�sz#StandardOptionsTests.test_offreliefcCs |j�}|j|d�dS)NZ
overrelief)r�rT)rr-rrr�test_overrelief�sz$StandardOptionsTests.test_overreliefcCs |j�}|j|d�dS)NZselectcolor)r�rG)rr-rrr�test_selectcolor�sz%StandardOptionsTests.test_selectcolorcCs |j�}|j|d�dS)NZselectimage)r�rV)rr-rrr�test_selectimage�sz%StandardOptionsTests.test_selectimager	r
cCs |j�}|j|d�dS)NZ
tristateimage)r�rV)rr-rrr�test_tristateimage�sz'StandardOptionsTests.test_tristateimagecCs#|j�}|j|dd�dS)NZ
tristatevalueZ
unknowable)r�r0)rr-rrr�test_tristatevalue�sz'StandardOptionsTests.test_tristatevaluecCs5|j�}tj|j�}|j|d|�dS)NZvariable)r�r*Z	DoubleVarrrX)rr-rWrrr�
test_variable�sz"StandardOptionsTests.test_variableN)*zactivebackgroundzactiveborderwidthzactiveforegroundzanchorz
backgroundzbitmapzborderwidthzcompoundzcursorzdisabledforegroundzexportselectionzfontz
foregroundzhighlightbackgroundzhighlightcolorzhighlightthicknesszimagezinsertbackgroundzinsertborderwidthz
insertofftimezinsertontimezinsertwidthzjumpzjustifyzorientzpadxzpadyzreliefzrepeatdelayzrepeatintervalzselectbackgroundzselectborderwidthzselectforegroundzsetgridz	takefocusztextztextvariableztroughcolorz	underlinez
wraplengthzxscrollcommandzyscrollcommand)=r\r]r^ZSTANDARD_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�rrrrre�s�
	rec@s(eZdZdd�Zdd�ZdS)�IntegerSizeTestscCs)|j�}|j|dddd�dS)N�heightr�ri����)r�r;)rr-rrr�test_height�szIntegerSizeTests.test_heightcCs)|j�}|j|dddd�dS)N�widthi�rin���)r�r;)rr-rrr�
test_width�szIntegerSizeTests.test_widthN)r\r]r^r�r�rrrrr��sr�c@s(eZdZdd�Zdd�ZdS)�PixelSizeTestsc	Cs2|j�}|j|ddddddd�dS)Nr�r�g�����LY@gfffff�Y@rZ3ci����)r�rS)rr-rrrr��szPixelSizeTests.test_heightc	Cs2|j�}|j|ddddddd�dS)Nr�i�gfffff6y@g�����Iy@rZ5iin���)r�rS)rr-rrrr��szPixelSizeTests.test_widthN)r\r]r^r�r�rrrrr��sr�cs�fdd�}|S)Ncs�x��jD]�}d|}t�|�s
xk�D]2}t||�r0t�|t||��Pq0q0W|�fdd�}||_t�||�q
q
W�S)NZtest_cs1|j�}||td|�jf��dS)NzOption "%s" is not tested in %s)r��AssertionErrorr\)r�optionr-)�clsrrr��sz5add_standard_options.<locals>.decorator.<locals>.test)r��hasattr�setattr�getattrr\)r�r�Z
methodnameZsource_classr�)�source_classes)r�r�	decorator�s

		z'add_standard_options.<locals>.decoratorr)r�r�r)r�r�add_standard_options�sr�cCs8tjjr4tj�}td|jdd��ndS)Nzpatchlevel =�infoZ
patchlevel)r�r��verboser*ZTcl�printr)Ztclrrr�setUpModulesr�)r�r�r*Ztkinter.ttkrZtkinter.test.supportrrrrrrZtest.supportr�Znoconvr rRr`rYrcr)r
rer�r�r�r�rrrr�<module>s&.	"		��