a zeO@sddlZddlZddlmZmZmZmZmZmZddl Z dZ edkrJe Z e ZedddkrdeZeZGdddeZGdd d ZGd d d ZGd d d ZddZddZdS)N)AbstractTkTest tcl_version requires_tclget_tk_patchlevel pixels_conv tcl_obj_eqF) c@seZdZeeZdZdZeddZ ddZ de j fddZ eddd d d Zd0d d ddZddZddZedddZddZddddZddZddZdd d!d"Zdd d#d$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/ZdS)1AbstractWidgetTestNFcCs:z|jWSty4t|jdd|_|jYS0dS)Ntkscaling)Z_scalingAttributeErrorfloatrootcall)selfrM/opt/bitninja-python-dojo/embedded/lib/python3.9/tkinter/test/widget_tests.pyrs  zAbstractWidgetTest.scalingcCs<|js|jrtdkr|St|tr4dt|j|St|S)Nr ) _stringify wantobjectsr isinstancetuplejoinmap_strstr)rvaluerrrr$s  zAbstractWidgetTest._strcCs |||rdS||||dSN) assertEqual)ractualexpectedmsgeqrrr assertEqual2+s zAbstractWidgetTest.assertEqual2)r%convr'cCs|||<|tur|}|r ||}|js,|jsJt|trBt|}nt|}|durVt}|j ||||d|j | |||d| |}| t |d|j |d||ddS)N)r'r ) _sentinelrrrrtkinterZ_joinr rr(Zcget configurer#len)rwidgetnamer!r%r)r'trrr checkParam0s     zAbstractWidgetTest.checkParamT) keep_origcCs||}|dur||}|tj}|||<Wdn1sD0Y|durh|t|j||r~||||n|||<|tj}|||iWdn1s0Y|dur|t|j||r||||n|||<dSr")formatZ assertRaisesr,ZTclErrorr#r exceptionr-)rr/r0r!errmsgr3ZorigcmrrrcheckInvalidParamDs" &,z$AbstractWidgetTest.checkInvalidParamcOs$|D]}|j|||fi|qdSr")r2)rr/r0valueskwargsr!rrr checkParamsZszAbstractWidgetTest.checkParamscOsT|j||g|Ri||j||ddd|j||ddd|j||ddddS)Nzexpected integer but got ""r610pzexpected integer but got "10p"g @zexpected integer but got "3.2"r;r8)rr/r0r9r:rrrcheckIntegerParam^s   z$AbstractWidgetTest.checkIntegerParamr)cOsL|D]}|j|||fd|i|q|j||ddd|j||ddddS)Nr)r<z)expected floating-point number but got ""r=spamz-expected floating-point number but got "spam"r2r8)rr/r0r)r9r:r!rrrcheckFloatParamgs  z"AbstractWidgetTest.checkFloatParamcCs`dD]}|j|||ddqdD]}|j|||ddq |j||ddd|j||d d ddS) N)FrZfalsenoZoffr)r%)TtrueZyesZonrFr<z!expected boolean value but got ""r=rBz%expected boolean value but got "spam"rC)rr/r0r!rrrcheckBooleanParamos  z$AbstractWidgetTest.checkBooleanParam) allow_emptyc Ks>|j||ddddddddd d f i||j||d d d dS)Nz#ff0000z#00ff00z#0000ffz#123456ZredZgreenZblueZwhiteZblackZgreyrBzunknown color name "spam"r=r?)rr/r0rIr:rrrcheckColorParamys  z"AbstractWidgetTest.checkColorParamcKsH|j||ddddfi|tdkr2|||d|j||ddd dS) NZarrowZwatchZcrossr<)rr nonerBzbad cursor spec "spam"r=)r;rr2r8)rr/r0r:rrrcheckCursorParams  z#AbstractWidgetTest.checkCursorParamcCs0dd}|||<||||||ddS)NcWsdSr"r)argsrrrcommandsz5AbstractWidgetTest.checkCommandParam..commandr<)Z assertTruer;)rr/r0rNrrrcheckCommandParamsz$AbstractWidgetTest.checkCommandParamr=cOs|j||g|Ri||durrd|d|ddt|dkrFdnd|df}|j||dd|dd |}|j||d |ddS) Nz %s "{}": must be %s%s or %sz, ,r<Z ambiguousr=ZbadrB)r;rr.r8)rr/r0r6r9r:Zerrmsg2rrrcheckEnumParams z!AbstractWidgetTest.checkEnumParam)r)r3c Os|dur|j}|D]P}t}|} t|trF| rF| turFt||j}t} |j|||f|| d|q|j||dd|d|j||dd|ddS)Nr%r)Z6xzbad screen distance "6x")r6r3rBzbad screen distance "spam") _conv_pixelsr+rr rrroundr2r8) rr/r0r)r3r9r:r!r%Zconv1rrrcheckPixelsParams(    z#AbstractWidgetTest.checkPixelsParamc Cs>|||ddddddd}tdkr(d}|j||d |d dS) NZflatZgrooveZraisedZridgeZsolidZsunkenzHbad relief "spam": must be flat, groove, raised, ridge, solid, or sunkenrrBr=)r;rr8)rr/r0r6rrrcheckReliefParams  z#AbstractWidgetTest.checkReliefParamcCs@tj|jdd}|j|||td|j||dddd||<dS)NZimage1)Zmasterr0rArBzimage "spam" doesn't existr=r<)r,Z PhotoImagerr2r r8)rr/r0imagerrrcheckImageParams  z"AbstractWidgetTest.checkImageParamcCs|j|||tddS)NrA)r2r )rr/r0varrrrcheckVariableParamsz%AbstractWidgetTest.checkVariableParamcCs^||||tt|dkr2|d|f|D]"}t|ts6|d|fqZq6dS)Nr*zInvalid bounding box: %r)ZassertIsNotNoneZassertIsInstancerr.Zfailrint)rZbboxitemrrrassertIsBoundingBoxs    z&AbstractWidgetTest.assertIsBoundingBoxcCs|}|}|t|t||D] }||q,tjjrdddddd}t|}t|j }t||D]8}||vr|||vr|||vspt d|j j |fqpdS)N borderwidth background foregroundZinvalidcommandZvalidatecommand)bdbgfgZinvcmdZvcmdz%s.OPTIONS doesn't contain "%s") createkeysr#sortedr-testsupportverbosesetOPTIONSprint __class____name__)rr/rgkaliasesr%rrr test_keyss.     zAbstractWidgetTest.test_keys)N) rp __module__ __qualname__ staticmethod pixels_roundrU_conv_pad_pixelsrpropertyrrobject__eq__r(r+r2r8r;r@rrDrHrJrLrOrSrWrXrZr\r_rsrrrrr s8        r c@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dd?Z"d@dAZ#dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dNdOZ*dPdQZ+dRdSZ,dTdUZ-dVdWZ.dXdYZ/dZd[Z0d\d]Z1d^d_Z2d`daZ3dbdcZ4e5dddedfdgZ6e5dddedhdiZ7djdkZ8dlS)mStandardOptionsTests)*activebackgroundactiveborderwidthactiveforegroundanchorrabitmapr`compoundcursordisabledforegroundexportselectionfontrbhighlightbackgroundhighlightcolorhighlightthicknessrYinsertbackgroundinsertborderwidth insertofftime insertontime insertwidthjumpjustifyorientpadxpadyrelief repeatdelayrepeatintervalselectbackgroundselectborderwidthselectforegroundsetgrid takefocustext textvariable troughcolor underline wraplengthxscrollcommandyscrollcommandcCs|}||ddS)Nr}rfrJrr/rrrtest_configure_activebackgroundsz4StandardOptionsTests.test_configure_activebackgroundc Cs$|}||ddddddddS)Nr~r?g333333@rr>rfrWrrrr test_configure_activeborderwidths z5StandardOptionsTests.test_configure_activeborderwidthcCs|}||ddS)Nrrrrrrtest_configure_activeforegroundsz4StandardOptionsTests.test_configure_activeforegroundc Cs*|}||ddddddddd d dS) NrnneeZsesswwZnwcenterrfrSrrrrtest_configure_anchorsz*StandardOptionsTests.test_configure_anchorcCs.|}||dd|jvr*||ddS)NrardrfrJrmrrrrtest_configure_backgrounds  z.StandardOptionsTests.test_configure_backgroundcCs~|}||dd||ddtjjddd}||dd|d|jjd d vrhd |jvsz|j |dd d ddS)NrZ questheadZgray50z python.xbmZ imghdrdata)Zsubdir@Zaquar ZwindowingsystemZAppKitrBzbitmap "spam" not definedr=) rfr2rirjZfindfilerr rZ winfo_serverr8)rr/filenamerrrtest_configure_bitmap s  z*StandardOptionsTests.test_configure_bitmapc CsF|}||dddddddd|jvrB||ddddddddS) Nr`rr@rrr>rc)rfrWrmrrrrtest_configure_borderwidths   z/StandardOptionsTests.test_configure_borderwidthc Cs$|}||ddddddddS)NrZbottomrleftrKrighttoprrrrrtest_configure_compound!s z,StandardOptionsTests.test_configure_compoundcCs|}||ddS)Nr)rfrLrrrrtest_configure_cursor&sz*StandardOptionsTests.test_configure_cursorcCs|}||ddS)Nrrrrrr!test_configure_disabledforeground*sz6StandardOptionsTests.test_configure_disabledforegroundcCs|}||ddS)NrrfrHrrrrtest_configure_exportselection.sz3StandardOptionsTests.test_configure_exportselectioncCs,|}||dd|j|dddddS)Nrz3-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*r<zfont "" doesn't existr=)rfr2r8rrrrtest_configure_font2s z(StandardOptionsTests.test_configure_fontcCs.|}||dd|jvr*||ddS)Nrbrerrrrrtest_configure_foreground9s  z.StandardOptionsTests.test_configure_foregroundcCs|}||ddS)Nrrrrrr"test_configure_highlightbackground?sz7StandardOptionsTests.test_configure_highlightbackgroundcCs|}||ddS)Nrrrrrrtest_configure_highlightcolorCsz2StandardOptionsTests.test_configure_highlightcolorc Cs8|}||dddddd|j|ddd|jddS) Nrrrrrr>rrT)rfrWr2rUrrrr!test_configure_highlightthicknessGs  z6StandardOptionsTests.test_configure_highlightthicknesscCs|}||ddS)NrYrfrZrrrrtest_configure_imageNsz)StandardOptionsTests.test_configure_imagecCs|}||ddS)Nrrrrrrtest_configure_insertbackgroundRsz4StandardOptionsTests.test_configure_insertbackgroundc Cs$|}||ddddddddS)Nrrrrrrr>rrrrr test_configure_insertborderwidthVs z5StandardOptionsTests.test_configure_insertborderwidthcCs|}||dddS)Nrdrfr@rrrrtest_configure_insertofftime[sz1StandardOptionsTests.test_configure_insertofftimecCs|}||dddS)Nrrrrrrrtest_configure_insertontime_sz0StandardOptionsTests.test_configure_insertontimecCs |}||ddddddS)Nrrrrr>rrrrrtest_configure_insertwidthcsz/StandardOptionsTests.test_configure_insertwidthcCs|}||ddS)Nrrrrrrtest_configure_jumpgsz(StandardOptionsTests.test_configure_jumpcCs4|}|j|dddddd|j|dddddS) Nrrrrz6bad justification "{}": must be left, right, or centerr=r<z:ambiguous justification "": must be left, right, or center)rfrSr8rrrrtest_configure_justifyks z+StandardOptionsTests.test_configure_justifycCs2|}|t|d|j||ddddS)NrZ horizontalZvertical)rfr#r Zdefault_orientrSrrrrtest_configure_orienttsz*StandardOptionsTests.test_configure_orientc Cs(|}|j|dddddd|jddS)Nrr 皙@ffffff@r12mrArfrWrxrrrrtest_configure_padxysz(StandardOptionsTests.test_configure_padxc Cs(|}|j|dddddd|jddS)Nrr rrrrrArrrrrtest_configure_pady~sz(StandardOptionsTests.test_configure_padycCs|}||ddS)NrrfrXrrrrtest_configure_reliefsz*StandardOptionsTests.test_configure_reliefcCs|}||ddddS)Nr rrrrrtest_configure_repeatdelaysz/StandardOptionsTests.test_configure_repeatdelaycCs|}||ddddS)Nrrrrrrrrtest_configure_repeatintervalsz2StandardOptionsTests.test_configure_repeatintervalcCs|}||ddS)Nrrrrrrtest_configure_selectbackgroundsz4StandardOptionsTests.test_configure_selectbackgroundcCs |}||ddddddS)Nrrrrr>rrrrr test_configure_selectborderwidthsz5StandardOptionsTests.test_configure_selectborderwidthcCs|}||ddS)Nrrrrrrtest_configure_selectforegroundsz4StandardOptionsTests.test_configure_selectforegroundcCs|}||ddS)Nrrrrrrtest_configure_setgridsz+StandardOptionsTests.test_configure_setgridcCs|}||dddddS)NstateZactivedisabledZnormalrrrrrtest_configure_statesz)StandardOptionsTests.test_configure_statecCs|}||dddddS)Nr01r<rfr;rrrrtest_configure_takefocussz-StandardOptionsTests.test_configure_takefocuscCs|}||ddddS)Nrr<z any stringrrrrrtest_configure_textsz(StandardOptionsTests.test_configure_textcCs&|}t|j}||d|dS)Nr)rfr,Z StringVarrr\rr/r[rrrtest_configure_textvariables z0StandardOptionsTests.test_configure_textvariablecCs|}||ddS)Nrrrrrrtest_configure_troughcolorsz/StandardOptionsTests.test_configure_troughcolorcCs|}||dddddS)NrrrF rrrrrtest_configure_underlinesz-StandardOptionsTests.test_configure_underlinecCs|}||dddS)Nrrrrrrrtest_configure_wraplengthsz.StandardOptionsTests.test_configure_wraplengthcCs|}||ddS)NrrfrOrrrrtest_configure_xscrollcommandsz2StandardOptionsTests.test_configure_xscrollcommandcCs|}||ddS)Nrrrrrrtest_configure_yscrollcommandsz2StandardOptionsTests.test_configure_yscrollcommandcCs|}||ddS)NrNrrrrrtest_configure_commandsz+StandardOptionsTests.test_configure_commandcCs|}||ddS)NZ indicatoronrrrrrtest_configure_indicatoronsz/StandardOptionsTests.test_configure_indicatoroncCs|}||ddS)NZ offreliefrrrrrtest_configure_offreliefsz-StandardOptionsTests.test_configure_offreliefcCs|}||ddS)NZ overreliefrrrrrtest_configure_overreliefsz.StandardOptionsTests.test_configure_overreliefcCs|}||ddS)NZ selectcolorrrrrrtest_configure_selectcolorsz/StandardOptionsTests.test_configure_selectcolorcCs|}||ddS)NZ selectimagerrrrrtest_configure_selectimagesz/StandardOptionsTests.test_configure_selectimagerr cCs|}||ddS)NZ tristateimagerrrrrtest_configure_tristateimagesz1StandardOptionsTests.test_configure_tristateimagecCs|}||dddS)NZ tristatevalueZ unknowable)rfr2rrrrtest_configure_tristatevaluesz1StandardOptionsTests.test_configure_tristatevaluecCs&|}t|j}||d|dS)Nvariable)rfr,Z DoubleVarrr\rrrrtest_configure_variables z,StandardOptionsTests.test_configure_variableN)9rprtruZSTANDARD_OPTIONSrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr|sn    r|c@seZdZddZddZdS)IntegerSizeTestscCs|}||dddddS)Nheightrrrrrrrtest_configure_heightsz&IntegerSizeTests.test_configure_heightcCs|}||dddddS)Nwidthnrrrrrrtest_configure_widthsz%IntegerSizeTests.test_configure_widthNrprtrurrrrrrrsrc@seZdZddZddZdS)PixelSizeTestsc Cs$|}||ddddddddS)NrrgLY@gfffffY@rrZ3crrrrrrsz$PixelSizeTests.test_configure_heightc Cs$|}||ddddddddS)Nrrgfffff6y@gIy@rrZ5irrrrrrsz#PixelSizeTests.test_configure_widthNrrrrrrsrcsfdd}|S)NcsnjD]b}d|}t|sD]$}t||r t|t||qq |ffdd }||_t||qS)NZtest_configure_cs&|}||td|jfdS)NzOption "%s" is not tested in %s)rfAssertionErrorrp)roptionr/clsrrris z5add_standard_options..decorator..test)rmhasattrsetattrgetattrrp)r r Z methodnameZ source_classrisource_classesr r decorators   z'add_standard_options..decoratorr)rrrrradd_standard_optionss rcCs&tjjr"t}td|dddS)Nz patchlevel =infoZ patchlevel)rirjrkr,ZTclrnr)Ztclrrr setUpModulesr)Zunittestr,Ztkinter.test.supportrrrrrrZ test.supportriZnoconvr rVrwr]rzr+r r|rrrrrrrrs&  P