asda?‰PNG  IHDR ? f ??C1 sRGB ??é gAMA ±? üa pHYs ? ??o¨d GIDATx^íüL”÷e÷Y?a?("Bh?_ò???¢§?q5k?*:t0A-o??¥]VkJ¢M??f?±8\k2íll£1]q?ù???T PK™e[jPPtest_parenmatch.pycnu[ {fc@sdZddlZddlmZddlmZmZddlmZdddYZ ddd YZ d ej fd YZ e d krejd dndS(sTest idlelib.ParenMatch.iN(trequires(tTktText(t ParenMatchtMockcBs,eZdZdZdZdZRS(cOs t|_dS(N(tFalsetcalled(tselftargstkwargs((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyt__init__ scOs t|_dS(N(tTrueR(RRR ((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyt__call__scOs t|_dS(N(RR(RRR ((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyt reset_mockscOsdS(N((RRR ((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pytafters(t__name__t __module__R R R R(((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyR s   t DummyEditwincBseZdZRS(cCs(||_d|_d|_t|_dS(Ni(ttextt indentwidthttabwidthR tcontext_use_ps1(RR((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyR s   (RRR (((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyRstParenMatchTestcBsSeZedZedZdZdZdZdZdZ RS(cCsMtdt|_t|j|_t|j|_t|j_dS(Ntgui( RRtrootRRRteditwinRt text_frame(tcls((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyt setUpClass!s   cCs#|`|`|jj|`dS(N(RRRtdestroy(R((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyt tearDownClass)s  cCs|jjdddS(Ns1.0tend(Rtdelete(R((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyttearDown/scCs|j}t|j}|jd|jdd|jd|jd|j|j|j ddd |jdd |j |j d|j|j |j ddd|j d|j|j dddd S(s: Test ParenMatch with 'expression' style. t expressiontinsertsdef foobar(a, btevents<>tparenRs1.10s1.15t)s1.16N(s1.10s1.15((s1.10s1.16(RRRt set_styleR#tflash_paren_eventtassertInt event_infotassertTupleEqualt tag_prevranget restore_eventt assertNotInt assertEqualtparen_closed_event(RRtpm((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyttest_paren_expression2s     cCs|j}t|j}|jd|jdd|jd|jd|j|j|j ddd |jdd |j |j d|j|j |j ddd d S(s7 Test ParenMatch with 'default' style. tdefaultR#sdef foobar(a, bR$s<>R%Rs1.10s1.11R&N(s1.10s1.11(( RRRR'R#R(R)R*R+R,R-R.R/(RRR1((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyttest_paren_defaultIs    cCs|j}t|j}|jdd|j|jd|jdd|j|jd|j|jd|jdd|j|jddS(s Test corner cases in flash_paren_event and paren_closed_event. These cases force conditional expression and alternate paths. R#s# this is a commen)R$s defs a, *arg)N(RRRR#t assertIsNoneR0R((RRR1((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyttest_paren_corner[s cCslt|j}t|_|jd|j|jj|jj|jd|j|jjdS(Nii( RRRR-thandle_restore_timert assertTrueRR t assertFalse(RR1((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyttest_handle_restore_timerns    ( RRt classmethodRRR!R2R4R6R:(((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyRs    t__main__t verbosityi(((t__doc__tunittestttest.test_supportRtTkinterRRtidlelib.ParenMatchRRRtTestCaseRRtmain(((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyts  Y PK™e[,test_rstrip.pyonu[ {fc@smddlZddljZddlmZdejfdYZedkriej ddde ndS( iN(tEditort rstripTestcBseZdZdZRS(cCst}|j}tj|j}||j|jddd|jdd||j|jddd|jdd||j|jddddS(Ns1.0tinsertts s s (RttexttrstRstripExtensiont do_rstript assertEqualtgetR(tselfteditorRR((s5/usr/lib64/python2.7/idlelib/idle_test/test_rstrip.pyttest_rstrip_lines  cCsgt}|j}tj|j}d}d}|jd|||j|jdd|dS(NsLine with an ending tab Line ending in 5 spaces Linewithnospaces indented line indented line with trailing space syLine with an ending tab Line ending in 5 spaces Linewithnospaces indented line indented line with trailing space s1.0R(RRRRRRRR (R R RRtoriginaltstripped((s5/usr/lib64/python2.7/idlelib/idle_test/test_rstrip.pyttest_rstrip_multiples  (t__name__t __module__R R(((s5/usr/lib64/python2.7/idlelib/idle_test/test_rstrip.pyRs t__main__t verbosityitexit( tunittesttidlelib.RstripExtensionRRtidlelib.idle_test.mock_idleRtTestCaseRRtmaintFalse(((s5/usr/lib64/python2.7/idlelib/idle_test/test_rstrip.pyts + PK™e[>8== mock_idle.pynu['''Mock classes that imitate idlelib modules or classes. Attributes and methods will be added as needed for tests. ''' from idlelib.idle_test.mock_tk import Text class Func(object): '''Mock function captures args and returns result set by test. Attributes: self.called - records call even if no args, kwds passed. self.result - set by init, returned by call. self.args - captures positional arguments. self.kwds - captures keyword arguments. Most common use will probably be to mock methods. Mock_tk.Var and Mbox_func are special variants of this. ''' def __init__(self, result=None): self.called = False self.result = result self.args = None self.kwds = None def __call__(self, *args, **kwds): self.called = True self.args = args self.kwds = kwds if isinstance(self.result, BaseException): raise self.result else: return self.result class Editor(object): '''Minimally imitate EditorWindow.EditorWindow class. ''' def __init__(self, flist=None, filename=None, key=None, root=None): self.text = Text() self.undo = UndoDelegator() def get_selection_indices(self): first = self.text.index('1.0') last = self.text.index('end') return first, last class UndoDelegator(object): '''Minimally imitate UndoDelegator,UndoDelegator class. ''' # A real undo block is only needed for user interaction. def undo_block_start(*args): pass def undo_block_stop(*args): pass PK™e[,test_rstrip.pycnu[ {fc@smddlZddljZddlmZdejfdYZedkriej ddde ndS( iN(tEditort rstripTestcBseZdZdZRS(cCst}|j}tj|j}||j|jddd|jdd||j|jddd|jdd||j|jddddS(Ns1.0tinsertts s s (RttexttrstRstripExtensiont do_rstript assertEqualtgetR(tselfteditorRR((s5/usr/lib64/python2.7/idlelib/idle_test/test_rstrip.pyttest_rstrip_lines  cCsgt}|j}tj|j}d}d}|jd|||j|jdd|dS(NsLine with an ending tab Line ending in 5 spaces Linewithnospaces indented line indented line with trailing space syLine with an ending tab Line ending in 5 spaces Linewithnospaces indented line indented line with trailing space s1.0R(RRRRRRRR (R R RRtoriginaltstripped((s5/usr/lib64/python2.7/idlelib/idle_test/test_rstrip.pyttest_rstrip_multiples  (t__name__t __module__R R(((s5/usr/lib64/python2.7/idlelib/idle_test/test_rstrip.pyRs t__main__t verbosityitexit( tunittesttidlelib.RstripExtensionRRtidlelib.idle_test.mock_idleRtTestCaseRRtmaintFalse(((s5/usr/lib64/python2.7/idlelib/idle_test/test_rstrip.pyts + PK™e[I+ test_warning.pycnu[ {fc@sdZddlZddlmZddlZejZdejkZddlm Z ddlm Z dZ e dZ d ejfd YZd ejfd YZed krejdddendS(s6Test warnings replacement in PyShell.py and run.py. This file could be expanded to include traceback overrides (in same two modules). If so, change name. Revise if output destination changes (http://bugs.python.org/issue18318). Make sure warnings module is left unaltered (http://bugs.python.org/issue18081). iN(tcaptured_stderrtidle(trun(tPyShellsf Warning (from warnings module): File "test_warning.py", line 99 Line of code UserWarning: Test s>>> t RunWarnTestcBs,eZejeddZdZRS(s#Does not work when run within Idle.cCsZ|jtjttjt|jtjtjtjt|jtjtdS(N(tassertIstwarningst showwarningRtcapture_warningstTruetidle_showwarning_subproctFalse(tself((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyttest_showwarnings"s   c CsTtE}tjdtdd|d|jtj|jjWdQXdS(NtTeststest_warning.pyics Line of code(RRR t UserWarningt assertEqualtidlemsgt splitlinestgetvalue(R tf((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyt test_run_show*s (t__name__t __module__tunittesttskipIftrunning_in_idleR R(((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyR st ShellWarnTestcBs5eZejeddZdZdZRS(s#Does not work when run within Idle.cCsZ|jtjttjt|jtjtjtjt|jtjtdS(N(RRRtshellRR tidle_showwarningR (R ((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyR 3s   cCs/tjdtddd}|jt|dS(NRstest_warning.pyics Line of code(Rtidle_formatwarningRRR(R ts((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyttest_idle_formatter;sc CsTtE}tjdtdd|d|jtj|jjWdQXdS(NRstest_warning.pyics Line of code(RRRRRtshellmsgRR(R R((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyttest_shell_showAs (RRRRRR R R"(((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyR1s t__main__t verbosityitexit(t__doc__Rttest.test_supportRRRRRtidlelibRRRRR!tTestCaseRRtmainR (((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyts      PK™e[мtest_widgetredir.pycnu[ {fc@sdZddlmZddlZddlmZddlmZmZm Z ddl m Z dej fdYZ d ej fd YZed krejd d ndS(s5Unittest for idlelib.WidgetRedirector 100% coverage i(trequiresN(tFunc(tTktTexttTclError(tWidgetRedirectort InitCloseTestcBs8eZedZedZdZdZRS(cCs9tdt|_|jjt|j|_dS(Ntgui(RRtroottwithdrawRttext(tcls((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt setUpClasss   cCs|`|jj|`dS(N(R Rtdestroy(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt tearDownClasss cCsbt|j}|j|j|j|j|j|jj|jtt|j|jdS(N(RR t assertEqualtwidgetttkt assertRaisesRtclose(tselftredir((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt test_inits cCsYt|j}|jdt|j|j|ji|jt|jddS(NtinsertR( RR tregisterRRRt _operationst assertFalsethasattr(RR((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt test_close"s  (t__name__t __module__t classmethodR RRR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyR s tWidgetRedirectorTestcBseZedZedZdZdZdZdZdZ dZ dZ d Z d Z d Zd ZRS( cCs9tdt|_|jjt|j|_dS(NR(RRRR RR (R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyR ,s   cCs|`|jj|`dS(N(R RR (R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyR3s cCsPt|j|_t|_|jjd|j|_|jjdddS(NRtasdf(RR RRtfuncRt orig_insertR(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pytsetUp9s cCs$|jjdd|jjdS(Ns1.0tend(R tdeleteRR(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttearDown?scCs6|jdt|j|jdt|jdS(Nt RedirectortOriginal(tassertIntreprRR#(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt test_reprCscCs~|j|jjddd|j|jjd|jd|jj|jd|jj|j|jj |jdS(Ns1.0R%s RR!(RR!( RR tgetR"targsR*RRt__dict__R(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt test_registerGs cCsh|j|jjd|j|jj|jjj|jdd|j|jjddddS(NRR!s1.0R%sasdf (RR#t operationttk_callR RtcallR-(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_original_commandNscCsh|j|jjd|j|jjd|j|jd|jj|jd|jjdS(Nsinvalid operation nameR( t assertIsNoneRt unregisterRR"t assertNotInRR R/(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_unregisterTscCs,|j`|j|jjd|jdS(NR(R RRRR6R"(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_unregister_no_attributeZs cCsG|jjt|j|jjdt|j|jjddS(NRi( R"t__init__tTruet assertTrueRtdispatchtFalseRR.(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_dispatch_intercept^scCsU|jdd|j|jjdddd|j|jjddddS(NRR!R&s1.0R%ts (R#RRR=R R-(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_dispatch_bypasscs"cCsR|jjt|j|jjdtd|j|jjdddS(NRR@tinvalid(R"R:RRRR=R>(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_dispatch_erroriscCs|jj|jjdd|j|jjd|j|jjddd|jjt |j|jj|jjddddS( NRthellos1.0R%s tbooR@(RD( RR3R t_wRR"R.R-R:R(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_command_dispatchns (RRRR RR$R'R,R0R4R8R9R?RARCRG(((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyR *s          t__main__t verbosityi(t__doc__ttest.test_supportRtunittesttidlelib.idle_test.mock_idleRtTkinterRRRtidlelib.WidgetRedirectorRtTestCaseRR Rtmain(((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyts Q PK™e[j? ? mock_idle.pycnu[ {fc@s\dZddlmZdefdYZdefdYZdefdYZd S( sqMock classes that imitate idlelib modules or classes. Attributes and methods will be added as needed for tests. i(tTexttFunccBs#eZdZddZdZRS(sMock function captures args and returns result set by test. Attributes: self.called - records call even if no args, kwds passed. self.result - set by init, returned by call. self.args - captures positional arguments. self.kwds - captures keyword arguments. Most common use will probably be to mock methods. Mock_tk.Var and Mbox_func are special variants of this. cCs(t|_||_d|_d|_dS(N(tFalsetcalledtresulttNonetargstkwds(tselfR((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyt__init__s   cOsDt|_||_||_t|jtr9|jn|jSdS(N(tTrueRRRt isinstanceRt BaseException(RRR((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyt__call__s     N(t__name__t __module__t__doc__RR R (((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyRs  tEditorcBs,eZdZdddddZdZRS(s7Minimally imitate EditorWindow.EditorWindow class. cCst|_t|_dS(N(Rttextt UndoDelegatortundo(Rtflisttfilenametkeytroot((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyR &s cCs.|jjd}|jjd}||fS(Ns1.0tend(Rtindex(Rtfirsttlast((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pytget_selection_indices*sN(RRRRR R(((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyR#sRcBs eZdZdZdZRS(s9Minimally imitate UndoDelegator,UndoDelegator class. cGsdS(N((R((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pytundo_block_start4scGsdS(N((R((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pytundo_block_stop6s(RRRRR(((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyR0s N(Rtidlelib.idle_test.mock_tkRtobjectRRR(((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyts PK™e[H''test_delegator.pycnu[ {fc@s^ddlZddlmZdejfdYZedkrZejddddndS( iN(t Delegatort DelegatorTestcBseZdZRS(cCs0tt}|j|jt|j|jt|jt|j d|j }|j|tj |j|j dtj |j|jdh|j |j|jddh|` |j d|j |jd|j|jt|j|jt|j d|j |j|jtdS(Ntxyzt bit_lengtht numerator(RtinttassertIstdelegatet assertEqualt_Delegator__cachetsett assertRaisestAttributeErrort __getattr__Rt__dict__Rt assertNotIntassertInt setdelegatetfloat(tselftmydeltbl((s8/usr/lib64/python2.7/idlelib/idle_test/test_delegator.pyt test_mydels"   (t__name__t __module__R(((s8/usr/lib64/python2.7/idlelib/idle_test/test_delegator.pyRst__main__t verbosityitexit(tunittesttidlelib.DelegatorRtTestCaseRRtmain(((s8/usr/lib64/python2.7/idlelib/idle_test/test_delegator.pyts  PK™e[7غi1i1test_searchengine.pycnu[ {fc@sydZddlZddlZddlmZmZmZddlZddlm Z ddl m Z m Z ddl mZdZdZd dd YZd ejfd YZd ejfdYZdejfdYZdejfdYZdejfdYZdejfdYZdejfdYZedkruejddddndS(s9Test functions and SearchEngine class in SearchEngine.py.iN(t BooleanVart StringVartTclError(t SearchEngine(tVartMbox(tTextcCstt_tt_tt_dS(N(RtseRRRt tkMessageBox(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt setUpModules  cCstt_tt_tt_dS(N(RRRR(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttearDownModules  tMockcBseZdZRS(cOsdS(N((tselftargstkwargs((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt__init__t(t__name__t __module__R(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR stGetTestcBseZdZRS(cCs~tj}tt_z[t}tj|}|j|tj|j|j||jtj||Wd|t_XdS(N(RRR tgettassertIsInstancetassertIst _searchengine(R t saved_Enginetroottengine((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_get#s   (RRR(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR!stGetLineColTestcBseZdZRS(cCsb|jtjdd|jtjdd |jttjd|jttjddS( Ns1.0iis1.11i s 1.0 lineendtend(ii(ii (t assertEqualRt get_line_colt assertRaisest ValueError(R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_get_line_col1s(RRR"(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR/stGetSelectionTestcBseZdZRS(cCsst}|jddd}||_|jtj|dd}||_|jtj|ddS( Ns1.0s Hello World!cSs*|dkrdS|dkr dStdS(Ns sel.firsts1.0ssel.lasts1.12(R(ts((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pytselKs   s1.12cSs|dkrdStdS(Ntinserts1.5(R(R$((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pytmarkSs s1.5(s1.0s1.12(s1.5s1.5(tmockTextR&tindexRRt get_selection(R ttextR%R'((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_get_selectionEs     (RRR,(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR#8s tReverseSearchTestcBseZdZRS(cCs|j}d}tjd}|tj||t|jd |tj||djd |tj||djd |tj||djd |tj||dddS( NsHere is an 'is' test text.tisi ii iii(i i(i i(ii(ii(RtretcompileRtsearch_reversetlentspantNone(R tEqualtlinetprog((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_search_reverse]s ("""(RRR8(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR-[stSearchEngineTestcBs>eZdZdZdZdZdZdZRS(cCstjdd|_dS(NR(RRR4R(R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pytsetUpkscCsW|j}|j}||jd|jd||jd||jt|jjd||jt||j t|j jd||j t||j t|j jd||j t||j t|jjd||j t||jt|jjd||jtdS(NRthelloii(RRtgetpattsetpattisretFalsetrevartsettTruetiscasetcasevartiswordtwordvartiswraptwrapvartisbacktbackvar(R RR5((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt test_is_getps(   cCsc|j}|jd|j|jd|jjd|jd|j|jddS(Ns\sis\\s(Rt setcookedpatRR<R@RA(R R((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_setcookedpats    cCs|j}|j}||jd|jd||jd|jjt||jd|jjt|jd||jd|jjt||jddS(NRR;s \bhello\bs\ss\\s( RRt getcookedpatR=RFRARBR?R@(R RR5((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_getcookedpats    cCs|j}|j}|jd|j}||jtjdtjj|jj d|j}||jtjdjd|jd||jd|jd|j j d||jd|jt j jddS(NtHelloiiRt+s#Error: nothing to repeat Pattern: +(RRR=tgetprogtpatternR/R0t IGNORECASERDRAR4R@Rt showerrortmessage(R RR5ttemppat((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt test_getprogs    "   cCstj}|j}d}d}||jj||d||jdd|d}||j|||jj||dd||jd|d7}||j|dS(Ns[a-zs$unexpected end of regular expressionsRegular expression errorsError: s Pattern: [a-zis Offset: 5(RRURRt report_errorR4ttitleRV(R RUR5tpattmsgtexpected_message((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_report_errors   (RRR:RKRMRORXR^(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR9hs      t SearchTestcBs eZedZdZRS(cCskt|_d}|jjd|tjd|_tjd|_ d|j _ d|j _ dS(Ns&First line Line with target Last line s1.0ttargetcWs d|fS(Ntf((R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pytRcWs d|fS(Ntb((R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyRbR( R(R+R&R/R0R[RRR4Rtsearch_forwardtsearch_backward(tclst test_text((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt setUpClasss c Cs|j}|j}|j}|j}|j}|jjd|||dd}||_||||d||ddt t ff|j jt ||||d||ddt t ff|j jt |j jt ||||d||ddt t ff|j jt d}||_||||d||ddt t ff||||t d||dd t t ff|j jt ||||d||dd t t ff||||t d||ddt t ffdS( NcSs|dkrdStdS(NR&s1.5(R(R$((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR's RaiiRccSs*|dkrdS|dkr dStdS(Ns sel.firsts2.10ssel.lasts2.16(R(R$((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR%s   iii ( RRt search_textR+R[tpatvarRAR4R)RBR?RHRJ(R R5RtsearchR+R[R'R%((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt test_searchs.       ...  .1.(RRt classmethodRhRl(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR_stForwardBackwardTestcBs2eZedZdZdZdZRS(cCstjd|_t|_d|j_d}|jjd|tj d|_ dd f|_ tj d|_ tj d |_ dS( NcSsdS(Ns4.0((R)((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyRbRs&First line Line with target Last line s1.0R`ii itxyzs\w*(i i(RRR4RR(R+R)R&R/R0R[trestfailpattemptypat(RfRg((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyRh s csdfd}|S(Nics@j|||||}|r<|d|djfS|S(Nii(R+R3(R[R6tcoltwraptokRp(tfuncR (s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyRk s((R RvRk((RvR s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt make_searchscCs|j}|j|jj}|j}|||ddt|j|||ddt|j|||ddtd|||ddt|j|||j ddtd|||j ddtdtddf|||j ddt|jdS( Niiiii i Ru(i i ( RRwRRdR[RBRpR?R4RqRr(R R5tforwardR[((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_search_forward&s  +cCs|j}|j|jj}|j}|||ddt|j|||ddt|j|||ddtd|||ddt|j|||j ddtd|||j ddtdtdd f|||j ddtdd fdS( Niiiiii i Ru(i i (ii ( RRwRReR[RBRpR?R4RqRr(R R5tbackwardR[((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_search_backward7s  +(RRRmRhRwRyR{(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyRns  t__main__t verbosityitexit((t__doc__R/tunittesttTkinterRRRRtidlelibRRtidlelib.idle_test.mock_tkRRRR(R R R tTestCaseRRR#R-R9R_RnRtmain(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyts&      # `=C PK™e[ggtest_textview.pyonu[ {fc@sdZddlZddlZddlmZddlmZddlmZ ddl m Z ddl m Z de jfd YZd ejfd YZd ejfd YZedkrejddndS(s8Test the functions and main class method of textView.py.iN(trequires(tTk(ttextView(tFunc(tMboxtTVcBs#eZeZeZeZRS((t__name__t __module__Rt transienttgrab_sett wait_window(((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyR s  ttextviewClassTestcBsJeZedZedZdZdZdZdZRS(cCs'tdt|_|jjdS(Ntgui(RRtroottwithdraw(tcls((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyt setUpClasss  cCs|jj|`dS(N(R tdestroy(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyt tearDownClasss cCs+tjjtjjtjjdS(N(RRt__init__R R (tself((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pytsetUps  cCs\t|jdd}|jtjj|jtjj|jtjj|jdS(NtTitles test text(RR t assertTrueRtcalledR R tOk(Rtview((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyttest_init_modal#s cCsbt|jdddt}|jtjj|jtjj|jtjj|jdS(NRs test texttmodal( RR tFalset assertFalseRRR R R(RR((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyttest_init_nonmodal*s cCsXt|jdddt}t|_|j|j|jj|`|jdS(NRs test textR(RR RRRRRR(RR((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyttest_ok1s   ( RRt classmethodRRRRRR (((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyR s    tViewFunctionTestcBs8eZedZedZdZdZRS(cCs<tdt|_|jjtj|_tt_dS(NR (RRR Rttvt tkMessageBoxt orig_mboxR(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyR<s     cCs)|jj|`|jt_|`dS(N(R RR%R#R$(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyRDs  cCs?tj|jdddt}|j|tj|jdS(NRs test textR(R#t view_textR RtassertIsInstancet TextViewerR(RR((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyttest_view_textKscCstjjt}tjj|d}tj|jd|dt}|j |tj |j d|j j dd|jtjj|d}tj|jd|dt}|j|dS(Nstest_textview.pyRRtTests1.0s1.ends../notthere.py(tostpathtdirnamet__file__tjoinR#t view_fileR RR'R(tassertInRtgetRt assertIsNone(Rttest_dirttestfileR((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyttest_view_fileQs (RRR!RRR)R6(((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyR":s t__main__t verbosityi(t__doc__tunittestR+ttest.test_supportRtTkinterRtidlelibRR#tidlelib.idle_test.mock_idleRtidlelib.idle_test.mock_tkRR(RtTestCaseR R"Rtmain(((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyts  )% PK™e[jPPtest_parenmatch.pyonu[ {fc@sdZddlZddlmZddlmZmZddlmZdddYZ ddd YZ d ej fd YZ e d krejd dndS(sTest idlelib.ParenMatch.iN(trequires(tTktText(t ParenMatchtMockcBs,eZdZdZdZdZRS(cOs t|_dS(N(tFalsetcalled(tselftargstkwargs((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyt__init__ scOs t|_dS(N(tTrueR(RRR ((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyt__call__scOs t|_dS(N(RR(RRR ((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyt reset_mockscOsdS(N((RRR ((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pytafters(t__name__t __module__R R R R(((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyR s   t DummyEditwincBseZdZRS(cCs(||_d|_d|_t|_dS(Ni(ttextt indentwidthttabwidthR tcontext_use_ps1(RR((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyR s   (RRR (((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyRstParenMatchTestcBsSeZedZedZdZdZdZdZdZ RS(cCsMtdt|_t|j|_t|j|_t|j_dS(Ntgui( RRtrootRRRteditwinRt text_frame(tcls((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyt setUpClass!s   cCs#|`|`|jj|`dS(N(RRRtdestroy(R((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyt tearDownClass)s  cCs|jjdddS(Ns1.0tend(Rtdelete(R((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyttearDown/scCs|j}t|j}|jd|jdd|jd|jd|j|j|j ddd |jdd |j |j d|j|j |j ddd|j d|j|j dddd S(s: Test ParenMatch with 'expression' style. t expressiontinsertsdef foobar(a, btevents<>tparenRs1.10s1.15t)s1.16N(s1.10s1.15((s1.10s1.16(RRRt set_styleR#tflash_paren_eventtassertInt event_infotassertTupleEqualt tag_prevranget restore_eventt assertNotInt assertEqualtparen_closed_event(RRtpm((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyttest_paren_expression2s     cCs|j}t|j}|jd|jdd|jd|jd|j|j|j ddd |jdd |j |j d|j|j |j ddd d S(s7 Test ParenMatch with 'default' style. tdefaultR#sdef foobar(a, bR$s<>R%Rs1.10s1.11R&N(s1.10s1.11(( RRRR'R#R(R)R*R+R,R-R.R/(RRR1((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyttest_paren_defaultIs    cCs|j}t|j}|jdd|j|jd|jdd|j|jd|j|jd|jdd|j|jddS(s Test corner cases in flash_paren_event and paren_closed_event. These cases force conditional expression and alternate paths. R#s# this is a commen)R$s defs a, *arg)N(RRRR#t assertIsNoneR0R((RRR1((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyttest_paren_corner[s cCslt|j}t|_|jd|j|jj|jj|jd|j|jjdS(Nii( RRRR-thandle_restore_timert assertTrueRR t assertFalse(RR1((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyttest_handle_restore_timerns    ( RRt classmethodRRR!R2R4R6R:(((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyRs    t__main__t verbosityi(((t__doc__tunittestttest.test_supportRtTkinterRRtidlelib.ParenMatchRRRtTestCaseRRtmain(((s9/usr/lib64/python2.7/idlelib/idle_test/test_parenmatch.pyts  Y PK™e[bF_ _ test_editmenu.pynu['''Test (selected) IDLE Edit menu items. Edit modules have their own test files files ''' from test.test_support import requires import Tkinter as tk import unittest from idlelib import PyShell class PasteTest(unittest.TestCase): '''Test pasting into widgets that allow pasting. On X11, replacing selections requires tk fix. ''' @classmethod def setUpClass(cls): requires('gui') cls.root = root = tk.Tk() root.withdraw() PyShell.fix_x11_paste(root) cls.text = tk.Text(root) cls.entry = tk.Entry(root) cls.spin = tk.Spinbox(root) root.clipboard_clear() root.clipboard_append('two') @classmethod def tearDownClass(cls): del cls.text, cls.entry, cls.spin cls.root.clipboard_clear() cls.root.update_idletasks() cls.root.update() cls.root.destroy() del cls.root def test_paste_text_no_selection(self): "Test pasting into text without a selection." text = self.text tag, ans = '', 'onetwo\n' text.delete('1.0', 'end') text.insert('1.0', 'one', tag) text.event_generate('<>') self.assertEqual(text.get('1.0', 'end'), ans) def test_paste_text_selection(self): "Test pasting into text with a selection." text = self.text tag, ans = 'sel', 'two\n' text.delete('1.0', 'end') text.insert('1.0', 'one', tag) text.event_generate('<>') self.assertEqual(text.get('1.0', 'end'), ans) def test_paste_entry_no_selection(self): "Test pasting into an entry without a selection." # On 3.6, generated <> fails without empty select range # for 'no selection'. Live widget works fine. entry = self.entry end, ans = 0, 'onetwo' entry.delete(0, 'end') entry.insert(0, 'one') entry.select_range(0, end) # see note entry.event_generate('<>') self.assertEqual(entry.get(), ans) def test_paste_entry_selection(self): "Test pasting into an entry with a selection." entry = self.entry end, ans = 'end', 'two' entry.delete(0, 'end') entry.insert(0, 'one') entry.select_range(0, end) entry.event_generate('<>') self.assertEqual(entry.get(), ans) def test_paste_spin_no_selection(self): "Test pasting into a spinbox without a selection." # See note above for entry. spin = self.spin end, ans = 0, 'onetwo' spin.delete(0, 'end') spin.insert(0, 'one') spin.selection('range', 0, end) # see note spin.event_generate('<>') self.assertEqual(spin.get(), ans) def test_paste_spin_selection(self): "Test pasting into a spinbox with a selection." spin = self.spin end, ans = 'end', 'two' spin.delete(0, 'end') spin.insert(0, 'one') spin.selection('range', 0, end) spin.event_generate('<>') self.assertEqual(spin.get(), ans) if __name__ == '__main__': unittest.main(verbosity=2) PK™e[test_autoexpand.pycnu[ {fc@sdZddlZddlmZddlmZmZddlmZdd dYZ dej fd YZ e d krej d d ndS(s!Unit tests for idlelib.AutoExpandiN(trequires(tTexttTk(t AutoExpandt Dummy_EditwincBseZdZRS(cCs ||_dS(N(ttext(tselfR((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyt__init__ s(t__name__t __module__R(((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyR stAutoExpandTestcBs\eZedZedZdZdZdZdZdZ dZ RS(cCsedttkr=tdt|_t|j|_n t|_tt|j|_dS(NtTkintertgui( tstrRRRttkRRRt auto_expand(tcls((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyt setUpClasss    cCs5|`|`t|dr1|jj|`ndS(NR(RRthasattrRtdestroy(R((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyt tearDownClasss  cCs|jjdddS(Ns1.0tend(Rtdelete(R((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttearDown!scCs|j}|jj}|j}||d|jdd||d|jdd||d|jdd||d|jdd||d|jdd||d |jd d||d|jd d ||ddS( Nttinsertttthistthist tiss sample stringtstrings3.0s1.0R(RRt getprevwordt assertEqualRR(RRtprevioustequal((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttest_get_prevword$s$   cCs|jj}|jj}|j}|jjdd||jjddddg|d||d|d||d|d||d|d||ddS(NRsab ac bx ad ab atabtadtactatevent(RR texpand_word_eventR!RRtgetwords(RR"texpandR#((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttest_before_only@s   "    cCs|j}|jj}|jj}|j}|jdd|jdd||jjddddg|d||d|d||d|d||d|d||ddS( NRs a, [ab] ac: () bx"" cd ac= ad yas1.1R%R'R&R(R)(RRR R*R!Rtmark_setR+(RRR"R,R#((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttest_after_onlyPs    "    cCs|j}|jj}|jj}|j}|jdd|jdd|jdd||jjdddg|d||d|d||d|d||ddS( NRs ab xy yz s a ac by acs2.1R%R'R(R)(RRR R*R!RR.R+(RRR"R,R#((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttest_both_before_aftercs       cCs|j}|jj}|j}||jjg||dd|jdd||jjg|jdd|jdd|d|jj}|jdd|d|jj}|j||dS(NR)tbreakRs bx cy dz asac xy a ac ad as1.7s1.end( RRR*R!R+RR.tstatetassertNotEqual(RRR,R#t initial_statet new_state((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttest_other_expand_casesus       ( RR t classmethodRRRR$R-R/R0R6(((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyR s      t__main__t verbosityi((t__doc__tunittestttest.test_supportRR RRtidlelib.AutoExpandRRtTestCaseR Rtmain(((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyts ~ PK™e[Rwwtest_configdialog.pyonu[ {fc@sdZddlZddlmZddlmZddlmZddlm Z dej fdYZ e d krej d d ndS( soUnittests for idlelib/configHandler.py Coverage: 46% just by creating dialog. The other half is change code. iN(trequires(tTk(t ConfigDialog(t_initializeTkVariantTeststConfigDialogTestcBs/eZedZedZdZRS(cCs4tdt|_|jjt|jdS(Ntgui(RRtroottwithdrawR(tcls((s;/usr/lib64/python2.7/idlelib/idle_test/test_configdialog.pyt setUpClasss   cCs|jj|`dS(N(Rtdestroy(R((s;/usr/lib64/python2.7/idlelib/idle_test/test_configdialog.pyt tearDownClasss cCs&t|jddt}|jdS(NtTestt_utest(RRtTruetremove_var_callbacks(tselftd((s;/usr/lib64/python2.7/idlelib/idle_test/test_configdialog.pyt test_dialogs(t__name__t __module__t classmethodR R R(((s;/usr/lib64/python2.7/idlelib/idle_test/test_configdialog.pyR st__main__t verbosityi(t__doc__tunittestttest.test_supportRtTkinterRtidlelib.configDialogRtidlelib.macosxSupportRtTestCaseRRtmain(((s;/usr/lib64/python2.7/idlelib/idle_test/test_configdialog.pyts  PK™e[rtest_pathbrowser.pycnu[ {fc@sddlZddlZddlZddlZddlmZdejfdYZedkr~ejddde ndS( iN(t PathBrowsertPathBrowserTestcBseZdZdZRS(cCstjd}|j|jd|jtjjtjjt j d}|j|j |t |j|j |dt dS(Ntis/Icons(RtDirBrowserTreeItemt GetSubListt assertEqualtGetTexttostpathtsplittabspathtidlelibt__file__t ispackagedirtTruetFalse(tselftdtdir((s:/usr/lib64/python2.7/idlelib/idle_test/test_pathbrowser.pyttest_DirBrowserTreeItem s  %cCsQtj}|j|jd|j}|jt|ttjdS(Nssys.path(RtPathBrowserTreeItemRRRtlentsysR(Rtptsub((s:/usr/lib64/python2.7/idlelib/idle_test/test_pathbrowser.pyttest_PathBrowserTreeItems  (t__name__t __module__RR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_pathbrowser.pyRs t__main__t verbosityitexit( tunittestRRR RtTestCaseRRtmainR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_pathbrowser.pyts     PK™e[test_autocomplete.pyonu[ {fc@sddlZddlmZddlmZmZddljZddl j Z ddl m Z ddlmZdddYZ ddd YZd ejfd YZed krejd dndS(iN(trequires(tTktText(tFunc(tEventtAutoCompleteWindowcBseZdZRS(cCsdS(N((((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pytcomplete s(t__name__t __module__R(((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyR st DummyEditwincBseZdZRS(cCs1||_||_d|_d|_t|_dS(Ni(trootttextt indentwidthttabwidthtTruetcontext_use_ps1(tselfR R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyt__init__s     (RRR(((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyR stAutoCompleteTestcBseZedZedZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZRS(cCsDtdt|_t|j|_t|j|j|_dS(Ntgui(RRR RR R teditor(tcls((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyt setUpClasss  cCs#|`|`|jj|`dS(N(RR R tdestroy(R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyt tearDownClass s  cCs/|jjjddtj|j|_dS(Ns1.0tend(RR tdeletetact AutoCompletet autocomplete(R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pytsetUp&scCs|j|jj|jdS(N(t assertEqualRteditwinR(R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyt test_init*scCs&|jj}|j|tjdS(N(Rt_make_autocomplete_windowtassertIsInstancetacwR(Rttestwin((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_make_autocomplete_window-scCs9|jj|j_|jj|j|jjdS(N(RR"tautocompletewindowt_remove_autocomplete_windowt assertIsNone(R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_remove_autocomplete_window1s cCsEt}||j_|jjd|j|jtttfdS(Ntevent(RRtopen_completionstforce_open_completions_eventRtargsRtFalse(Rto_cs((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyt!test_force_open_completions_event7s  cCs|j}|j}|jj}t}||_|d||jd|jjdd|d||jt t t df|jj dd|jjdd|d||jt t t dfdS(NR+s1.0sre.iRs"./Lib/i( RRttry_open_completions_eventRt_open_completions_laterR.tNoneR tinsertR/R(RtEqualRttrycompletionsto_c_l((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_try_open_completions_event>s        cCs|j}|j}tdt}|j|j||`|jjdd||jj|d|j t }||_ ||jj|d||j tttft|_||jj|d||j tttfdS(Ntmc_states1.0sre.tbreak(RRRRR)tautocomplete_eventR:R R5R(RR,R4R.R/tresult(RR6RtevR0((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_autocomplete_eventTs      cCsdS(N((R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_open_completions_laternscCsdS(N((R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_delayed_open_completionsrscCsdS(N((R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_open_completionsxscCsdS(N((R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_fetch_completions}scCsdS(N((R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_get_entitys(RRt classmethodRRRR!R&R*R1R9R?R@RARBRCRD(((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyRs           t__main__t verbosityi(((tunittestttest.test_supportRtTkinterRRtidlelib.AutoCompleteRRtidlelib.AutoCompleteWindowRR$tidlelib.idle_test.mock_idleRtidlelib.idle_test.mock_tkRR tTestCaseRRtmain(((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyts  t PK™e[j? ? mock_idle.pyonu[ {fc@s\dZddlmZdefdYZdefdYZdefdYZd S( sqMock classes that imitate idlelib modules or classes. Attributes and methods will be added as needed for tests. i(tTexttFunccBs#eZdZddZdZRS(sMock function captures args and returns result set by test. Attributes: self.called - records call even if no args, kwds passed. self.result - set by init, returned by call. self.args - captures positional arguments. self.kwds - captures keyword arguments. Most common use will probably be to mock methods. Mock_tk.Var and Mbox_func are special variants of this. cCs(t|_||_d|_d|_dS(N(tFalsetcalledtresulttNonetargstkwds(tselfR((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyt__init__s   cOsDt|_||_||_t|jtr9|jn|jSdS(N(tTrueRRRt isinstanceRt BaseException(RRR((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyt__call__s     N(t__name__t __module__t__doc__RR R (((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyRs  tEditorcBs,eZdZdddddZdZRS(s7Minimally imitate EditorWindow.EditorWindow class. cCst|_t|_dS(N(Rttextt UndoDelegatortundo(Rtflisttfilenametkeytroot((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyR &s cCs.|jjd}|jjd}||fS(Ns1.0tend(Rtindex(Rtfirsttlast((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pytget_selection_indices*sN(RRRRR R(((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyR#sRcBs eZdZdZdZRS(s9Minimally imitate UndoDelegator,UndoDelegator class. cGsdS(N((R((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pytundo_block_start4scGsdS(N((R((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pytundo_block_stop6s(RRRRR(((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyR0s N(Rtidlelib.idle_test.mock_tkRtobjectRRR(((s3/usr/lib64/python2.7/idlelib/idle_test/mock_idle.pyts PK™e[L)test_calltips.pynu[import unittest import idlelib.CallTips as ct CTi = ct.CallTips() # needed for get_entity test in 2.7 import textwrap import types import warnings default_tip = '' # Test Class TC is used in multiple get_argspec test methods class TC(object): 'doc' tip = "(ai=None, *args)" def __init__(self, ai=None, *b): 'doc' __init__.tip = "(self, ai=None, *args)" def t1(self): 'doc' t1.tip = "(self)" def t2(self, ai, b=None): 'doc' t2.tip = "(self, ai, b=None)" def t3(self, ai, *args): 'doc' t3.tip = "(self, ai, *args)" def t4(self, *args): 'doc' t4.tip = "(self, *args)" def t5(self, ai, b=None, *args, **kw): 'doc' t5.tip = "(self, ai, b=None, *args, **kwargs)" def t6(no, self): 'doc' t6.tip = "(no, self)" def __call__(self, ci): 'doc' __call__.tip = "(self, ci)" # attaching .tip to wrapped methods does not work @classmethod def cm(cls, a): 'doc' @staticmethod def sm(b): 'doc' tc = TC() signature = ct.get_arg_text # 2.7 and 3.x use different functions class Get_signatureTest(unittest.TestCase): # The signature function must return a string, even if blank. # Test a variety of objects to be sure that none cause it to raise # (quite aside from getting as correct an answer as possible). # The tests of builtins may break if the docstrings change, # but a red buildbot is better than a user crash (as has happened). # For a simple mismatch, change the expected output to the actual. def test_builtins(self): # 2.7 puts '()\n' where 3.x does not, other minor differences # Python class that inherits builtin methods class List(list): "List() doc" # Simulate builtin with no docstring for default argspec test class SB: __call__ = None def gtest(obj, out): self.assertEqual(signature(obj), out) if List.__doc__ is not None: gtest(List, '()\n' + List.__doc__) gtest(list.__new__, 'T.__new__(S, ...) -> a new object with type S, a subtype of T') gtest(list.__init__, 'x.__init__(...) initializes x; see help(type(x)) for signature') append_doc = "L.append(object) -- append object to end" gtest(list.append, append_doc) gtest([].append, append_doc) gtest(List.append, append_doc) gtest(types.MethodType, '()\ninstancemethod(function, instance, class)') gtest(SB(), default_tip) def test_signature_wrap(self): # This is also a test of an old-style class if textwrap.TextWrapper.__doc__ is not None: self.assertEqual(signature(textwrap.TextWrapper), '''\ (width=70, initial_indent='', subsequent_indent='', expand_tabs=True, replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, drop_whitespace=True, break_on_hyphens=True)''') def test_docline_truncation(self): def f(): pass f.__doc__ = 'a'*300 self.assertEqual(signature(f), '()\n' + 'a' * (ct._MAX_COLS-3) + '...') def test_multiline_docstring(self): # Test fewer lines than max. self.assertEqual(signature(list), "()\nlist() -> new empty list\n" "list(iterable) -> new list initialized from iterable's items") # Test max lines and line (currently) too long. def f(): pass s = 'a\nb\nc\nd\n' f.__doc__ = s + 300 * 'e' + 'f' self.assertEqual(signature(f), '()\n' + s + (ct._MAX_COLS - 3) * 'e' + '...') def test_functions(self): def t1(): 'doc' t1.tip = "()" def t2(a, b=None): 'doc' t2.tip = "(a, b=None)" def t3(a, *args): 'doc' t3.tip = "(a, *args)" def t4(*args): 'doc' t4.tip = "(*args)" def t5(a, b=None, *args, **kwds): 'doc' t5.tip = "(a, b=None, *args, **kwargs)" doc = '\ndoc' if t1.__doc__ is not None else '' for func in (t1, t2, t3, t4, t5, TC): self.assertEqual(signature(func), func.tip + doc) def test_methods(self): doc = '\ndoc' if TC.__doc__ is not None else '' for meth in (TC.t1, TC.t2, TC.t3, TC.t4, TC.t5, TC.t6, TC.__call__): self.assertEqual(signature(meth), meth.tip + doc) self.assertEqual(signature(TC.cm), "(a)" + doc) self.assertEqual(signature(TC.sm), "(b)" + doc) def test_bound_methods(self): # test that first parameter is correctly removed from argspec doc = '\ndoc' if TC.__doc__ is not None else '' for meth, mtip in ((tc.t1, "()"), (tc.t4, "(*args)"), (tc.t6, "(self)"), (tc.__call__, '(ci)'), (tc, '(ci)'), (TC.cm, "(a)"),): self.assertEqual(signature(meth), mtip + doc) def test_starred_parameter(self): # test that starred first parameter is *not* removed from argspec class C: def m1(*args): pass def m2(**kwds): pass def f1(args, kwargs, *a, **k): pass def f2(args, kwargs, args1, kwargs1, *a, **k): pass c = C() self.assertEqual(signature(C.m1), '(*args)') self.assertEqual(signature(c.m1), '(*args)') self.assertEqual(signature(C.m2), '(**kwargs)') self.assertEqual(signature(c.m2), '(**kwargs)') self.assertEqual(signature(f1), '(args, kwargs, *args1, **kwargs1)') self.assertEqual(signature(f2), '(args, kwargs, args1, kwargs1, *args2, **kwargs2)') def test_no_docstring(self): def nd(s): pass TC.nd = nd self.assertEqual(signature(nd), "(s)") self.assertEqual(signature(TC.nd), "(s)") self.assertEqual(signature(tc.nd), "()") def test_attribute_exception(self): class NoCall(object): def __getattr__(self, name): raise BaseException class Call(NoCall): def __call__(self, ci): pass for meth, mtip in ((NoCall, '()'), (Call, '()'), (NoCall(), ''), (Call(), '(ci)')): self.assertEqual(signature(meth), mtip) def test_non_callables(self): for obj in (0, 0.0, '0', b'0', [], {}): self.assertEqual(signature(obj), '') class Get_entityTest(unittest.TestCase): # In 3.x, get_entity changed from 'instance method' to module function # since 'self' not used. Use dummy instance until change 2.7 also. def test_bad_entity(self): self.assertIsNone(CTi.get_entity('1//0')) def test_good_entity(self): self.assertIs(CTi.get_entity('int'), int) class Py2Test(unittest.TestCase): def test_paramtuple_float(self): # 18539: (a,b) becomes '.0' in code object; change that but not 0.0 with warnings.catch_warnings(): # Suppess message of py3 deprecation of parameter unpacking warnings.simplefilter("ignore") exec "def f((a,b), c=0.0): pass" self.assertEqual(signature(f), '(, c=0.0)') if __name__ == '__main__': unittest.main(verbosity=2, exit=False) PK™e[F*7; ; test_helpabout.pyonu[ {fc@sdZddlmZddlmZddlmZddlm Z ddl Z ej Z dddYZ d e jfd YZed kre jd d ndS(s$Test idlelib.help_about. Coverage: i(t aboutDialog(ttextView(tFunc(tMboxNtDummy_about_dialogcBs8eZejjZejjZejjZ ej jZ RS(( t__name__t __module__tAbouttShowIDLECreditstim_funct idle_creditst ShowIDLEAboutt idle_readmet ShowIDLENEWSt idle_newstdisplay_file_text(((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyR s   tDisplayFileTestcBs>eZdZeZedZedZdZRS(s4Test that .txt files are found and properly decoded.cCsXtj|_tj|_t|_t|_|jt_|jt_t |_ dS(N( ttextviewt tkMessageBoxt orig_mboxt view_textt orig_viewRtmboxRtviewRR(tcls((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyt setUpClasss      cCs|jt_|jjt_dS(N(RRRRR R(R((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyt tearDownClass#s cCsxz|jj|jj|jjfD]W}d|jj_t|j_ ||j |jjjd|j |jj t q"WdS(Nt( tdialogR R RRt showerrortmessagetFalseRtcalledt assertEqualtTrue(tselfthandler((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyttest_file_isplay(s   ( RRt__doc__RRt classmethodRRR%(((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyRs   t__main__t verbosityi((R&tidlelibRt help_aboutRRtidlelib.idle_test.mock_idleRtidlelib.idle_test.mock_tkRtunittestt AboutDialogRRtTestCaseRRtmain(((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyts    PK™e[^c/c/test_calltips.pyonu[ {fc@sddlZddljZejZddlZddlZddlZdZde fdYZ e Z ej Z dejfdYZdejfdYZd ejfd YZed krejd d dendS(iNttTCcBseZdZdZddZde_dZde_ddZde_dZd e_d Z d e _dd Z d e _dZ de _dZ de _e dZedZRS(tdocs(ai=None, *args)cGsdS(RN((tselftaitb((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyt__init__Rs(self, ai=None, *args)cCsdS(RN((R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt1Rs(self)cCsdS(RN((RRR((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt2Rs(self, ai, b=None)cGsdS(RN((RRtargs((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt3Rs(self, ai, *args)cGsdS(RN((RR ((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt4Rs (self, *args)cOsdS(RN((RRRR tkw((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt5Rs#(self, ai, b=None, *args, **kwargs)cCsdS(RN((tnoR((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt6Rs (no, self)cCsdS(RN((Rtci((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyt__call__Rs (self, ci)cCsdS(RN((tclsta((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytcmRcCsdS(RN((R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytsm!RN(t__name__t __module__t__doc__ttiptNoneRRRR R R RRt classmethodRt staticmethodR(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR s(                tGet_signatureTestcBskeZdZdZdZdZdZdZdZdZ dZ d Z d Z RS( csdtfdY}dd dY}fd}|jdk r^||d|jn|tjd|tjdd }|tj||gj|||j||tjd ||tdS( NtListcBseZdZRS(s List() doc(RRR(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR3stSBcBseZdZRS(N(RRRR(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR5scsjt||dS(N(t assertEqualt signature(tobjtout(R(s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytgtest7ss() s=T.__new__(S, ...) -> a new object with type S, a subtype of Ts>x.__init__(...) initializes x; see help(type(x)) for signatures(L.append(object) -- append object to ends,() instancemethod(function, instance, class)(( tlistRRt__new__Rtappendttypest MethodTypet default_tip(RRRR$t append_doc((Rs7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyt test_builtins/s  cCs2tjjdk r.|jttjdndS(Ns(width=70, initial_indent='', subsequent_indent='', expand_tabs=True, replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, drop_whitespace=True, break_on_hyphens=True)(ttextwrapt TextWrapperRRR R!(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_signature_wrapHscCsCd}dd|_|jt|ddtjdddS(NcSsdS(N((((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytfQRRi,s() is...(RR R!tctt _MAX_COLS(RR0((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_docline_truncationPs  cCsk|jttdd}d}|ddd|_|jt|d|tjddd dS( NsX() list() -> new empty list list(iterable) -> new list initialized from iterable's itemscSsdS(N((((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR0\ssa b c d i,teR0s() is...(R R!R%RR1R2(RR0ts((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_multiline_docstringUs cCsd}d|_dd}d|_d}d|_d}d|_dd }d |_|jdk rud nd }x=|||||tfD]#}|jt||j|qWdS( NcSsdS(RN((((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRdRs()cSsdS(RN((RR((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRfRs (a, b=None)cWsdS(RN((RR ((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR hRs (a, *args)cWsdS(RN((R ((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR jRs(*args)c_sdS(RN((RRR tkwds((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR lRs(a, b=None, *args, **kwargs)s docR(RRRRR R!(RRRR R R Rtfunc((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_functionscs          cCstjdk rdnd}xUtjtjtjtjtjtjtj fD]#}|j t ||j |qLW|j t tj d||j t tjd|dS(Ns docRs(a)s(b)(RRRRRR R R RRR R!RRR(RRtmeth((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyt test_methodsss 7!cCstjdk rdnd}xstjdftjdftjdftjdftdftjdffD]&\}}|j t |||qgWdS(Ns docRs()s(*args)s(self)s(ci)s(a)( RRRttcRR RRRR R!(RRR:tmtip((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_bound_methodszs'1cCsdd dY}d}d}|}|jt|jd|jt|jd|jt|jd|jt|jd|jt|d|jt|ddS( NtCcBseZdZdZRS(cWsdS(N((R ((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytm1Rc[sdS(N((R7((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytm2R(RRR@RA(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR?s c_sdS(N((R tkwargsRtk((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytf1Rc_sdS(N((R RBtargs1tkwargs1RRC((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytf2Rs(*args)s (**kwargs)s!(args, kwargs, *args1, **kwargs1)s1(args, kwargs, args1, kwargs1, *args2, **kwargs2)((R R!R@RA(RR?RDRGtc((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_starred_parameters   cCs^d}|t_|jt|d|jttjd|jttjddS(NcSsdS(N((R5((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytndRs(s)s()(RRJR R!R<(RRJ((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_no_docstrings   cCsdtfdY}d|fdY}xT|df|df|df|dffD]"\}}|jt||q]WdS(NtNoCallcBseZdZRS(cSs tdS(N(t BaseException(Rtname((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyt __getattr__s(RRRO(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRLstCallcBseZdZRS(cSsdS(N((RR((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRs(RRR(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRPss()Rs(ci)(tobjectR R!(RRLRPR:R=((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_attribute_exceptions (cCs=x6ddddgifD]}|jt|dqWdS(Nigt0R(R R!(RR"((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_non_callabless( RRR,R/R3R6R9R;R>RIRKRRRT(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR's          tGet_entityTestcBseZdZdZRS(cCs|jtjddS(Ns1//0(t assertIsNonetCTit get_entity(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_bad_entityscCs|jtjdtdS(Ntint(tassertIsRWRXRZ(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_good_entitys(RRRYR\(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRUs tPy2TestcBseZdZRS(cBsBejejdddUWdQX|jeeddS(Ntignoresdef f((a,b), c=0.0): passs(, c=0.0)(twarningstcatch_warningst simplefilterR R!R0(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_paramtuple_floats  (RRRb(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR]st__main__t verbosityitexit(tunittesttidlelib.CallTipstCallTipsR1RWR-R(R_R*RQRR<t get_arg_textR!tTestCaseRRUR]RtmaintFalse(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyts        PK™e[' test_text.pyonu[ {fc@sddlZddlmZddlmZdefdYZdeejfdYZdeejfd YZ e d krej d d d e ndS(iN(trequires(tTclErrortTextTestcBseZdZedZd ZdZdZdZdZ dZ dZ dZ d Z d Zd Zd ZRS(s hello worlds cCs|j|_dS(N(tTextttext(tself((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pytsetUp scCs<|j|jjdd|j|jjdddS(Ns1.0s tendt(t assertEqualRtget(R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt test_initscCs^|jj}x$dD]}|j||dqWx$dD]}|j||d q:WdS(Ngg333333?s1.-1s1.0s 1.0 lineends1.ends1.33tinsertRg@s2.1s33.44s2.0(gg333333?s1.-1s1.0s 1.0 lineends1.ends1.33R (Rg@s2.1s33.44(RtindexR (RR tdex((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_index_emptys    cCs|jj}|jjd|jx$d D]}|j||dq)Wx$d D]}|j||dqPWx$dD]}|j||d qwWdS(Ns1.0gg333333?s1.-1s 1.0 lineends1.ends1.33s1.5Rs33.44s3.0(gg333333?s1.-1s1.0(s 1.0 lineends1.ends1.33(Rs33.44(RR R thwR (RR R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_index_datas    cCsM|jj}|j}|jjd|j||dd||ddd||dd||ddd||ddd||ddd||dd d ||dd d ||d d ||dd d||dd|j||dd|j||dd|jdS(Ns1.0RRths1.1s1.3theltels 1.0 lineendthellos1.10s s2.3sello wors2.5s0.0s5.0(RR R R Rthwn(RR tEqual((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_get+s   cCs#|jj}|jj}|j}|d|j||dd|j|dd||dd|j|dd||ddd|dd||ddd|dd||ddd |dd ||ddd |d d ||ddddS(Ns1.0RRt*s *hello world s 1.0 lineends*hello* world s2.3s*hello* wor*ld txs*hello* wor*ldx s1.4sx s*helx lo* wor*ldx (RR R R RR(RR R R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt test_insert>s"         cCs|jj}|jj}|j}|jjd|j|d||dd|j|d||dd|j|dd||dd|j|dd||dd|j|dd||dd|j|dd||dd|jdS(Ns1.0R Rs5.5s1.4(RtdeleteR R R RR(RRR R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_no_deleteXs          cCs|jj}|jj}|j}|jjd|j|d||ddd|dd||ddd|d||ddd|jjdd|d ||ddd|jjdd|dd ||ddddS( Ns1.0s1.endtellos1.1tllotlloworlds1.3s s1.10s2.0(RRR R R R(RRR R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_delete_charqs         cCs|jj}|jj}|j}|jjd|j|dd||ddd|dd||ddd|jjd|j|dd||ddd|dd||ddd|jjd|j|dd ||ddd dS( Ns1.0s 1.0 lineendRs world s s2.0sworld s1.2s2.3sheld (RRR R R R(RRR R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_delete_slices         cCs{|jjdd|jjdd|j|jjddd|jjdd|j|jjddddS( Ns1.0Rs1.3s 1 2 3 4 5Rshel1 2 3 4 5lo s5.1shello (RR R R R(R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_multiple_liness c Csr|jj}|j}|jjdd|jt|dddx*dtttttfdtttttfdtttttfdtttttfd tttttfd tttttffD]\}}}}}}||d |d||||d |d||||d|d||||d |d||||d|d||qWdS(Ns1.0sFirst Second Third s2.2topts>=s==s!=s1.1s2.1s2.3s3.3(RtcompareR R t assertRaisesRtTruetFalse( RR'RR$tless1tless0tequaltgreater0tgreater1((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt test_compares   1N(t__name__t __module__RRtNoneRRR RRRRRR!R"R#R0(((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyRs         t MockTextTestcBs eZedZdZRS(cCsddlm}||_dS(Ni(R(tidlelib.idle_test.mock_tkR(tclsR((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt setUpClassscCs|jj}|j}|jjd|j||ddd ||ddd ||ddd ||ddd dS( Ns1.0Riiis3.1ii(ii(ii(ii(ii(Rt_decodeR R R(RtdecodeR((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt test_decodes  (R1R2t classmethodR7R:(((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyR4st TkTextTestcBs&eZedZedZRS(cCs9tdddlm}m}||_||_dS(Ntguii(tTkR(RtTkinterR>Rtroot(R6R>R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyR7s  cCs|jj|`dS(N(R@tdestroy(R6((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt tearDownClasss (R1R2R;R7RB(((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyR<st__main__t verbosityitexit( tunittestttest.test_supportRt_tkinterRtobjectRtTestCaseR4R<R1tmainR*(((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyts  PK™e[Hvptest_delegator.pynu[import unittest from idlelib.Delegator import Delegator class DelegatorTest(unittest.TestCase): def test_mydel(self): # test a simple use scenario # initialize mydel = Delegator(int) self.assertIs(mydel.delegate, int) self.assertEqual(mydel._Delegator__cache, set()) # add an attribute: self.assertRaises(AttributeError, mydel.__getattr__, 'xyz') bl = mydel.bit_length self.assertIs(bl, int.bit_length) self.assertIs(mydel.__dict__['bit_length'], int.bit_length) self.assertEqual(mydel._Delegator__cache, {'bit_length'}) # add a second attribute mydel.numerator self.assertEqual(mydel._Delegator__cache, {'bit_length', 'numerator'}) # delete the second (which, however, leaves it in the name cache) del mydel.numerator self.assertNotIn('numerator', mydel.__dict__) self.assertIn('numerator', mydel._Delegator__cache) # reset by calling .setdelegate, which calls .resetcache mydel.setdelegate(float) self.assertIs(mydel.delegate, float) self.assertNotIn('bit_length', mydel.__dict__) self.assertEqual(mydel._Delegator__cache, set()) if __name__ == '__main__': unittest.main(verbosity=2, exit=2) PK™e[p-test_config_name.pyonu[ {fc@sdZddlZddlmZmZddlmZejZ de fdYZ ej Z ejZdejfdYZed krejd d d endS( s.Unit tests for idlelib.configSectionNameDialogiN(tVartMbox(tconfigSectionNameDialogtDummy_name_dialogcBs\eZejjZejjZejjZdgZeZ dZ e Z dZdZRS(tusedcCsdS(N((tself((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyt grab_releasescCs t|_dS(N(tTruet destroyed(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pytdestroysN(t__name__t __module__t name_dialogtname_oktim_functOktCancelt used_namesRtnametNonetresulttFalseRRR (((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyRs      tConfigNameTestcBseeZeZedZedZdZdZdZ dZ dZ dZ RS(cCs tt_dS(N(Rtname_dialog_modulet tkMessageBox(tcls((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyt setUpClassscCs tt_dS(N(t orig_mboxRR(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyt tearDownClass"scCsV|jjjd|j|jjd|jtjd|jdtjdS(Nt ts Name ErrortNo( tdialogRtsett assertEqualR t showerrorttitletassertIntmessage(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyttest_blank_name&scCsV|jjjd|j|jjd|jtjd|jdtjdS(NRRs Name Errortuse( R RR!R"R R#R$R%R&(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyttest_used_name,scCsZ|jjjdd|j|jjd|jtjd|jdtjdS(NtgoodiRs Name Errorstoo long( R RR!R"R R#R$R%R&(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyttest_long_name2scCsL|jjjddt_|j|jjd|jtjddS(Ns good sNo ErrorR*(R RR!R#R$R"R (R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyttest_good_name8s cCsYt|j_|jjjd|jj|j|jjd|j|jjdS(NR*( RR RRR!RR"Rt assertTrue(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyttest_ok>s   cCsFt|j_|jj|j|jjd|j|jjdS(NR(RR RRR"RR-(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyt test_cancelEs  ( R R RR t classmethodRRR'R)R+R,R.R/(((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyRs      t__main__t verbosityitexit(t__doc__tunittesttidlelib.idle_test.mock_tkRRtidlelibRRtGetCfgSectionNameDialogR tobjectRRRR#tTestCaseRR tmainR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyts    1 PK™e[)WWtest_editmenu.pycnu[ {fc@szdZddlmZddlZddlZddlmZdejfdYZ e dkrvej dd ndS( sTTest (selected) IDLE Edit menu items. Edit modules have their own test files files i(trequiresN(tPyShellt PasteTestcBsbeZdZedZedZdZdZdZdZ dZ dZ RS( seTest pasting into widgets that allow pasting. On X11, replacing selections requires tk fix. cCstdtj|_}|jtj|tj||_tj ||_ tj ||_ |j |jddS(Ntguittwo(RttktTktroottwithdrawRt fix_x11_pastetTextttexttEntrytentrytSpinboxtspintclipboard_cleartclipboard_append(tclsR((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyt setUpClasss    cCsP|`|`|`|jj|jj|jj|jj|`dS(N(R R RRRtupdate_idletaskstupdatetdestroy(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyt tearDownClasss     cCse|j}d\}}|jdd|jdd||jd|j|jdd|dS( s+Test pasting into text without a selection.tsonetwo s1.0tendtones <>N(Rsonetwo (R tdeletetinserttevent_generatet assertEqualtget(tselfR ttagtans((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_text_no_selection&s    cCse|j}d\}}|jdd|jdd||jd|j|jdd|dS( s(Test pasting into text with a selection.tselstwo s1.0RRs <>N(R$stwo (R RRRRR(R R R!R"((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_text_selection/s    cCsl|j}d\}}|jdd|jdd|jd||jd|j|j|dS(s/Test pasting into an entry without a selection.itonetwoRRs <>N(iR&(R RRt select_rangeRRR(R R RR"((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_entry_no_selection8s   cCsl|j}d\}}|jdd|jdd|jd||jd|j|j|dS(s,Test pasting into an entry with a selection.RRiRs <>N(RR(R RRR'RRR(R R RR"((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_entry_selectionDs   cCso|j}d\}}|jdd|jdd|jdd||jd|j|j|dS( s0Test pasting into a spinbox without a selection.iR&RRtranges <>N(iR&(RRRt selectionRRR(R RRR"((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_spin_no_selectionNs   cCso|j}d\}}|jdd|jdd|jdd||jd|j|j|dS( s-Test pasting into a spinbox with a selection.RRiRR*s <>N(RR(RRRR+RRR(R RRR"((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_spin_selectionYs   ( t__name__t __module__t__doc__t classmethodRRR#R%R(R)R,R-(((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyR s  t__main__t verbosityi( R0ttest.test_supportRtTkinterRtunittesttidlelibRtTestCaseRR.tmain(((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyts  Y PK™e[1uftest_searchdialogbase.pycnu[ {fc@sdZddlZddlmZddlmZmZmZmZddl m Z ddl m Z ddlmZdejfd YZed krejd d d d ndS(sUnittests for idlelib/SearchDialogBase.py Coverage: 99%. The only thing not covered is inconsequential -- testing skipping of suite when self.needwrapbutton is false. iN(trequires(tTexttTktTopleveltFrame(t SearchEngine(tSearchDialogBase(tFunctSearchDialogBaseTestcBseZedZedZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZRS(cCstdt|_dS(Ntgui(RRtroot(tcls((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyt setUpClasss cCs|jj|`dS(N(R tdestroy(R ((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyt tearDownClass s cCs:tj|j|_tjd|jd|j|_dS(NR tengine(tseRR RtsdbRtdialog(tself((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pytsetUp%scCs|jjdS(N(Rtclose(R((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttearDown)scCsd|j_t|j}t|}|jj||j|jjj d|jj |j|jjj d|jj|dd|j|jj j d|j |jdS(Ntnormalt withdrawnt searchphrasethello(tNoneRtdefault_commandRR Rtopent assertEqualttoptstateRtenttgettupdate_idletasksR (Rttoplevelttext((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_open_and_close,s    cCst|j_t|j_t|j_t|j_d|j_|jj|j |jjj |j |jjj |j |jjj |j |jjj dS(N( RRtcreate_entriestcreate_option_buttonstcreate_other_buttonstcreate_command_buttonsRRtcreate_widgetst assertTruetcalled(R((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_create_widgets<s  cCs|j}d|j_t|j|j_|jjdd\}}||dd|j|jd|j }|t |dd|t |dd|t |dd|t |d d||jjddS( NisTest:RR%trowtcolumnitrowspant columnspan( RRR/RR Rt make_entrytassertInR"t grid_infotint(Rtequaltentrytlabeltegi((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_make_entryJs   cCsId|j_|jjd|jj|j|jjjddS(NiR(RR/RtsetpatR'R4R!R"(R((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_create_entriesYs  cCsd|j_t|j|j_|jj\}}|j|d|j|t|jjd\}}|j|dd|j|tdS(Nitt testlabelR%( RR/RR Rt make_frameRtassertIsInstanceR(RtframeR9((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_make_frame_s cCs(t|j|j_d|j_|S(Ni(RR RRR/(Rtmeth((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pytbtn_test_setupjs c Cs|j}xdD]}x3|j|j|j|jfD]}|j|q5W|j|jj\}}xt ||j D]\}}|\}}|j |d||j |j ||dkr|j n |j|j |j d|q}WqWdS(NiiR%(ii(RtrevartcasevartwordvartwrapvartsetRERR(tzipt pack_slavesRR"tdeselecttselect( RteR tvarRBtoptionstspectbuttonR9((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_create_option_buttonsos  %"    c Csx ttfD]}|jj}|j||j|jj\}}|j}xt ||D]\}}|\}} |j |d| ||krc|j |j |||j |j |j d||d|j |j |j |qcqcWq WdS(NR%i( tFalsetTrueRtbackvarRJRERR)RLRKRR"RN( RR RPRBtotherstbuttonsRRRStvalR9((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_create_other_buttonss     cCs`t|j|j_t|jj|j_|jjd|jj}|j|dddS(NtTestR%( RR RRRt buttonframet make_buttonRR(Rtbtn((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_make_buttonscCsa|jjd}x7|jjjD]#}|ddkr&|d}q&q&W|jd|dS(NR>R%Rtcommand(RR*R]twinfo_childrenR4(Rtclosebuttoncommandtchild((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_create_command_buttonss  (t__name__t __module__t classmethodR RRRR&R.R;R=RCRERTR[R`Re(((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyRs          t__main__t verbosityitexit(t__doc__tunittestttest.test_supportRtTkinterRRRRtidlelibRRRRtidlelib.idle_test.mock_idleRtTestCaseRRftmain(((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyts "  PK™e[ F77test_formatparagraph.pyonu[ {fc@s7ddlZddlmZddlmZddlmZmZddl m Z dej fdYZ dej fd YZ d ej fd YZd ej fd YZdej fdYZdddYZdddYZdej fdYZedkr3ejddddndS(iN(tFormatParagraph(t EditorWindow(tTktText(trequirest Is_Get_TestcBsGeZdZdZdZdZdZdZdZdZ dZ RS( sTest the is_ and get_ functionss# This is a commentsThis is not a comments# This is a comment s # This is a comments This is not a commentcCsI|jtjd|jtjd|jtj|jdS(Nts (t assertTruetfpt is_all_whitet assertFalset test_comment(tself((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_is_all_whitescCsq|j}|tj|jd|tj|jd|tj|jd|tj|jddS(NRs (t assertEqualRt get_indentR ttrailingws_commenttleadingws_commenttleadingws_nocomment(R tEqual((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_get_indents  cCs|j}|tj|jd|tj|jd|tj|jd|tj|jd|tj|jddS(Nt#s #s R(RRtget_comment_headerR RRRttest_nocomment(R R((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_get_comment_headers  ( t__name__t __module__t__doc__R RRRRR RR(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR s  tFindTestcBs8eZdZedZdZdZdZRS(s`Test the find_paragraph function in FormatParagraph. Using the runcase() function, find_paragraph() is called with 'mark' set at multiple indexes before and inside the test paragraph. It appears that code with the same indentation as a quoted string is grouped as part of the same paragraph, which is probably incorrect behavior. cCs ddlm}||_dS(Ni(R(tidlelib.idle_test.mock_tkRttext(tclsR((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt setUpClass2sc Cs|j}|jd|xtd|D]v}t|jd|jdd}xGd|d|fD]2}d||f}|jtj|||qiWq)W|j dddS( Ns1.0is%d.endt.iis%d.%dtend( RtinserttrangetinttindextsplitRRtfind_paragraphtdelete( R t inserttexttstoplinetexpectedRtlinet linelengthtcolt tempindex((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pytruncase7s &$c Csdd}|j|dddd|dd!fd}|j|d d d d|d d !fd}|j|d d d d|d d!fd}|j|dd dd|d d!fd}|j|dd dd|d d!fd}|j|dd dd|d d!fd}|j|dd dd|d d!fd}|j|dd dd|d d!fdS(Ns;# Comment block with no blank lines before # Comment line is1.0s3.0Rii:sG # Comment block with whitespace line before and after # Comment line is2.0s4.0iiFsS # Indented comment block with whitespace before and after # Comment line s #iRs # Single line comment is4 # Single line comment with leading whitespace i3s0 # Comment immediately followed by code x = 42 i(s= # Indented comment immediately followed by code x = 42 i5s= # Comment immediately followed by indented code x = 42 i1(R1(R tcomment((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_find_commentDs &&&&&&&c Csd}|j|dddd|dd!fd}|j|d d d d|d d !fd}|j|d d d d|d d!fd}|j|dd dd|d d!fd}|j|dd dd|d d!fdS(Ns6"""String with no blank lines before String line """ is1.0s4.0Rii5sC """String with whitespace line before and after String line. """ is2.0s5.0iiBsV """Indented string with whitespace before and after Comment string. """ s iUs """Single line string.""" is3.0is8 """Single line string with leading whitespace.""" i7(R1(R t teststring((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_find_paragraphzs&&&&(RRRt classmethodR R1R3R5(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR(s  6tReformatFunctionTestcBseZdZdZRS(s?Test the reformat_paragraph function without the editor window.cCs*|j}tj}d}||ddd||ddd|||dd|||dd|||d d |||d d |||d dd }|||dd|||dd|||d d|||d d|||d d dS(Ns O hello worldt isHello worldis Hello worlds O hello worldiis O hello worldi i s O hello worlds O hello worlds O hello world(RRtreformat_paragraph(R Rtreformthw((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_reformat_paragraphs   (RRRR<(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR7stReformatCommentTestcBseZdZdZRS(s=Test the reformat_comment function without the editor window.cCsi|j}d}tj|dd}d}|||d}tj|dd}d}|||dS(Nsu """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""iFs sy """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""sm# this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?Rso# this is a test of a reformat for a triple quoted string will it # reformat to less than 70 characters for me?(RRtreformat_comment(R Rt test_stringtresultR,R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_reformat_comments  (RRRRA(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR=stFormatClassTestcBseZdZRS(cCsCtjd}|j|jd|j|j|jddS(Nteditor(RRRteditwintclosetNone(R tinstance((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_init_closes (RRRH(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRBst TextWrappercBs,eZdZdZdZdZRS(cCstd||_dS(Ntmaster(RR(R RJ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt__init__scCst|j|S(N(tgetattrR(R tname((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt __getattr__scCsdS(N((R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pytundo_block_startRcCsdS(N((R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pytundo_block_stopR(RRRKRNRORP(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRIs   tEditorcBseZdZejjZRS(cCst||_dS(N(RIR(R troot((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRKs(RRRKRtget_selection_indicestim_func(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRQs tFormatEventTestcBsbeZdZdZdZdZedZedZdZ dZ dZ d Z RS( sTest the formatting of text inside a Text widget. This is done with FormatParagraph.format.paragraph_event, which calls functions in the module as appropriate. sv '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?''' s '''The first line is under the max width. The second line's length is way over the max width. It goes on and on until it is over 100 characters long. Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it. ''' s,# The first line is under the max width. # The second line's length is way over the max width. It goes on and on until it is over 100 characters long. # Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it. # The fourth line is short like the first line.cCsPtdt|_td|j}|jj|_tj|j|_dS(NtguiRR( RRRRRQRRRtformat_paragraph_eventt formatter(RRC((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR s   cCs#|`|`|jj|`dS(N(RRXRRtdestroy(R((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt tearDownClasss  cCsV|jjdd|jd|j|jjddd|jjdddS(Ns1.0s Short line tDummyR#R"(RR#RXRtgetR)(R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_short_lines cCs|j}|jd|j|jdd|jddd|jdd}d}|j|||jdd|jd|j|jdd d |jddd|jdd}d }|j|||jdddS( Ns1.0R#tParameterDoesNothingtlimitiFsz '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?''' R"tsels1.11s1.endsv '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?'''( RR#R?tmark_setRXR\RR)ttag_add(R RR@R,((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_long_line!s cCs~|j}|jd|j|jddd|jddd|jdd}d }|j|||jdd dS( Ns1.0R`s2.0s4.0R^R_iFR#s The second line's length is way over the max width. It goes on and on until it is over 100 characters long. Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it. R"(RR#tmultiline_test_stringRbRXR\RR)(R RR@R,((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_multiple_lines<s cCs|j}|jd|j|jddd|jdd}d}|j|||jdd|jd|j|jdd d |jddd|jdd}d }|j|||jdddS( Ns1.0R^R_iFR#s/# The first line is under the max width. The second line's length is # way over the max width. It goes on and on until it is over 100 # characters long. Same thing with the third line. It is also way over # the max width, but FormatParagraph will fix it. The fourth line is # short like the first line. R"R`s2.0s3.0s# The first line is under the max width. # The second line's length is way over the max width. It goes on and # on until it is over 100 characters long. (RR#tmultiline_test_commentRXR\RR)Rb(R RR@R,((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_comment_blockKs ( RRRR?RdRfR6R RZR]RcReRg(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRUs    t__main__t verbosityitexit(((tunittesttidlelibRRtidlelib.EditorWindowRtTkinterRRttest.test_supportRtTestCaseRRR7R=RBRIRQRURtmain(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyts w PK™e[c$' test_config_name.pynu["""Unit tests for idlelib.configSectionNameDialog""" import unittest from idlelib.idle_test.mock_tk import Var, Mbox from idlelib import configSectionNameDialog as name_dialog_module name_dialog = name_dialog_module.GetCfgSectionNameDialog class Dummy_name_dialog(object): # Mock for testing the following methods of name_dialog name_ok = name_dialog.name_ok.im_func Ok = name_dialog.Ok.im_func Cancel = name_dialog.Cancel.im_func # Attributes, constant or variable, needed for tests used_names = ['used'] name = Var() result = None destroyed = False def grab_release(self): pass def destroy(self): self.destroyed = True # name_ok calls Mbox.showerror if name is not ok orig_mbox = name_dialog_module.tkMessageBox showerror = Mbox.showerror class ConfigNameTest(unittest.TestCase): dialog = Dummy_name_dialog() @classmethod def setUpClass(cls): name_dialog_module.tkMessageBox = Mbox @classmethod def tearDownClass(cls): name_dialog_module.tkMessageBox = orig_mbox def test_blank_name(self): self.dialog.name.set(' ') self.assertEqual(self.dialog.name_ok(), '') self.assertEqual(showerror.title, 'Name Error') self.assertIn('No', showerror.message) def test_used_name(self): self.dialog.name.set('used') self.assertEqual(self.dialog.name_ok(), '') self.assertEqual(showerror.title, 'Name Error') self.assertIn('use', showerror.message) def test_long_name(self): self.dialog.name.set('good'*8) self.assertEqual(self.dialog.name_ok(), '') self.assertEqual(showerror.title, 'Name Error') self.assertIn('too long', showerror.message) def test_good_name(self): self.dialog.name.set(' good ') showerror.title = 'No Error' # should not be called self.assertEqual(self.dialog.name_ok(), 'good') self.assertEqual(showerror.title, 'No Error') def test_ok(self): self.dialog.destroyed = False self.dialog.name.set('good') self.dialog.Ok() self.assertEqual(self.dialog.result, 'good') self.assertTrue(self.dialog.destroyed) def test_cancel(self): self.dialog.destroyed = False self.dialog.Cancel() self.assertEqual(self.dialog.result, '') self.assertTrue(self.dialog.destroyed) if __name__ == '__main__': unittest.main(verbosity=2, exit=False) PK™e[btest_idlehistory.pyonu[ {fc@sddlZddlmZddlZddlmZddlmZddl m Z ddl m Z dZ dZdejfd YZd dd YZd ejfd YZedkrejddddndS(iN(trequires(tText(tHistory(tidleConfsa = 7sb = at StoreTestcBsJeZdZedZdZdZdZdZdZ RS(s7Tests History.__init__ and History.store with mock TextcCs"t|_t|j|_dS(N(tmkTextttextRthistory(tcls((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt setUpClasss cCs#|jjddg|j_dS(Ns1.0tend(RtdeleteR(tself((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttearDownscCs|j|jj|j|j|jjg|j|jj|j|jj|j|jjtj ddddddS(NtmainRtcyclicitbool( tassertIsRRt assertEqualt assertIsNonetprefixtpointerRRt GetOption(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt test_inits cCsP|jjd|j|jjg|jjd|j|jjgdS(Ntas a (RtstoreR(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_store_short!scCs|jjt|j|jjtg|jjt|j|jjttg|jjt|j|jjttgdS(N(RRtline1Rtline2(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_store_dup's cCsRt|j_d|j_|jjt|j|jj|j|jjdS(Ni(RRRRRRR(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_store_reset/s   ( t__name__t __module__t__doc__t classmethodR R RRRR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyR s    t TextWrappercBs#eZdZdZdZRS(cCstd||_t|_dS(Ntmaster(ttkTextRtFalset_bell(R R$((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt__init__8scCst|j|S(N(tgetattrR(R tname((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt __getattr__;scCs t|_dS(N(tTrueR'(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pytbell=s(RR R(R+R-(((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyR#7s  t FetchTestcBseZdZedZdZedZedZdZ dZ dZ dZ d Z d Zd Zd Zd ZRS(s-Test History.fetch with wrapped tk.Text. cCs*tdtj|_|jjdS(Ntgui(RttktTktroottwithdraw(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyR Cs cCskt|j|_}|jdd|jdd|jddt||_tt g|j_dS(Ns1.0s>>> tiomarks1.4tleft( R#R2Rtinserttmark_sett mark_gravityRRRR(R R((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pytsetUpIs cCs|jj|`dS(N(R2tdestroy(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt tearDownClassQs cCs|j}|j||j}||jjdd|||jj||rct|j_n||j|||j|||jj dddddS(NR4send-1cR6s==i( RtfetchRRtgetR'R&RRtcompare(R treversetlineRtindexR-RtEqual((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt fetch_testVs   cCsRd}|j}|tt|d|tt|d|t|dddtdS(NtiiR-(RCR,RRtNone(R Rttest((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_prev_cyclicfs  cCsRd}|j}|tt|d|tt|d|t|dddtdS(NRDiiR-(RCR&RRRER,(R RRF((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_next_cyclicms  cCsOd}|jjd||jtt|d|jt|dddtdS(NRR4iR-(RR6RCR,RRE(R R((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_prev_prefixuscCsOd}|jjd||jtt|d|jt|dddtdS(NRR4iR-(RR6RCR&RRER,(R R((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_next_prefix{scCs^d}t|j_|j}|tt|d|tt|d|tt|ddtdS(NRDiiR-(R&RRRCR,RR(R RRF((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_prev_noncyclics   cCs}d}t|j_|j}|t|dddt|tt|d|t|dddt|t|dddtdS(NRDR-i(R&RRRCRER,R(R RRF((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_next_noncyclics  cCsF|jjdt|jjdd|jttdddtdS(NR?R6R4R-(RR<R,RR7RCRRE(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_cursor_movescCsS|jjdt|jjdd|jjdd|jttdddS(NR?R4R6sa =i(RR<R,RR R6RCR(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_editscCsP|jjd|j|jjd|jjd|j|jjddS(Ns dummy eventi(Rt history_prevRRt history_nextRE(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_history_prev_nexts(RR R!R"R R9R;R&RCRGRHRIRJRKRLRMRNRQ(((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyR.@s         t__main__t verbosityitexit((tunittestttest.test_supportRtTkinterR0RR%tidlelib.idle_test.mock_tkRtidlelib.IdleHistoryRtidlelib.configHandlerRRRtTestCaseRR#R.RR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyts  * g PK™e[k test_grep.pyonu[ {fc@sdZddlZddlmZmZddlmZddlmZddl Z eddZ ddd YZ e Z d dd YZ e Zd ejfd YZdejfdYZdejfdYZedkr ejdddendS(s !Changing this line will break Test_findfile.test_found! Non-gui unit tests for idlelib.GrepDialog methods. dummy_command calls grep_it calls findfiles. An exception raised in one method will fail callers. Otherwise, tests are mostly independent. *** Currently only test grep_it. iN(tcaptured_stdouttfindfile(tVar(t GrepDialogsidlelib/idle_tests /test_grep.pytDummy_searchenginecBseZdZdZRS(sGrepDialog.__init__ calls parent SearchDiabolBase which attaches the passed in SearchEngine instance as attribute 'engine'. Only a few of the many possible self.engine.x attributes are needed here. cCs|jS(N(t_pat(tself((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pytgetpats(t__name__t __module__t__doc__R(((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyRst Dummy_grepcBs;eZejjZejjZeeZe Z dZ RS(cCsdS(N((R((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pytclose"s( RR Rtgrep_ittim_funct findfilesRtFalsetrecvart searchenginetengineR (((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyR s    t FindfilesTestcBseZRS((RR (((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyR'st Grep_itTestcBs#eZdZdZdZRS(cCsZ|tj_t }tjtj|tWdQX|jj d}|j |S(Ns ( tgrepRRRR tretcompilet__file__tgetvaluetsplittpop(Rtpattstlines((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pytreport3s    cCs[dd}|j|}|jt|d|j||d|j|dddS(Nsxyz*iiiisNo hits.(R t assertEqualtlentassertIn(RRR((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyt test_unfound;s  cCsd}|j|}|jt|d|j||d|jd|d|jd|d|j|djd dS( Ns<""" !Changing this line will break Test_findfile.test_found!iispy: 1:it2iis(Hint:(R R!R"R#t assertTruet startswith(RRR((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyt test_foundBs(RR R R$R((((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyR.s  tDefault_commandTestcBseZRS((RR (((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyR)Lst__main__t verbosityitexit(((R tunittestttest.test_supportRRtidlelib.idle_test.mock_tkRtidlelib.GrepDialogRRRRRR RtTestCaseRRR)RtmainR(((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyts     PK™e[^c/c/test_calltips.pycnu[ {fc@sddlZddljZejZddlZddlZddlZdZde fdYZ e Z ej Z dejfdYZdejfdYZd ejfd YZed krejd d dendS(iNttTCcBseZdZdZddZde_dZde_ddZde_dZd e_d Z d e _dd Z d e _dZ de _dZ de _e dZedZRS(tdocs(ai=None, *args)cGsdS(RN((tselftaitb((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyt__init__Rs(self, ai=None, *args)cCsdS(RN((R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt1Rs(self)cCsdS(RN((RRR((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt2Rs(self, ai, b=None)cGsdS(RN((RRtargs((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt3Rs(self, ai, *args)cGsdS(RN((RR ((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt4Rs (self, *args)cOsdS(RN((RRRR tkw((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt5Rs#(self, ai, b=None, *args, **kwargs)cCsdS(RN((tnoR((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytt6Rs (no, self)cCsdS(RN((Rtci((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyt__call__Rs (self, ci)cCsdS(RN((tclsta((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytcmRcCsdS(RN((R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytsm!RN(t__name__t __module__t__doc__ttiptNoneRRRR R R RRt classmethodRt staticmethodR(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR s(                tGet_signatureTestcBskeZdZdZdZdZdZdZdZdZ dZ d Z d Z RS( csdtfdY}dd dY}fd}|jdk r^||d|jn|tjd|tjdd }|tj||gj|||j||tjd ||tdS( NtListcBseZdZRS(s List() doc(RRR(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR3stSBcBseZdZRS(N(RRRR(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR5scsjt||dS(N(t assertEqualt signature(tobjtout(R(s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytgtest7ss() s=T.__new__(S, ...) -> a new object with type S, a subtype of Ts>x.__init__(...) initializes x; see help(type(x)) for signatures(L.append(object) -- append object to ends,() instancemethod(function, instance, class)(( tlistRRt__new__Rtappendttypest MethodTypet default_tip(RRRR$t append_doc((Rs7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyt test_builtins/s  cCs2tjjdk r.|jttjdndS(Ns(width=70, initial_indent='', subsequent_indent='', expand_tabs=True, replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, drop_whitespace=True, break_on_hyphens=True)(ttextwrapt TextWrapperRRR R!(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_signature_wrapHscCsCd}dd|_|jt|ddtjdddS(NcSsdS(N((((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytfQRRi,s() is...(RR R!tctt _MAX_COLS(RR0((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_docline_truncationPs  cCsk|jttdd}d}|ddd|_|jt|d|tjddd dS( NsX() list() -> new empty list list(iterable) -> new list initialized from iterable's itemscSsdS(N((((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR0\ssa b c d i,teR0s() is...(R R!R%RR1R2(RR0ts((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_multiline_docstringUs cCsd}d|_dd}d|_d}d|_d}d|_dd }d |_|jdk rud nd }x=|||||tfD]#}|jt||j|qWdS( NcSsdS(RN((((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRdRs()cSsdS(RN((RR((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRfRs (a, b=None)cWsdS(RN((RR ((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR hRs (a, *args)cWsdS(RN((R ((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR jRs(*args)c_sdS(RN((RRR tkwds((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR lRs(a, b=None, *args, **kwargs)s docR(RRRRR R!(RRRR R R Rtfunc((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_functionscs          cCstjdk rdnd}xUtjtjtjtjtjtjtj fD]#}|j t ||j |qLW|j t tj d||j t tjd|dS(Ns docRs(a)s(b)(RRRRRR R R RRR R!RRR(RRtmeth((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyt test_methodsss 7!cCstjdk rdnd}xstjdftjdftjdftjdftdftjdffD]&\}}|j t |||qgWdS(Ns docRs()s(*args)s(self)s(ci)s(a)( RRRttcRR RRRR R!(RRR:tmtip((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_bound_methodszs'1cCsdd dY}d}d}|}|jt|jd|jt|jd|jt|jd|jt|jd|jt|d|jt|ddS( NtCcBseZdZdZRS(cWsdS(N((R ((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytm1Rc[sdS(N((R7((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytm2R(RRR@RA(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR?s c_sdS(N((R tkwargsRtk((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytf1Rc_sdS(N((R RBtargs1tkwargs1RRC((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytf2Rs(*args)s (**kwargs)s!(args, kwargs, *args1, **kwargs1)s1(args, kwargs, args1, kwargs1, *args2, **kwargs2)((R R!R@RA(RR?RDRGtc((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_starred_parameters   cCs^d}|t_|jt|d|jttjd|jttjddS(NcSsdS(N((R5((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pytndRs(s)s()(RRJR R!R<(RRJ((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_no_docstrings   cCsdtfdY}d|fdY}xT|df|df|df|dffD]"\}}|jt||q]WdS(NtNoCallcBseZdZRS(cSs tdS(N(t BaseException(Rtname((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyt __getattr__s(RRRO(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRLstCallcBseZdZRS(cSsdS(N((RR((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRs(RRR(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRPss()Rs(ci)(tobjectR R!(RRLRPR:R=((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_attribute_exceptions (cCs=x6ddddgifD]}|jt|dqWdS(Nigt0R(R R!(RR"((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_non_callabless( RRR,R/R3R6R9R;R>RIRKRRRT(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR's          tGet_entityTestcBseZdZdZRS(cCs|jtjddS(Ns1//0(t assertIsNonetCTit get_entity(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_bad_entityscCs|jtjdtdS(Ntint(tassertIsRWRXRZ(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_good_entitys(RRRYR\(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyRUs tPy2TestcBseZdZRS(cBsBejejdddUWdQX|jeeddS(Ntignoresdef f((a,b), c=0.0): passs(, c=0.0)(twarningstcatch_warningst simplefilterR R!R0(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyttest_paramtuple_floats  (RRRb(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyR]st__main__t verbosityitexit(tunittesttidlelib.CallTipstCallTipsR1RWR-R(R_R*RQRR<t get_arg_textR!tTestCaseRRUR]RtmaintFalse(((s7/usr/lib64/python2.7/idlelib/idle_test/test_calltips.pyts        PK™e[I+ test_warning.pyonu[ {fc@sdZddlZddlmZddlZejZdejkZddlm Z ddlm Z dZ e dZ d ejfd YZd ejfd YZed krejdddendS(s6Test warnings replacement in PyShell.py and run.py. This file could be expanded to include traceback overrides (in same two modules). If so, change name. Revise if output destination changes (http://bugs.python.org/issue18318). Make sure warnings module is left unaltered (http://bugs.python.org/issue18081). iN(tcaptured_stderrtidle(trun(tPyShellsf Warning (from warnings module): File "test_warning.py", line 99 Line of code UserWarning: Test s>>> t RunWarnTestcBs,eZejeddZdZRS(s#Does not work when run within Idle.cCsZ|jtjttjt|jtjtjtjt|jtjtdS(N(tassertIstwarningst showwarningRtcapture_warningstTruetidle_showwarning_subproctFalse(tself((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyttest_showwarnings"s   c CsTtE}tjdtdd|d|jtj|jjWdQXdS(NtTeststest_warning.pyics Line of code(RRR t UserWarningt assertEqualtidlemsgt splitlinestgetvalue(R tf((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyt test_run_show*s (t__name__t __module__tunittesttskipIftrunning_in_idleR R(((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyR st ShellWarnTestcBs5eZejeddZdZdZRS(s#Does not work when run within Idle.cCsZ|jtjttjt|jtjtjtjt|jtjtdS(N(RRRtshellRR tidle_showwarningR (R ((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyR 3s   cCs/tjdtddd}|jt|dS(NRstest_warning.pyics Line of code(Rtidle_formatwarningRRR(R ts((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyttest_idle_formatter;sc CsTtE}tjdtdd|d|jtj|jjWdQXdS(NRstest_warning.pyics Line of code(RRRRRtshellmsgRR(R R((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyttest_shell_showAs (RRRRRR R R"(((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyR1s t__main__t verbosityitexit(t__doc__Rttest.test_supportRRRRRtidlelibRRRRR!tTestCaseRRtmainR (((s6/usr/lib64/python2.7/idlelib/idle_test/test_warning.pyts      PK™e[ __init__.pycnu[ {fc@s#dZddlmZdZdS(sidlelib.idle_test is a private implementation of test.test_idle, which tests the IDLE application as part of the stdlib test suite. Run IDLE tests alone with "python -m test.test_idle". This package and its contained modules are subject to change and any direct use is at your own risk. i(tdirnamecCsMtt}tt|}|jd|ddd|}|j||S(Nt start_dirtpatternstest*.pyt top_level_dir(Rt__file__tdiscovertaddTests(tloadertstandard_testsRtthis_dirttop_dirt package_tests((s2/usr/lib64/python2.7/idlelib/idle_test/__init__.pyt load_tests s    N(t__doc__tos.pathRR (((s2/usr/lib64/python2.7/idlelib/idle_test/__init__.pytsPK™e[̏d44test_hyperparser.pynu["""Unittest for idlelib.HyperParser""" import unittest from test.test_support import requires from Tkinter import Tk, Text from idlelib.EditorWindow import EditorWindow from idlelib.HyperParser import HyperParser class DummyEditwin: def __init__(self, text): self.text = text self.indentwidth = 8 self.tabwidth = 8 self.context_use_ps1 = True self.num_context_lines = 50, 500, 1000 _build_char_in_string_func = EditorWindow._build_char_in_string_func.im_func is_char_in_string = EditorWindow.is_char_in_string.im_func class HyperParserTest(unittest.TestCase): code = ( '"""This is a module docstring"""\n' '# this line is a comment\n' 'x = "this is a string"\n' "y = 'this is also a string'\n" 'l = [i for i in range(10)]\n' 'm = [py*py for # comment\n' ' py in l]\n' 'x.__len__\n' "z = ((r'asdf')+('a')))\n" '[x for x in\n' 'for = False\n' ) @classmethod def setUpClass(cls): requires('gui') cls.root = Tk() cls.root.withdraw() cls.text = Text(cls.root) cls.editwin = DummyEditwin(cls.text) @classmethod def tearDownClass(cls): del cls.text, cls.editwin cls.root.destroy() del cls.root def setUp(self): self.text.insert('insert', self.code) def tearDown(self): self.text.delete('1.0', 'end') self.editwin.context_use_ps1 = True def get_parser(self, index): """ Return a parser object with index at 'index' """ return HyperParser(self.editwin, index) def test_init(self): """ test corner cases in the init method """ with self.assertRaises(ValueError) as ve: self.text.tag_add('console', '1.0', '1.end') p = self.get_parser('1.5') self.assertIn('precedes', str(ve.exception)) # test without ps1 self.editwin.context_use_ps1 = False # number of lines lesser than 50 p = self.get_parser('end') self.assertEqual(p.rawtext, self.text.get('1.0', 'end')) # number of lines greater than 50 self.text.insert('end', self.text.get('1.0', 'end')*4) p = self.get_parser('54.5') def test_is_in_string(self): get = self.get_parser p = get('1.0') self.assertFalse(p.is_in_string()) p = get('1.4') self.assertTrue(p.is_in_string()) p = get('2.3') self.assertFalse(p.is_in_string()) p = get('3.3') self.assertFalse(p.is_in_string()) p = get('3.7') self.assertTrue(p.is_in_string()) p = get('4.6') self.assertTrue(p.is_in_string()) def test_is_in_code(self): get = self.get_parser p = get('1.0') self.assertTrue(p.is_in_code()) p = get('1.1') self.assertFalse(p.is_in_code()) p = get('2.5') self.assertFalse(p.is_in_code()) p = get('3.4') self.assertTrue(p.is_in_code()) p = get('3.6') self.assertFalse(p.is_in_code()) p = get('4.14') self.assertFalse(p.is_in_code()) def test_get_surrounding_bracket(self): get = self.get_parser def without_mustclose(parser): # a utility function to get surrounding bracket # with mustclose=False return parser.get_surrounding_brackets(mustclose=False) def with_mustclose(parser): # a utility function to get surrounding bracket # with mustclose=True return parser.get_surrounding_brackets(mustclose=True) p = get('3.2') self.assertIsNone(with_mustclose(p)) self.assertIsNone(without_mustclose(p)) p = get('5.6') self.assertTupleEqual(without_mustclose(p), ('5.4', '5.25')) self.assertTupleEqual(without_mustclose(p), with_mustclose(p)) p = get('5.23') self.assertTupleEqual(without_mustclose(p), ('5.21', '5.24')) self.assertTupleEqual(without_mustclose(p), with_mustclose(p)) p = get('6.15') self.assertTupleEqual(without_mustclose(p), ('6.4', '6.end')) self.assertIsNone(with_mustclose(p)) p = get('9.end') self.assertIsNone(with_mustclose(p)) self.assertIsNone(without_mustclose(p)) def test_get_expression(self): get = self.get_parser p = get('4.2') self.assertEqual(p.get_expression(), 'y ') p = get('4.7') with self.assertRaises(ValueError) as ve: p.get_expression() self.assertIn('is inside a code', str(ve.exception)) p = get('5.25') self.assertEqual(p.get_expression(), 'range(10)') p = get('6.7') self.assertEqual(p.get_expression(), 'py') p = get('6.8') self.assertEqual(p.get_expression(), '') p = get('7.9') self.assertEqual(p.get_expression(), 'py') p = get('8.end') self.assertEqual(p.get_expression(), 'x.__len__') p = get('9.13') self.assertEqual(p.get_expression(), "r'asdf'") p = get('9.17') with self.assertRaises(ValueError) as ve: p.get_expression() self.assertIn('is inside a code', str(ve.exception)) p = get('10.0') self.assertEqual(p.get_expression(), '') p = get('11.3') self.assertEqual(p.get_expression(), '') p = get('11.11') self.assertEqual(p.get_expression(), 'False') if __name__ == '__main__': unittest.main(verbosity=2) PK™e[}J0J0 mock_tk.pycnu[ {fc@sdZdefdYZdefdYZdefdYZdefdYZd d lmZd efd YZd S(sClasses that replace tkinter gui objects used by an object being tested. A gui object is anything with a master or parent parameter, which is typically required in spite of what the doc strings say. tEventcBseZdZdZRS(sMinimal mock with attributes for testing event handlers. This is not a gui object, but is used as an argument for callbacks that access attributes of the event passed. If a callback ignores the event, other than the fact that is happened, pass 'event'. Keyboard, mouse, window, and other sources generate Event instances. Event instances have the following attributes: serial (number of event), time (of event), type (of event as number), widget (in which event occurred), and x,y (position of mouse). There are other attributes for specific events, such as keycode for key events. tkinter.Event.__doc__ has more but is still not complete. cKs|jj|dS(s,Create event with attributes needed for testN(t__dict__tupdate(tselftkwds((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt__init__s(t__name__t __module__t__doc__R(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyRs tVarcBs2eZdZddddZdZdZRS(s)Use for String/Int/BooleanVar: incompletecCs||_||_||_dS(N(tmastertvaluetname(RR R R ((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyRs  cCs ||_dS(N(R (RR ((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytsetscCs|jS(N(R (R((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytget!sN(RRRtNoneRR R(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR s t Mbox_funccBs#eZdZddZdZRS(sGeneric mock for messagebox functions, which all have the same signature. Instead of displaying a message box, the mock's call method saves the arguments as instance attributes, which test functions can then examime. The test can set the result returned to ask function cCs ||_dS(N(tresult(RR((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR+scOs+||_||_||_||_|jS(N(ttitletmessagetargsRR(RRRRR((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt__call__-s     N(RRRRRR(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR$s tMboxcBsVeZdZeZeZeZeZeZeZ eZ eZ RS(s5Mock for tkinter.messagebox with an Mbox_func for each function. This module was 'tkMessageBox' in 2.x; hence the 'import as' in 3.x. Example usage in test_module.py for testing functions in module.py: --- from idlelib.idle_test.mock_tk import Mbox import module orig_mbox = module.tkMessageBox showerror = Mbox.showerror # example, for attribute access in test methods class Test(unittest.TestCase): @classmethod def setUpClass(cls): module.tkMessageBox = Mbox @classmethod def tearDownClass(cls): module.tkMessageBox = orig_mbox --- For 'ask' functions, set func.result return value before calling the method that uses the message function. When tkMessageBox functions are the only gui alls in a method, this replacement makes the method gui-free, ( RRRRt askokcancelt askquestiontaskretrycanceltaskyesnotaskyesnocancelt showerrortshowinfot showwarning(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR5s       i(tTclErrortTextcBseZdZdidZdZddZdZdZddZ ddZ d Z d Z d Z dd Zd ZdZdZddddZRS(sA semi-functional non-gui replacement for tkinter.Text text editors. The mock's data model is that a text is a list of -terminated lines. The mock adds an empty string at the beginning of the list so that the index of actual lines start at 1, as with Tk. The methods never see this. Tk initializes files with a terminal that cannot be deleted. It is invisible in the sense that one cannot move the cursor beyond it. This class is only tested (and valid) with strings of ascii chars. For testing, we are not concerned with Tk Text's treatment of, for instance, 0-width characters or character + accent. cKsddg|_dS(sInitialize mock, non-gui, text-only Text widget. At present, all args are ignored. Almost all affect visual behavior. There are just a few Text-only options that affect text behavior. ts N(tdata(RR tcnftkw((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyRgscCsd|j|ddS(sAReturn string version of index decoded according to current text.s%s.%stendflagi(t_decode(Rtindex((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR'osicCsqt|ttfr$t|}ny|j}Wn!tk rWtd|nXt|jd}|dkr|t|j|dfS|dkr|j |S|j d\}}t |}|dkrdS||kr|j |St|j|d}|j ds'|dkr1||fSt |}|dkrRd}n||krg|}n||fS( s7Return a (line, char) tuple of int indexes into self.data. This implements .index without converting the result back to a string. The result is contrained by the number of lines and linelengths of self.data. For many indexes, the result is initially (1, 0). The input index may have any of several possible forms: * line.char float: converted to 'line.char' string; * 'line.char' string, where line and char are decimal integers; * 'line.char lineend', where lineend='lineend' (and char is ignored); * 'line.end', where end='end' (same as above); * 'insert', the positions before terminal ; * 'end', whose meaning depends on the endflag passed to ._endex. * 'sel.first' or 'sel.last', where sel is a tag -- not implemented. sbad text index "%s"itinserttendt.is lineend(ii( t isinstancetfloattbyteststrtlowertAttributeErrorRtlenR"t_endextsplittinttendswith(RR'R%tlastlinetlinetchart linelength((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR&ss4              cCsNt|j}|dkr%|dfS|d8}|t|j||fSdS(sReturn position for 'end' or line overflow corresponding to endflag. -1: position before terminal ; for .insert(), .delete 0: position after terminal ; for .get, .delete index 1 1: same viewed as beginning of non-existent next line (for .index) iiN(R1R"(RR%tn((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR2s    cCs|s dS|jt}|dddkr=|jdn|j|d\}}|j|| }|j||}||d|j|<|d|j|d|d+|j|t|dc|7s>=s==s!=s=bad comparison operator "%s": must be <, <=, ==, >=, >, or !=(R&R(RRCtopRDtline1tchar1tline2tchar2((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytcompares  " " " "  cCsdS(s.Set mark *name* before the character at index.N((RR R'((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytmark_set scGsdS(sDelete all marks in markNames.N((Rt markNames((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt mark_unsetR!cCsdS(sARemove tag tagName from all characters between index1 and index2.N((RttagNameRCRD((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt tag_removescCsdS(s2Adjust the view of the text according to scan_markN((Rtxty((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt scan_dragtoR!cCsdS(s&Remember the current X, Y coordinates.N((RRYRZ((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt scan_markR!cCsdS(s8Scroll screen to make the character at INDEX is visible.N((RR'((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytsee!scCsdS(s>Bind to this widget at event sequence a call to function func.N((tsequencetfunctadd((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytbind(sN(RRRRRR'R&R2R(RRKRSRTRVRXR[R\R]Ra(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR Zs    3           N( RtobjectRR RRt_tkinterRR (((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyts  #PK™e[ - - test_io.pyonu[ {fc@sddlZddlZddlmZmZddlmZdefdYZ de e fdYZ de e fd YZ d e efd YZd dd YZdejfdYZdejfdYZdZedkrendS(iN(tPseudoInputFiletPseudoOutputFile(t test_supporttBasecBs>eZdZdZdZdZdZdZRS(cCsdt|jS(Ns%s:str(ttypet__name__(tself((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt__str__scCsdt|jS(Ns %s:unicode(RR(R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt __unicode__ scCsdS(Ni((R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt__len__ scCs tdS(Ntabc(titer(R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt__iter__scGsdt|jS(Ns%s:item(RR(Rtargs((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt __getitem__scGsdt|jS(Ns%s:slice(RR(RR ((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt __getslice__s(Rt __module__RRR R RR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRs      tScBseZRS((RR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRstUcBseZRS((RR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRstBAcBseZRS((RR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRst MockShellcBs>eZdZdZdZdZdZdZRS(cCs|jdS(N(treset(R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt__init__scGs|jj|dS(N(twrittentappend(RR ((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pytwrite"scCs |jjS(N(tlinestpop(R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pytreadline%scCsdS(N((R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pytclose(scCs g|_dS(N(R(R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyR+scCs t|ddd|_dS(Ni(tlistR(RR((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pytpush.s(RRRRRRRR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRs      tPseudeOutputFilesTestcBs5eZdZdZdZdZdZRS(cCst}t|dd}|j|tj|j|jd|j|j|j|j |j|j d|j |j |j |j|j |j|j |j|j |jdS(Ntstdoutsutf-8s(RRtassertIsInstancetiot TextIOBaset assertEqualtencodingt assertIsNoneterrorstnewlinestnamet assertFalsetclosedt assertTruetisattytreadabletwritabletseekable(Rtshelltf((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_misc3s cCst}t|dd}|jt|j|jt|j|jt|jd|jt|jd|jt|jddS(NR!sutf-8i( RRt assertRaisestIOErrortfilenottelltseektreadR(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyttest_unsupportedAs cCst}t|dd}|jd|j|jd g|j|jd|j|jd g|j|jd|j|jd g|j|jtd|j|jd g|jt|jddt|j|jt d|j|jd g|jt|jddt|j|jt d|j|jdg|jt|jddt |j|j t |j|j|jg|j t |jd|j|jg|j t |jdd|j|jgdS(NR!sutf-8ttestststutèstii{tspam(R<R!(ststR!(utèstR!(ststR!(ststR!(utèstR!(RRRR%RRRRtstrRRtunicodeR5t TypeError(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_writeJs:       ! ! ! cCst}t|dd}|jg|j|jg|j|jddg|j|jd dg|j|jddg|j|jddg|j|jddg|j|jddg|j|jtd g|j|jdg|jt|jd d t|j|jt d g|j|jdg|jt|jd d t|j|jt d g|j|jdg|jt|jd d t |j|j t |j|j|jg|j t |jd |j|jg|j t |jd g|j|jg|j t |jgg|j|jgdS(NR!sutf-8sone ttwoson stwuonè utwòststiutèsti{(sone R!(RBR!(son R!(stwR!(uonè R!(utwòR!(ststR!(ststR!(utèstR!(RRt writelinesR%RRRRR>RRR?R5R@(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyttest_writelinesksJ            ! ! ! cCst}t|dd}|j|j|jd|j|j|j|jt|jd|j |j dg|j|jt |jddS(NR!sutf-8R<txi(R<R!( RRR+R,RRR-R5t ValueErrorR%RR@(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_closes    (RRR4R;RARDRG(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyR 2s   ! )tPseudeInputFilesTestcBs>eZdZdZdZdZdZdZRS(cCst}t|dd}|j|tj|j|jd|j|j|j|j |j|j d|j |j |j |j|j |j|j |j|j |jdS(Ntstdinsutf-8s(RRR"R#R$R%R&R'R(R)R*R+R,R-R.R/R0R1(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyR4s cCst}t|dd}|jt|j|jt|j|jt|jd|jt|jd|jt|jdgdS(NRIsutf-8iRE( RRR5R6R7R8R9RRC(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyR;s cCs~t}t|dd}|jdddg|j|jd|jdddg|j|jdd|jdddg|j|jdd|jddddg|j|jd d |j|jd d |j|jd d|jddg|j|jdd|jt|jd|jt|jd|jt|jdddS(NRIsutf-8sone stwo tsone two isthree itonise ti s wo three ig?t1i(RRRR%R:tNoneR5R@(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_reads" cCst}t|dd}|jddddg|j|jd|j|jdd|j|jdd|jdg|j|jd|j|jd|jd d d g|j|jd |j|jd |jdddg|j|jd d |j|jdd|j|jdd|j|jdd|jddg|j|jdd|jt|jd|jt|jd|jt|jdddS(NRIsutf-8sone stwo sthree sfour isone two toneRBtthreeiRKites i iRJg?RL( RRRR%RRMR5R@t readlines(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_readlines, cCst}t|dd}|jdddg|j|jddg|jdddg|j|jdddg|jdddg|j|jdddg|jdddg|j|jdddg|jdddg|j|jddg|jdddg|j|jd ddg|jdddg|jt|jd |jt|jd |jt|jd d dS( NRIsutf-8sone stwo RJiiiig?RLi(RRRR%RRRMR5R@(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyttest_readliness$ cCst}t|dd}|jdddg|j|j|j|jd|j|j|j|j|jd|jt |jddS(NRIsutf-8sone stwo RJi( RRRR+R,R%RRR5R@(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRGs  (RRR4R;RNRSRTRG(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRHs     cCstjttdS(N(tsupportt run_unittestR RH(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_mainst__main__((tunittestR#tidlelib.PyShellRRR<RRUtobjectRR>RR?Rt bytearrayRRtTestCaseR RHRWR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyts  of  PK™e[G% test_textview.pynu['''Test the functions and main class method of textView.py.''' import unittest import os from test.test_support import requires from Tkinter import Tk from idlelib import textView as tv from idlelib.idle_test.mock_idle import Func from idlelib.idle_test.mock_tk import Mbox class TV(tv.TextViewer): # Use in TextViewTest transient = Func() grab_set = Func() wait_window = Func() class textviewClassTest(unittest.TestCase): @classmethod def setUpClass(cls): requires('gui') cls.root = Tk() cls.root.withdraw() @classmethod def tearDownClass(cls): cls.root.destroy() del cls.root def setUp(self): TV.transient.__init__() TV.grab_set.__init__() TV.wait_window.__init__() def test_init_modal(self): view = TV(self.root, 'Title', 'test text') self.assertTrue(TV.transient.called) self.assertTrue(TV.grab_set.called) self.assertTrue(TV.wait_window.called) view.Ok() def test_init_nonmodal(self): view = TV(self.root, 'Title', 'test text', modal=False) self.assertFalse(TV.transient.called) self.assertFalse(TV.grab_set.called) self.assertFalse(TV.wait_window.called) view.Ok() def test_ok(self): view = TV(self.root, 'Title', 'test text', modal=False) view.destroy = Func() view.Ok() self.assertTrue(view.destroy.called) del view.destroy # Unmask the real function. view.destroy() class ViewFunctionTest(unittest.TestCase): @classmethod def setUpClass(cls): requires('gui') cls.root = Tk() cls.root.withdraw() cls.orig_mbox = tv.tkMessageBox tv.tkMessageBox = Mbox @classmethod def tearDownClass(cls): cls.root.destroy() del cls.root tv.tkMessageBox = cls.orig_mbox del cls.orig_mbox def test_view_text(self): # If modal True, get tkinter error 'can't invoke "event" command'. view = tv.view_text(self.root, 'Title', 'test text', modal=False) self.assertIsInstance(view, tv.TextViewer) view.Ok() def test_view_file(self): test_dir = os.path.dirname(__file__) testfile = os.path.join(test_dir, 'test_textview.py') view = tv.view_file(self.root, 'Title', testfile, modal=False) self.assertIsInstance(view, tv.TextViewer) self.assertIn('Test', view.textView.get('1.0', '1.end')) view.Ok() # Mock messagebox will be used; view_file will return None. testfile = os.path.join(test_dir, '../notthere.py') view = tv.view_file(self.root, 'Title', testfile, modal=False) self.assertIsNone(view) if __name__ == '__main__': unittest.main(verbosity=2) PK™e[fMMtest_rstrip.pynu[import unittest import idlelib.RstripExtension as rs from idlelib.idle_test.mock_idle import Editor class rstripTest(unittest.TestCase): def test_rstrip_line(self): editor = Editor() text = editor.text do_rstrip = rs.RstripExtension(editor).do_rstrip do_rstrip() self.assertEqual(text.get('1.0', 'insert'), '') text.insert('1.0', ' ') do_rstrip() self.assertEqual(text.get('1.0', 'insert'), '') text.insert('1.0', ' \n') do_rstrip() self.assertEqual(text.get('1.0', 'insert'), '\n') def test_rstrip_multiple(self): editor = Editor() # Uncomment following to verify that test passes with real widgets. ## from idlelib.EditorWindow import EditorWindow as Editor ## from tkinter import Tk ## editor = Editor(root=Tk()) text = editor.text do_rstrip = rs.RstripExtension(editor).do_rstrip original = ( "Line with an ending tab \n" "Line ending in 5 spaces \n" "Linewithnospaces\n" " indented line\n" " indented line with trailing space \n" " ") stripped = ( "Line with an ending tab\n" "Line ending in 5 spaces\n" "Linewithnospaces\n" " indented line\n" " indented line with trailing space\n") text.insert('1.0', original) do_rstrip() self.assertEqual(text.get('1.0', 'insert'), stripped) if __name__ == '__main__': unittest.main(verbosity=2, exit=False) PK™e[`test_parenmatch.pynu["""Test idlelib.ParenMatch.""" # This must currently be a gui test because ParenMatch methods use # several text methods not defined on idlelib.idle_test.mock_tk.Text. import unittest from test.test_support import requires from Tkinter import Tk, Text from idlelib.ParenMatch import ParenMatch class Mock: # 2.7 does not have unittest.mock def __init__(self, *args, **kwargs): self.called = False def __call__(self, *args, **kwargs): self.called = True def reset_mock(self, *args, **kwargs): self.called = False def after(self, *args, **kwargs): pass class DummyEditwin: def __init__(self, text): self.text = text self.indentwidth = 8 self.tabwidth = 8 self.context_use_ps1 = True class ParenMatchTest(unittest.TestCase): @classmethod def setUpClass(cls): requires('gui') cls.root = Tk() cls.text = Text(cls.root) cls.editwin = DummyEditwin(cls.text) cls.editwin.text_frame = Mock() @classmethod def tearDownClass(cls): del cls.text, cls.editwin cls.root.destroy() del cls.root def tearDown(self): self.text.delete('1.0', 'end') def test_paren_expression(self): """ Test ParenMatch with 'expression' style. """ text = self.text pm = ParenMatch(self.editwin) pm.set_style('expression') text.insert('insert', 'def foobar(a, b') pm.flash_paren_event('event') self.assertIn('<>', text.event_info()) self.assertTupleEqual(text.tag_prevrange('paren', 'end'), ('1.10', '1.15')) text.insert('insert', ')') pm.restore_event() self.assertNotIn('<>', text.event_info()) self.assertEqual(text.tag_prevrange('paren', 'end'), ()) # paren_closed_event can only be tested as below pm.paren_closed_event('event') self.assertTupleEqual(text.tag_prevrange('paren', 'end'), ('1.10', '1.16')) def test_paren_default(self): """ Test ParenMatch with 'default' style. """ text = self.text pm = ParenMatch(self.editwin) pm.set_style('default') text.insert('insert', 'def foobar(a, b') pm.flash_paren_event('event') self.assertIn('<>', text.event_info()) self.assertTupleEqual(text.tag_prevrange('paren', 'end'), ('1.10', '1.11')) text.insert('insert', ')') pm.restore_event() self.assertNotIn('<>', text.event_info()) self.assertEqual(text.tag_prevrange('paren', 'end'), ()) def test_paren_corner(self): """ Test corner cases in flash_paren_event and paren_closed_event. These cases force conditional expression and alternate paths. """ text = self.text pm = ParenMatch(self.editwin) text.insert('insert', '# this is a commen)') self.assertIsNone(pm.paren_closed_event('event')) text.insert('insert', '\ndef') self.assertIsNone(pm.flash_paren_event('event')) self.assertIsNone(pm.paren_closed_event('event')) text.insert('insert', ' a, *arg)') self.assertIsNone(pm.paren_closed_event('event')) def test_handle_restore_timer(self): pm = ParenMatch(self.editwin) pm.restore_event = Mock() pm.handle_restore_timer(0) self.assertTrue(pm.restore_event.called) pm.restore_event.reset_mock() pm.handle_restore_timer(1) self.assertFalse(pm.restore_event.called) if __name__ == '__main__': unittest.main(verbosity=2) PK™e[sOtt README.txtnu[README FOR IDLE TESTS IN IDLELIB.IDLE_TEST 0. Quick Start Automated unit tests were added in 2.7 for Python 2.x and 3.3 for Python 3.x. To run the tests from a command line: python -m test.test_idle Human-mediated tests were added later in 2.7 and in 3.4. python -m idlelib.idle_test.htest 1. Test Files The idle directory, idlelib, has over 60 xyz.py files. The idle_test subdirectory should contain a test_xyz.py for each, where 'xyz' is lowercased even if xyz.py is not. Here is a possible template, with the blanks after '.' and 'as', and before and after '_' to be filled in. import unittest from test.support import requires import idlelib. as class _Test(unittest.TestCase): def test_(self): if __name__ == '__main__': unittest.main(verbosity=2) Add the following at the end of xyy.py, with the appropriate name added after 'test_'. Some files already have something like this for htest. If so, insert the import and unittest.main lines before the htest lines. if __name__ == "__main__": import unittest unittest.main('idlelib.idle_test.test_', verbosity=2, exit=False) 2. GUI Tests When run as part of the Python test suite, Idle GUI tests need to run test.test_support.requires('gui') (test.support in 3.x). A test is a GUI test if it creates a Tk root or master object either directly or indirectly by instantiating a tkinter or idle class. For the benefit of test processes that either have no graphical environment available or are not allowed to use it, GUI tests must be 'guarded' by "requires('gui')" in a setUp function or method. This will typically be setUpClass. To avoid interfering with other GUI tests, all GUI objects must be destroyed and deleted by the end of the test. The Tk root created in a setUpX function should be destroyed in the corresponding tearDownX and the module or class attribute deleted. Others widgets should descend from the single root and the attributes deleted BEFORE root is destroyed. See https://bugs.python.org/issue20567. @classmethod def setUpClass(cls): requires('gui') cls.root = tk.Tk() cls.text = tk.Text(root) @classmethod def tearDownClass(cls): del cls.text cls.root.destroy() del cls.root WARNING: In 2.7, "requires('gui') MUST NOT be called at module scope. See https://bugs.python.org/issue18910 Requires('gui') causes the test(s) it guards to be skipped if any of these conditions are met: - The tests are being run by regrtest.py, and it was started without enabling the "gui" resource with the "-u" command line option. - The tests are being run on Windows by a service that is not allowed to interact with the graphical environment. - The tests are being run on Linux and X Windows is not available. - The tests are being run on Mac OSX in a process that cannot make a window manager connection. - tkinter.Tk cannot be successfully instantiated for some reason. - test.support.use_resources has been set by something other than regrtest.py and does not contain "gui". Tests of non-GUI operations should avoid creating tk widgets. Incidental uses of tk variables and messageboxes can be replaced by the mock classes in idle_test/mock_tk.py. The mock text handles some uses of the tk Text widget. 3. Running Unit Tests Assume that xyz.py and test_xyz.py both end with a unittest.main() call. Running either from an Idle editor runs all tests in the test_xyz file with the version of Python running Idle. Test output appears in the Shell window. The 'verbosity=2' option lists all test methods in the file, which is appropriate when developing tests. The 'exit=False' option is needed in xyx.py files when an htest follows. The following command lines also run all test methods, including GUI tests, in test_xyz.py. (Both '-m idlelib' and '-m idlelib.idle' start Idle and so cannot run tests.) python -m idlelib.xyz python -m idlelib.idle_test.test_xyz The following runs all idle_test/test_*.py tests interactively. >>> import unittest >>> unittest.main('idlelib.idle_test', verbosity=2) The following run all Idle tests at a command line. Option '-v' is the same as 'verbosity=2'. (For 2.7, replace 'test' in the second line with 'test.regrtest'.) python -m unittest -v idlelib.idle_test python -m test -v -ugui test_idle python -m test.test_idle The idle tests are 'discovered' by idlelib.idle_test.__init__.load_tests, which is also imported into test.test_idle. Normally, neither file should be changed when working on individual test modules. The third command runs unittest indirectly through regrtest. The same happens when the entire test suite is run with 'python -m test'. So that command must work for buildbots to stay green. Idle tests must not disturb the environment in a way that makes other tests fail (issue 18081). To run an individual Testcase or test method, extend the dotted name given to unittest on the command line. python -m unittest -v idlelib.idle_test.test_xyz.Test_case.test_meth 4. Human-mediated Tests Human-mediated tests are widget tests that cannot be automated but need human verification. They are contained in idlelib/idle_test/htest.py, which has instructions. (Some modules need an auxiliary function, identified with # htest # on the header line.) The set is about complete, though some tests need improvement. To run all htests, run the htest file from an editor or from the command line with: python -m idlelib.idle_test.htest PK™e[rtest_pathbrowser.pyonu[ {fc@sddlZddlZddlZddlZddlmZdejfdYZedkr~ejddde ndS( iN(t PathBrowsertPathBrowserTestcBseZdZdZRS(cCstjd}|j|jd|jtjjtjjt j d}|j|j |t |j|j |dt dS(Ntis/Icons(RtDirBrowserTreeItemt GetSubListt assertEqualtGetTexttostpathtsplittabspathtidlelibt__file__t ispackagedirtTruetFalse(tselftdtdir((s:/usr/lib64/python2.7/idlelib/idle_test/test_pathbrowser.pyttest_DirBrowserTreeItem s  %cCsQtj}|j|jd|j}|jt|ttjdS(Nssys.path(RtPathBrowserTreeItemRRRtlentsysR(Rtptsub((s:/usr/lib64/python2.7/idlelib/idle_test/test_pathbrowser.pyttest_PathBrowserTreeItems  (t__name__t __module__RR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_pathbrowser.pyRs t__main__t verbosityitexit( tunittestRRR RtTestCaseRRtmainR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_pathbrowser.pyts     PK™e[A::test_autocomplete.pynu[import unittest from test.test_support import requires from Tkinter import Tk, Text import idlelib.AutoComplete as ac import idlelib.AutoCompleteWindow as acw from idlelib.idle_test.mock_idle import Func from idlelib.idle_test.mock_tk import Event class AutoCompleteWindow: def complete(): return class DummyEditwin: def __init__(self, root, text): self.root = root self.text = text self.indentwidth = 8 self.tabwidth = 8 self.context_use_ps1 = True class AutoCompleteTest(unittest.TestCase): @classmethod def setUpClass(cls): requires('gui') cls.root = Tk() cls.text = Text(cls.root) cls.editor = DummyEditwin(cls.root, cls.text) @classmethod def tearDownClass(cls): del cls.editor, cls.text cls.root.destroy() del cls.root def setUp(self): self.editor.text.delete('1.0', 'end') self.autocomplete = ac.AutoComplete(self.editor) def test_init(self): self.assertEqual(self.autocomplete.editwin, self.editor) def test_make_autocomplete_window(self): testwin = self.autocomplete._make_autocomplete_window() self.assertIsInstance(testwin, acw.AutoCompleteWindow) def test_remove_autocomplete_window(self): self.autocomplete.autocompletewindow = ( self.autocomplete._make_autocomplete_window()) self.autocomplete._remove_autocomplete_window() self.assertIsNone(self.autocomplete.autocompletewindow) def test_force_open_completions_event(self): # Test that force_open_completions_event calls _open_completions o_cs = Func() self.autocomplete.open_completions = o_cs self.autocomplete.force_open_completions_event('event') self.assertEqual(o_cs.args, (True, False, True)) def test_try_open_completions_event(self): Equal = self.assertEqual autocomplete = self.autocomplete trycompletions = self.autocomplete.try_open_completions_event o_c_l = Func() autocomplete._open_completions_later = o_c_l # _open_completions_later should not be called with no text in editor trycompletions('event') Equal(o_c_l.args, None) # _open_completions_later should be called with COMPLETE_ATTRIBUTES (1) self.text.insert('1.0', 're.') trycompletions('event') Equal(o_c_l.args, (False, False, False, 1)) # _open_completions_later should be called with COMPLETE_FILES (2) self.text.delete('1.0', 'end') self.text.insert('1.0', '"./Lib/') trycompletions('event') Equal(o_c_l.args, (False, False, False, 2)) def test_autocomplete_event(self): Equal = self.assertEqual autocomplete = self.autocomplete # Test that the autocomplete event is ignored if user is pressing a # modifier key in addition to the tab key ev = Event(mc_state=True) self.assertIsNone(autocomplete.autocomplete_event(ev)) del ev.mc_state # If autocomplete window is open, complete() method is called self.text.insert('1.0', 're.') # This must call autocomplete._make_autocomplete_window() Equal(self.autocomplete.autocomplete_event(ev), 'break') # If autocomplete window is not active or does not exist, # open_completions is called. Return depends on its return. autocomplete._remove_autocomplete_window() o_cs = Func() # .result = None autocomplete.open_completions = o_cs Equal(self.autocomplete.autocomplete_event(ev), None) Equal(o_cs.args, (False, True, True)) o_cs.result = True Equal(self.autocomplete.autocomplete_event(ev), 'break') Equal(o_cs.args, (False, True, True)) def test_open_completions_later(self): # Test that autocomplete._delayed_completion_id is set pass def test_delayed_open_completions(self): # Test that autocomplete._delayed_completion_id set to None and that # open_completions only called if insertion index is the same as # _delayed_completion_index pass def test_open_completions(self): # Test completions of files and attributes as well as non-completion # of errors pass def test_fetch_completions(self): # Test that fetch_completions returns 2 lists: # For attribute completion, a large list containing all variables, and # a small list containing non-private variables. # For file completion, a large list containing all files in the path, # and a small list containing files that do not start with '.' pass def test_get_entity(self): # Test that a name is in the namespace of sys.modules and # __main__.__dict__ pass if __name__ == '__main__': unittest.main(verbosity=2) PK™e[s",,test_searchengine.pynu['''Test functions and SearchEngine class in SearchEngine.py.''' # With mock replacements, the module does not use any gui widgets. # The use of tk.Text is avoided (for now, until mock Text is improved) # by patching instances with an index function returning what is needed. # This works because mock Text.get does not use .index. import re import unittest #from test.test_support import requires from Tkinter import BooleanVar, StringVar, TclError # ,Tk, Text import tkMessageBox from idlelib import SearchEngine as se from idlelib.idle_test.mock_tk import Var, Mbox from idlelib.idle_test.mock_tk import Text as mockText def setUpModule(): # Replace s-e module tkinter imports other than non-gui TclError. se.BooleanVar = Var se.StringVar = Var se.tkMessageBox = Mbox def tearDownModule(): # Restore 'just in case', though other tests should also replace. se.BooleanVar = BooleanVar se.StringVar = StringVar se.tkMessageBox = tkMessageBox class Mock: def __init__(self, *args, **kwargs): pass class GetTest(unittest.TestCase): # SearchEngine.get returns singleton created & saved on first call. def test_get(self): saved_Engine = se.SearchEngine se.SearchEngine = Mock # monkey-patch class try: root = Mock() engine = se.get(root) self.assertIsInstance(engine, se.SearchEngine) self.assertIs(root._searchengine, engine) self.assertIs(se.get(root), engine) finally: se.SearchEngine = saved_Engine # restore class to module class GetLineColTest(unittest.TestCase): # Test simple text-independent helper function def test_get_line_col(self): self.assertEqual(se.get_line_col('1.0'), (1, 0)) self.assertEqual(se.get_line_col('1.11'), (1, 11)) self.assertRaises(ValueError, se.get_line_col, ('1.0 lineend')) self.assertRaises(ValueError, se.get_line_col, ('end')) class GetSelectionTest(unittest.TestCase): # Test text-dependent helper function. ## # Need gui for text.index('sel.first/sel.last/insert'). ## @classmethod ## def setUpClass(cls): ## requires('gui') ## cls.root = Tk() ## ## @classmethod ## def tearDownClass(cls): ## cls.root.destroy() ## del cls.root def test_get_selection(self): # text = Text(master=self.root) text = mockText() text.insert('1.0', 'Hello World!') # fix text.index result when called in get_selection def sel(s): # select entire text, cursor irrelevant if s == 'sel.first': return '1.0' if s == 'sel.last': return '1.12' raise TclError text.index = sel # replaces .tag_add('sel', '1.0, '1.12') self.assertEqual(se.get_selection(text), ('1.0', '1.12')) def mark(s): # no selection, cursor after 'Hello' if s == 'insert': return '1.5' raise TclError text.index = mark # replaces .mark_set('insert', '1.5') self.assertEqual(se.get_selection(text), ('1.5', '1.5')) class ReverseSearchTest(unittest.TestCase): # Test helper function that searches backwards within a line. def test_search_reverse(self): Equal = self.assertEqual line = "Here is an 'is' test text." prog = re.compile('is') Equal(se.search_reverse(prog, line, len(line)).span(), (12, 14)) Equal(se.search_reverse(prog, line, 14).span(), (12, 14)) Equal(se.search_reverse(prog, line, 13).span(), (5, 7)) Equal(se.search_reverse(prog, line, 7).span(), (5, 7)) Equal(se.search_reverse(prog, line, 6), None) class SearchEngineTest(unittest.TestCase): # Test class methods that do not use Text widget. def setUp(self): self.engine = se.SearchEngine(root=None) # Engine.root is only used to create error message boxes. # The mock replacement ignores the root argument. def test_is_get(self): engine = self.engine Equal = self.assertEqual Equal(engine.getpat(), '') engine.setpat('hello') Equal(engine.getpat(), 'hello') Equal(engine.isre(), False) engine.revar.set(1) Equal(engine.isre(), True) Equal(engine.iscase(), False) engine.casevar.set(1) Equal(engine.iscase(), True) Equal(engine.isword(), False) engine.wordvar.set(1) Equal(engine.isword(), True) Equal(engine.iswrap(), True) engine.wrapvar.set(0) Equal(engine.iswrap(), False) Equal(engine.isback(), False) engine.backvar.set(1) Equal(engine.isback(), True) def test_setcookedpat(self): engine = self.engine engine.setcookedpat('\s') self.assertEqual(engine.getpat(), '\s') engine.revar.set(1) engine.setcookedpat('\s') self.assertEqual(engine.getpat(), r'\\s') def test_getcookedpat(self): engine = self.engine Equal = self.assertEqual Equal(engine.getcookedpat(), '') engine.setpat('hello') Equal(engine.getcookedpat(), 'hello') engine.wordvar.set(True) Equal(engine.getcookedpat(), r'\bhello\b') engine.wordvar.set(False) engine.setpat('\s') Equal(engine.getcookedpat(), r'\\s') engine.revar.set(True) Equal(engine.getcookedpat(), '\s') def test_getprog(self): engine = self.engine Equal = self.assertEqual engine.setpat('Hello') temppat = engine.getprog() Equal(temppat.pattern, re.compile('Hello', re.IGNORECASE).pattern) engine.casevar.set(1) temppat = engine.getprog() Equal(temppat.pattern, re.compile('Hello').pattern, 0) engine.setpat('') Equal(engine.getprog(), None) engine.setpat('+') engine.revar.set(1) Equal(engine.getprog(), None) self.assertEqual(Mbox.showerror.message, 'Error: nothing to repeat\nPattern: +') def test_report_error(self): showerror = Mbox.showerror Equal = self.assertEqual pat = '[a-z' msg = 'unexpected end of regular expression' Equal(self.engine.report_error(pat, msg), None) Equal(showerror.title, 'Regular expression error') expected_message = ("Error: " + msg + "\nPattern: [a-z") Equal(showerror.message, expected_message) Equal(self.engine.report_error(pat, msg, 5), None) Equal(showerror.title, 'Regular expression error') expected_message += "\nOffset: 5" Equal(showerror.message, expected_message) class SearchTest(unittest.TestCase): # Test that search_text makes right call to right method. @classmethod def setUpClass(cls): ## requires('gui') ## cls.root = Tk() ## cls.text = Text(master=cls.root) cls.text = mockText() test_text = ( 'First line\n' 'Line with target\n' 'Last line\n') cls.text.insert('1.0', test_text) cls.pat = re.compile('target') cls.engine = se.SearchEngine(None) cls.engine.search_forward = lambda *args: ('f', args) cls.engine.search_backward = lambda *args: ('b', args) ## @classmethod ## def tearDownClass(cls): ## cls.root.destroy() ## del cls.root def test_search(self): Equal = self.assertEqual engine = self.engine search = engine.search_text text = self.text pat = self.pat engine.patvar.set(None) #engine.revar.set(pat) Equal(search(text), None) def mark(s): # no selection, cursor after 'Hello' if s == 'insert': return '1.5' raise TclError text.index = mark Equal(search(text, pat), ('f', (text, pat, 1, 5, True, False))) engine.wrapvar.set(False) Equal(search(text, pat), ('f', (text, pat, 1, 5, False, False))) engine.wrapvar.set(True) engine.backvar.set(True) Equal(search(text, pat), ('b', (text, pat, 1, 5, True, False))) engine.backvar.set(False) def sel(s): if s == 'sel.first': return '2.10' if s == 'sel.last': return '2.16' raise TclError text.index = sel Equal(search(text, pat), ('f', (text, pat, 2, 16, True, False))) Equal(search(text, pat, True), ('f', (text, pat, 2, 10, True, True))) engine.backvar.set(True) Equal(search(text, pat), ('b', (text, pat, 2, 10, True, False))) Equal(search(text, pat, True), ('b', (text, pat, 2, 16, True, True))) class ForwardBackwardTest(unittest.TestCase): # Test that search_forward method finds the target. ## @classmethod ## def tearDownClass(cls): ## cls.root.destroy() ## del cls.root @classmethod def setUpClass(cls): cls.engine = se.SearchEngine(None) ## requires('gui') ## cls.root = Tk() ## cls.text = Text(master=cls.root) cls.text = mockText() # search_backward calls index('end-1c') cls.text.index = lambda index: '4.0' test_text = ( 'First line\n' 'Line with target\n' 'Last line\n') cls.text.insert('1.0', test_text) cls.pat = re.compile('target') cls.res = (2, (10, 16)) # line, slice indexes of 'target' cls.failpat = re.compile('xyz') # not in text cls.emptypat = re.compile('\w*') # empty match possible def make_search(self, func): def search(pat, line, col, wrap, ok=0): res = func(self.text, pat, line, col, wrap, ok) # res is (line, matchobject) or None return (res[0], res[1].span()) if res else res return search def test_search_forward(self): # search for non-empty match Equal = self.assertEqual forward = self.make_search(self.engine.search_forward) pat = self.pat Equal(forward(pat, 1, 0, True), self.res) Equal(forward(pat, 3, 0, True), self.res) # wrap Equal(forward(pat, 3, 0, False), None) # no wrap Equal(forward(pat, 2, 10, False), self.res) Equal(forward(self.failpat, 1, 0, True), None) Equal(forward(self.emptypat, 2, 9, True, ok=True), (2, (9, 9))) #Equal(forward(self.emptypat, 2, 9, True), self.res) # While the initial empty match is correctly ignored, skipping # the rest of the line and returning (3, (0,4)) seems buggy - tjr. Equal(forward(self.emptypat, 2, 10, True), self.res) def test_search_backward(self): # search for non-empty match Equal = self.assertEqual backward = self.make_search(self.engine.search_backward) pat = self.pat Equal(backward(pat, 3, 5, True), self.res) Equal(backward(pat, 2, 0, True), self.res) # wrap Equal(backward(pat, 2, 0, False), None) # no wrap Equal(backward(pat, 2, 16, False), self.res) Equal(backward(self.failpat, 3, 9, True), None) Equal(backward(self.emptypat, 2, 10, True, ok=True), (2, (9,9))) # Accepted because 9 < 10, not because ok=True. # It is not clear that ok=True is useful going back - tjr Equal(backward(self.emptypat, 2, 9, True), (2, (5, 9))) if __name__ == '__main__': unittest.main(verbosity=2, exit=2) PK™e[J_ test_grep.pynu[""" !Changing this line will break Test_findfile.test_found! Non-gui unit tests for idlelib.GrepDialog methods. dummy_command calls grep_it calls findfiles. An exception raised in one method will fail callers. Otherwise, tests are mostly independent. *** Currently only test grep_it. """ import unittest from test.test_support import captured_stdout, findfile from idlelib.idle_test.mock_tk import Var from idlelib.GrepDialog import GrepDialog import re __file__ = findfile('idlelib/idle_test') + '/test_grep.py' class Dummy_searchengine: '''GrepDialog.__init__ calls parent SearchDiabolBase which attaches the passed in SearchEngine instance as attribute 'engine'. Only a few of the many possible self.engine.x attributes are needed here. ''' def getpat(self): return self._pat searchengine = Dummy_searchengine() class Dummy_grep: # Methods tested #default_command = GrepDialog.default_command grep_it = GrepDialog.grep_it.im_func findfiles = GrepDialog.findfiles.im_func # Other stuff needed recvar = Var(False) engine = searchengine def close(self): # gui method pass grep = Dummy_grep() class FindfilesTest(unittest.TestCase): # findfiles is really a function, not a method, could be iterator # test that filename return filename # test that idlelib has many .py files # test that recursive flag adds idle_test .py files pass class Grep_itTest(unittest.TestCase): # Test captured reports with 0 and some hits. # Should test file names, but Windows reports have mixed / and \ separators # from incomplete replacement, so 'later'. def report(self, pat): grep.engine._pat = pat with captured_stdout() as s: grep.grep_it(re.compile(pat), __file__) lines = s.getvalue().split('\n') lines.pop() # remove bogus '' after last \n return lines def test_unfound(self): pat = 'xyz*'*7 lines = self.report(pat) self.assertEqual(len(lines), 2) self.assertIn(pat, lines[0]) self.assertEqual(lines[1], 'No hits.') def test_found(self): pat = '""" !Changing this line will break Test_findfile.test_found!' lines = self.report(pat) self.assertEqual(len(lines), 5) self.assertIn(pat, lines[0]) self.assertIn('py: 1:', lines[1]) # line number 1 self.assertIn('2', lines[3]) # hits found 2 self.assertTrue(lines[4].startswith('(Hint:')) class Default_commandTest(unittest.TestCase): # To write this, mode OutputWindow import to top of GrepDialog # so it can be replaced by captured_stdout in class setup/teardown. pass if __name__ == '__main__': unittest.main(verbosity=2, exit=False) PK™e[1uftest_searchdialogbase.pyonu[ {fc@sdZddlZddlmZddlmZmZmZmZddl m Z ddl m Z ddlmZdejfd YZed krejd d d d ndS(sUnittests for idlelib/SearchDialogBase.py Coverage: 99%. The only thing not covered is inconsequential -- testing skipping of suite when self.needwrapbutton is false. iN(trequires(tTexttTktTopleveltFrame(t SearchEngine(tSearchDialogBase(tFunctSearchDialogBaseTestcBseZedZedZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZRS(cCstdt|_dS(Ntgui(RRtroot(tcls((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyt setUpClasss cCs|jj|`dS(N(R tdestroy(R ((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyt tearDownClass s cCs:tj|j|_tjd|jd|j|_dS(NR tengine(tseRR RtsdbRtdialog(tself((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pytsetUp%scCs|jjdS(N(Rtclose(R((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttearDown)scCsd|j_t|j}t|}|jj||j|jjj d|jj |j|jjj d|jj|dd|j|jj j d|j |jdS(Ntnormalt withdrawnt searchphrasethello(tNoneRtdefault_commandRR Rtopent assertEqualttoptstateRtenttgettupdate_idletasksR (Rttoplevelttext((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_open_and_close,s    cCst|j_t|j_t|j_t|j_d|j_|jj|j |jjj |j |jjj |j |jjj |j |jjj dS(N( RRtcreate_entriestcreate_option_buttonstcreate_other_buttonstcreate_command_buttonsRRtcreate_widgetst assertTruetcalled(R((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_create_widgets<s  cCs|j}d|j_t|j|j_|jjdd\}}||dd|j|jd|j }|t |dd|t |dd|t |dd|t |d d||jjddS( NisTest:RR%trowtcolumnitrowspant columnspan( RRR/RR Rt make_entrytassertInR"t grid_infotint(Rtequaltentrytlabeltegi((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_make_entryJs   cCsId|j_|jjd|jj|j|jjjddS(NiR(RR/RtsetpatR'R4R!R"(R((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_create_entriesYs  cCsd|j_t|j|j_|jj\}}|j|d|j|t|jjd\}}|j|dd|j|tdS(Nitt testlabelR%( RR/RR Rt make_frameRtassertIsInstanceR(RtframeR9((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_make_frame_s cCs(t|j|j_d|j_|S(Ni(RR RRR/(Rtmeth((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pytbtn_test_setupjs c Cs|j}xdD]}x3|j|j|j|jfD]}|j|q5W|j|jj\}}xt ||j D]\}}|\}}|j |d||j |j ||dkr|j n |j|j |j d|q}WqWdS(NiiR%(ii(RtrevartcasevartwordvartwrapvartsetRERR(tzipt pack_slavesRR"tdeselecttselect( RteR tvarRBtoptionstspectbuttonR9((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_create_option_buttonsos  %"    c Csx ttfD]}|jj}|j||j|jj\}}|j}xt ||D]\}}|\}} |j |d| ||krc|j |j |||j |j |j d||d|j |j |j |qcqcWq WdS(NR%i( tFalsetTrueRtbackvarRJRERR)RLRKRR"RN( RR RPRBtotherstbuttonsRRRStvalR9((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_create_other_buttonss     cCs`t|j|j_t|jj|j_|jjd|jj}|j|dddS(NtTestR%( RR RRRt buttonframet make_buttonRR(Rtbtn((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_make_buttonscCsa|jjd}x7|jjjD]#}|ddkr&|d}q&q&W|jd|dS(NR>R%Rtcommand(RR*R]twinfo_childrenR4(Rtclosebuttoncommandtchild((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyttest_create_command_buttonss  (t__name__t __module__t classmethodR RRRR&R.R;R=RCRERTR[R`Re(((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyRs          t__main__t verbosityitexit(t__doc__tunittestttest.test_supportRtTkinterRRRRtidlelibRRRRtidlelib.idle_test.mock_idleRtTestCaseRRftmain(((s?/usr/lib64/python2.7/idlelib/idle_test/test_searchdialogbase.pyts "  PK™e[ '.QQtest_widgetredir.pynu["""Unittest for idlelib.WidgetRedirector 100% coverage """ from test.test_support import requires import unittest from idlelib.idle_test.mock_idle import Func from Tkinter import Tk, Text, TclError from idlelib.WidgetRedirector import WidgetRedirector class InitCloseTest(unittest.TestCase): @classmethod def setUpClass(cls): requires('gui') cls.root = Tk() cls.root.withdraw() cls.text = Text(cls.root) @classmethod def tearDownClass(cls): del cls.text cls.root.destroy() del cls.root def test_init(self): redir = WidgetRedirector(self.text) self.assertEqual(redir.widget, self.text) self.assertEqual(redir.tk, self.text.tk) self.assertRaises(TclError, WidgetRedirector, self.text) redir.close() # restore self.tk, self.text def test_close(self): redir = WidgetRedirector(self.text) redir.register('insert', Func) redir.close() self.assertEqual(redir._operations, {}) self.assertFalse(hasattr(self.text, 'widget')) class WidgetRedirectorTest(unittest.TestCase): @classmethod def setUpClass(cls): requires('gui') cls.root = Tk() cls.root.withdraw() cls.text = Text(cls.root) @classmethod def tearDownClass(cls): del cls.text cls.root.destroy() del cls.root def setUp(self): self.redir = WidgetRedirector(self.text) self.func = Func() self.orig_insert = self.redir.register('insert', self.func) self.text.insert('insert', 'asdf') # leaves self.text empty def tearDown(self): self.text.delete('1.0', 'end') self.redir.close() def test_repr(self): # partly for 100% coverage self.assertIn('Redirector', repr(self.redir)) self.assertIn('Original', repr(self.orig_insert)) def test_register(self): self.assertEqual(self.text.get('1.0', 'end'), '\n') self.assertEqual(self.func.args, ('insert', 'asdf')) self.assertIn('insert', self.redir._operations) self.assertIn('insert', self.text.__dict__) self.assertEqual(self.text.insert, self.func) def test_original_command(self): self.assertEqual(self.orig_insert.operation, 'insert') self.assertEqual(self.orig_insert.tk_call, self.text.tk.call) self.orig_insert('insert', 'asdf') self.assertEqual(self.text.get('1.0', 'end'), 'asdf\n') def test_unregister(self): self.assertIsNone(self.redir.unregister('invalid operation name')) self.assertEqual(self.redir.unregister('insert'), self.func) self.assertNotIn('insert', self.redir._operations) self.assertNotIn('insert', self.text.__dict__) def test_unregister_no_attribute(self): del self.text.insert self.assertEqual(self.redir.unregister('insert'), self.func) def test_dispatch_intercept(self): self.func.__init__(True) self.assertTrue(self.redir.dispatch('insert', False)) self.assertFalse(self.func.args[0]) def test_dispatch_bypass(self): self.orig_insert('insert', 'asdf') # tk.call returns '' where Python would return None self.assertEqual(self.redir.dispatch('delete', '1.0', 'end'), '') self.assertEqual(self.text.get('1.0', 'end'), '\n') def test_dispatch_error(self): self.func.__init__(TclError()) self.assertEqual(self.redir.dispatch('insert', False), '') self.assertEqual(self.redir.dispatch('invalid'), '') def test_command_dispatch(self): # Test that .__init__ causes redirection of tk calls # through redir.dispatch self.root.call(self.text._w, 'insert', 'hello') self.assertEqual(self.func.args, ('hello',)) self.assertEqual(self.text.get('1.0', 'end'), '\n') # Ensure that called through redir .dispatch and not through # self.text.insert by having mock raise TclError. self.func.__init__(TclError()) self.assertEqual(self.root.call(self.text._w, 'insert', 'boo'), '') if __name__ == '__main__': unittest.main(verbosity=2) PK™e[ggtest_textview.pycnu[ {fc@sdZddlZddlZddlmZddlmZddlmZ ddl m Z ddl m Z de jfd YZd ejfd YZd ejfd YZedkrejddndS(s8Test the functions and main class method of textView.py.iN(trequires(tTk(ttextView(tFunc(tMboxtTVcBs#eZeZeZeZRS((t__name__t __module__Rt transienttgrab_sett wait_window(((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyR s  ttextviewClassTestcBsJeZedZedZdZdZdZdZRS(cCs'tdt|_|jjdS(Ntgui(RRtroottwithdraw(tcls((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyt setUpClasss  cCs|jj|`dS(N(R tdestroy(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyt tearDownClasss cCs+tjjtjjtjjdS(N(RRt__init__R R (tself((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pytsetUps  cCs\t|jdd}|jtjj|jtjj|jtjj|jdS(NtTitles test text(RR t assertTrueRtcalledR R tOk(Rtview((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyttest_init_modal#s cCsbt|jdddt}|jtjj|jtjj|jtjj|jdS(NRs test texttmodal( RR tFalset assertFalseRRR R R(RR((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyttest_init_nonmodal*s cCsXt|jdddt}t|_|j|j|jj|`|jdS(NRs test textR(RR RRRRRR(RR((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyttest_ok1s   ( RRt classmethodRRRRRR (((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyR s    tViewFunctionTestcBs8eZedZedZdZdZRS(cCs<tdt|_|jjtj|_tt_dS(NR (RRR Rttvt tkMessageBoxt orig_mboxR(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyR<s     cCs)|jj|`|jt_|`dS(N(R RR%R#R$(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyRDs  cCs?tj|jdddt}|j|tj|jdS(NRs test textR(R#t view_textR RtassertIsInstancet TextViewerR(RR((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyttest_view_textKscCstjjt}tjj|d}tj|jd|dt}|j |tj |j d|j j dd|jtjj|d}tj|jd|dt}|j|dS(Nstest_textview.pyRRtTests1.0s1.ends../notthere.py(tostpathtdirnamet__file__tjoinR#t view_fileR RR'R(tassertInRtgetRt assertIsNone(Rttest_dirttestfileR((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyttest_view_fileQs (RRR!RRR)R6(((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyR":s t__main__t verbosityi(t__doc__tunittestR+ttest.test_supportRtTkinterRtidlelibRR#tidlelib.idle_test.mock_idleRtidlelib.idle_test.mock_tkRR(RtTestCaseR R"Rtmain(((s7/usr/lib64/python2.7/idlelib/idle_test/test_textview.pyts  )% PK™e[qiItest_configdialog.pynu['''Unittests for idlelib/configHandler.py Coverage: 46% just by creating dialog. The other half is change code. ''' import unittest from test.test_support import requires from Tkinter import Tk from idlelib.configDialog import ConfigDialog from idlelib.macosxSupport import _initializeTkVariantTests class ConfigDialogTest(unittest.TestCase): @classmethod def setUpClass(cls): requires('gui') cls.root = Tk() cls.root.withdraw() _initializeTkVariantTests(cls.root) @classmethod def tearDownClass(cls): cls.root.destroy() del cls.root def test_dialog(self): d = ConfigDialog(self.root, 'Test', _utest=True) d.remove_var_callbacks() if __name__ == '__main__': unittest.main(verbosity=2) PK™e[p-test_config_name.pycnu[ {fc@sdZddlZddlmZmZddlmZejZ de fdYZ ej Z ejZdejfdYZed krejd d d endS( s.Unit tests for idlelib.configSectionNameDialogiN(tVartMbox(tconfigSectionNameDialogtDummy_name_dialogcBs\eZejjZejjZejjZdgZeZ dZ e Z dZdZRS(tusedcCsdS(N((tself((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyt grab_releasescCs t|_dS(N(tTruet destroyed(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pytdestroysN(t__name__t __module__t name_dialogtname_oktim_functOktCancelt used_namesRtnametNonetresulttFalseRRR (((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyRs      tConfigNameTestcBseeZeZedZedZdZdZdZ dZ dZ dZ RS(cCs tt_dS(N(Rtname_dialog_modulet tkMessageBox(tcls((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyt setUpClassscCs tt_dS(N(t orig_mboxRR(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyt tearDownClass"scCsV|jjjd|j|jjd|jtjd|jdtjdS(Nt ts Name ErrortNo( tdialogRtsett assertEqualR t showerrorttitletassertIntmessage(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyttest_blank_name&scCsV|jjjd|j|jjd|jtjd|jdtjdS(NRRs Name Errortuse( R RR!R"R R#R$R%R&(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyttest_used_name,scCsZ|jjjdd|j|jjd|jtjd|jdtjdS(NtgoodiRs Name Errorstoo long( R RR!R"R R#R$R%R&(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyttest_long_name2scCsL|jjjddt_|j|jjd|jtjddS(Ns good sNo ErrorR*(R RR!R#R$R"R (R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyttest_good_name8s cCsYt|j_|jjjd|jj|j|jjd|j|jjdS(NR*( RR RRR!RR"Rt assertTrue(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyttest_ok>s   cCsFt|j_|jj|j|jjd|j|jjdS(NR(RR RRR"RR-(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyt test_cancelEs  ( R R RR t classmethodRRR'R)R+R,R.R/(((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyRs      t__main__t verbosityitexit(t__doc__tunittesttidlelib.idle_test.mock_tkRRtidlelibRRtGetCfgSectionNameDialogR tobjectRRRR#tTestCaseRR tmainR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_config_name.pyts    1 PK™e[' test_text.pycnu[ {fc@sddlZddlmZddlmZdefdYZdeejfdYZdeejfd YZ e d krej d d d e ndS(iN(trequires(tTclErrortTextTestcBseZdZedZd ZdZdZdZdZ dZ dZ dZ d Z d Zd Zd ZRS(s hello worlds cCs|j|_dS(N(tTextttext(tself((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pytsetUp scCs<|j|jjdd|j|jjdddS(Ns1.0s tendt(t assertEqualRtget(R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt test_initscCs^|jj}x$dD]}|j||dqWx$dD]}|j||d q:WdS(Ngg333333?s1.-1s1.0s 1.0 lineends1.ends1.33tinsertRg@s2.1s33.44s2.0(gg333333?s1.-1s1.0s 1.0 lineends1.ends1.33R (Rg@s2.1s33.44(RtindexR (RR tdex((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_index_emptys    cCs|jj}|jjd|jx$d D]}|j||dq)Wx$d D]}|j||dqPWx$dD]}|j||d qwWdS(Ns1.0gg333333?s1.-1s 1.0 lineends1.ends1.33s1.5Rs33.44s3.0(gg333333?s1.-1s1.0(s 1.0 lineends1.ends1.33(Rs33.44(RR R thwR (RR R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_index_datas    cCsM|jj}|j}|jjd|j||dd||ddd||dd||ddd||ddd||ddd||dd d ||dd d ||d d ||dd d||dd|j||dd|j||dd|jdS(Ns1.0RRths1.1s1.3theltels 1.0 lineendthellos1.10s s2.3sello wors2.5s0.0s5.0(RR R R Rthwn(RR tEqual((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_get+s   cCs#|jj}|jj}|j}|d|j||dd|j|dd||dd|j|dd||ddd|dd||ddd|dd||ddd |dd ||ddd |d d ||ddddS(Ns1.0RRt*s *hello world s 1.0 lineends*hello* world s2.3s*hello* wor*ld txs*hello* wor*ldx s1.4sx s*helx lo* wor*ldx (RR R R RR(RR R R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt test_insert>s"         cCs|jj}|jj}|j}|jjd|j|d||dd|j|d||dd|j|dd||dd|j|dd||dd|j|dd||dd|j|dd||dd|jdS(Ns1.0R Rs5.5s1.4(RtdeleteR R R RR(RRR R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_no_deleteXs          cCs|jj}|jj}|j}|jjd|j|d||ddd|dd||ddd|d||ddd|jjdd|d ||ddd|jjdd|dd ||ddddS( Ns1.0s1.endtellos1.1tllotlloworlds1.3s s1.10s2.0(RRR R R R(RRR R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_delete_charqs         cCs|jj}|jj}|j}|jjd|j|dd||ddd|dd||ddd|jjd|j|dd||ddd|dd||ddd|jjd|j|dd ||ddd dS( Ns1.0s 1.0 lineendRs world s s2.0sworld s1.2s2.3sheld (RRR R R R(RRR R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_delete_slices         cCs{|jjdd|jjdd|j|jjddd|jjdd|j|jjddddS( Ns1.0Rs1.3s 1 2 3 4 5Rshel1 2 3 4 5lo s5.1shello (RR R R R(R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyttest_multiple_liness c Csr|jj}|j}|jjdd|jt|dddx*dtttttfdtttttfdtttttfdtttttfd tttttfd tttttffD]\}}}}}}||d |d||||d |d||||d|d||||d |d||||d|d||qWdS(Ns1.0sFirst Second Third s2.2topts>=s==s!=s1.1s2.1s2.3s3.3(RtcompareR R t assertRaisesRtTruetFalse( RR'RR$tless1tless0tequaltgreater0tgreater1((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt test_compares   1N(t__name__t __module__RRtNoneRRR RRRRRR!R"R#R0(((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyRs         t MockTextTestcBs eZedZdZRS(cCsddlm}||_dS(Ni(R(tidlelib.idle_test.mock_tkR(tclsR((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt setUpClassscCs|jj}|j}|jjd|j||ddd ||ddd ||ddd ||ddd dS( Ns1.0Riiis3.1ii(ii(ii(ii(ii(Rt_decodeR R R(RtdecodeR((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt test_decodes  (R1R2t classmethodR7R:(((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyR4st TkTextTestcBs&eZedZedZRS(cCs9tdddlm}m}||_||_dS(Ntguii(tTkR(RtTkinterR>Rtroot(R6R>R((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyR7s  cCs|jj|`dS(N(R@tdestroy(R6((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyt tearDownClasss (R1R2R;R7RB(((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyR<st__main__t verbosityitexit( tunittestttest.test_supportRt_tkinterRtobjectRtTestCaseR4R<R1tmainR*(((s3/usr/lib64/python2.7/idlelib/idle_test/test_text.pyts  PK™e[k test_grep.pycnu[ {fc@sdZddlZddlmZmZddlmZddlmZddl Z eddZ ddd YZ e Z d dd YZ e Zd ejfd YZdejfdYZdejfdYZedkr ejdddendS(s !Changing this line will break Test_findfile.test_found! Non-gui unit tests for idlelib.GrepDialog methods. dummy_command calls grep_it calls findfiles. An exception raised in one method will fail callers. Otherwise, tests are mostly independent. *** Currently only test grep_it. iN(tcaptured_stdouttfindfile(tVar(t GrepDialogsidlelib/idle_tests /test_grep.pytDummy_searchenginecBseZdZdZRS(sGrepDialog.__init__ calls parent SearchDiabolBase which attaches the passed in SearchEngine instance as attribute 'engine'. Only a few of the many possible self.engine.x attributes are needed here. cCs|jS(N(t_pat(tself((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pytgetpats(t__name__t __module__t__doc__R(((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyRst Dummy_grepcBs;eZejjZejjZeeZe Z dZ RS(cCsdS(N((R((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pytclose"s( RR Rtgrep_ittim_funct findfilesRtFalsetrecvart searchenginetengineR (((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyR s    t FindfilesTestcBseZRS((RR (((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyR'st Grep_itTestcBs#eZdZdZdZRS(cCsZ|tj_t }tjtj|tWdQX|jj d}|j |S(Ns ( tgrepRRRR tretcompilet__file__tgetvaluetsplittpop(Rtpattstlines((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pytreport3s    cCs[dd}|j|}|jt|d|j||d|j|dddS(Nsxyz*iiiisNo hits.(R t assertEqualtlentassertIn(RRR((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyt test_unfound;s  cCsd}|j|}|jt|d|j||d|jd|d|jd|d|j|djd dS( Ns<""" !Changing this line will break Test_findfile.test_found!iispy: 1:it2iis(Hint:(R R!R"R#t assertTruet startswith(RRR((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyt test_foundBs(RR R R$R((((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyR.s  tDefault_commandTestcBseZRS((RR (((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyR)Lst__main__t verbosityitexit(((R tunittestttest.test_supportRRtidlelib.idle_test.mock_tkRtidlelib.GrepDialogRRRRRR RtTestCaseRRR)RtmainR(((s3/usr/lib64/python2.7/idlelib/idle_test/test_grep.pyts     PK™e[btest_idlehistory.pycnu[ {fc@sddlZddlmZddlZddlmZddlmZddl m Z ddl m Z dZ dZdejfd YZd dd YZd ejfd YZedkrejddddndS(iN(trequires(tText(tHistory(tidleConfsa = 7sb = at StoreTestcBsJeZdZedZdZdZdZdZdZ RS(s7Tests History.__init__ and History.store with mock TextcCs"t|_t|j|_dS(N(tmkTextttextRthistory(tcls((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt setUpClasss cCs#|jjddg|j_dS(Ns1.0tend(RtdeleteR(tself((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttearDownscCs|j|jj|j|j|jjg|j|jj|j|jj|j|jjtj ddddddS(NtmainRtcyclicitbool( tassertIsRRt assertEqualt assertIsNonetprefixtpointerRRt GetOption(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt test_inits cCsP|jjd|j|jjg|jjd|j|jjgdS(Ntas a (RtstoreR(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_store_short!scCs|jjt|j|jjtg|jjt|j|jjttg|jjt|j|jjttgdS(N(RRtline1Rtline2(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_store_dup's cCsRt|j_d|j_|jjt|j|jj|j|jjdS(Ni(RRRRRRR(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_store_reset/s   ( t__name__t __module__t__doc__t classmethodR R RRRR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyR s    t TextWrappercBs#eZdZdZdZRS(cCstd||_t|_dS(Ntmaster(ttkTextRtFalset_bell(R R$((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt__init__8scCst|j|S(N(tgetattrR(R tname((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt __getattr__;scCs t|_dS(N(tTrueR'(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pytbell=s(RR R(R+R-(((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyR#7s  t FetchTestcBseZdZedZdZedZedZdZ dZ dZ dZ d Z d Zd Zd Zd ZRS(s-Test History.fetch with wrapped tk.Text. cCs*tdtj|_|jjdS(Ntgui(RttktTktroottwithdraw(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyR Cs cCskt|j|_}|jdd|jdd|jddt||_tt g|j_dS(Ns1.0s>>> tiomarks1.4tleft( R#R2Rtinserttmark_sett mark_gravityRRRR(R R((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pytsetUpIs cCs|jj|`dS(N(R2tdestroy(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt tearDownClassQs cCs|j}|j||j}||jjdd|||jj||rct|j_n||j|||j|||jj dddddS(NR4send-1cR6s==i( RtfetchRRtgetR'R&RRtcompare(R treversetlineRtindexR-RtEqual((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyt fetch_testVs   cCsRd}|j}|tt|d|tt|d|t|dddtdS(NtiiR-(RCR,RRtNone(R Rttest((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_prev_cyclicfs  cCsRd}|j}|tt|d|tt|d|t|dddtdS(NRDiiR-(RCR&RRRER,(R RRF((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_next_cyclicms  cCsOd}|jjd||jtt|d|jt|dddtdS(NRR4iR-(RR6RCR,RRE(R R((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_prev_prefixuscCsOd}|jjd||jtt|d|jt|dddtdS(NRR4iR-(RR6RCR&RRER,(R R((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_next_prefix{scCs^d}t|j_|j}|tt|d|tt|d|tt|ddtdS(NRDiiR-(R&RRRCR,RR(R RRF((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_prev_noncyclics   cCs}d}t|j_|j}|t|dddt|tt|d|t|dddt|t|dddtdS(NRDR-i(R&RRRCRER,R(R RRF((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_next_noncyclics  cCsF|jjdt|jjdd|jttdddtdS(NR?R6R4R-(RR<R,RR7RCRRE(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_cursor_movescCsS|jjdt|jjdd|jjdd|jttdddS(NR?R4R6sa =i(RR<R,RR R6RCR(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_fetch_editscCsP|jjd|j|jjd|jjd|j|jjddS(Ns dummy eventi(Rt history_prevRRt history_nextRE(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyttest_history_prev_nexts(RR R!R"R R9R;R&RCRGRHRIRJRKRLRMRNRQ(((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyR.@s         t__main__t verbosityitexit((tunittestttest.test_supportRtTkinterR0RR%tidlelib.idle_test.mock_tkRtidlelib.IdleHistoryRtidlelib.configHandlerRRRtTestCaseRR#R.RR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_idlehistory.pyts  * g PK™e[ZKKtest_helpabout.pynu['''Test idlelib.help_about. Coverage: ''' from idlelib import aboutDialog as help_about from idlelib import textView as textview from idlelib.idle_test.mock_idle import Func from idlelib.idle_test.mock_tk import Mbox import unittest About = help_about.AboutDialog class Dummy_about_dialog(): # Dummy class for testing file display functions. idle_credits = About.ShowIDLECredits.im_func idle_readme = About.ShowIDLEAbout.im_func idle_news = About.ShowIDLENEWS.im_func # Called by the above display_file_text = About.display_file_text.im_func class DisplayFileTest(unittest.TestCase): "Test that .txt files are found and properly decoded." dialog = Dummy_about_dialog() @classmethod def setUpClass(cls): cls.orig_mbox = textview.tkMessageBox cls.orig_view = textview.view_text cls.mbox = Mbox() cls.view = Func() textview.tkMessageBox = cls.mbox textview.view_text = cls.view cls.About = Dummy_about_dialog() @classmethod def tearDownClass(cls): textview.tkMessageBox = cls.orig_mbox textview.view_text = cls.orig_view.im_func def test_file_isplay(self): for handler in (self.dialog.idle_credits, self.dialog.idle_readme, self.dialog.idle_news): self.mbox.showerror.message = '' self.view.called = False handler() self.assertEqual(self.mbox.showerror.message, '') self.assertEqual(self.view.called, True) if __name__ == '__main__': unittest.main(verbosity=2) PK™e[Ytest_searchdialogbase.pynu['''Unittests for idlelib/SearchDialogBase.py Coverage: 99%. The only thing not covered is inconsequential -- testing skipping of suite when self.needwrapbutton is false. ''' import unittest from test.test_support import requires from Tkinter import Text, Tk, Toplevel, Frame ## BooleanVar, StringVar from idlelib import SearchEngine as se from idlelib import SearchDialogBase as sdb from idlelib.idle_test.mock_idle import Func ##from idlelib.idle_test.mock_tk import Var # The ## imports above & following could help make some tests gui-free.# However, they currently make radiobutton tests fail. ##def setUpModule(): ## # Replace tk objects used to initialize se.SearchEngine. ## se.BooleanVar = Var ## se.StringVar = Var ## ##def tearDownModule(): ## se.BooleanVar = BooleanVar ## se.StringVar = StringVar class SearchDialogBaseTest(unittest.TestCase): @classmethod def setUpClass(cls): requires('gui') cls.root = Tk() @classmethod def tearDownClass(cls): cls.root.destroy() del cls.root def setUp(self): self.engine = se.SearchEngine(self.root) # None also seems to work self.dialog = sdb.SearchDialogBase(root=self.root, engine=self.engine) def tearDown(self): self.dialog.close() def test_open_and_close(self): # open calls create_widgets, which needs default_command self.dialog.default_command = None toplevel = Toplevel(self.root) text = Text(toplevel) self.dialog.open(text) self.assertEqual(self.dialog.top.state(), 'normal') self.dialog.close() self.assertEqual(self.dialog.top.state(), 'withdrawn') self.dialog.open(text, searchphrase="hello") self.assertEqual(self.dialog.ent.get(), 'hello') toplevel.update_idletasks() toplevel.destroy() def test_create_widgets(self): self.dialog.create_entries = Func() self.dialog.create_option_buttons = Func() self.dialog.create_other_buttons = Func() self.dialog.create_command_buttons = Func() self.dialog.default_command = None self.dialog.create_widgets() self.assertTrue(self.dialog.create_entries.called) self.assertTrue(self.dialog.create_option_buttons.called) self.assertTrue(self.dialog.create_other_buttons.called) self.assertTrue(self.dialog.create_command_buttons.called) def test_make_entry(self): equal = self.assertEqual self.dialog.row = 0 self.dialog.top = Toplevel(self.root) entry, label = self.dialog.make_entry("Test:", 'hello') equal(label['text'], 'Test:') self.assertIn(entry.get(), 'hello') egi = entry.grid_info() equal(int(egi['row']), 0) equal(int(egi['column']), 1) equal(int(egi['rowspan']), 1) equal(int(egi['columnspan']), 1) equal(self.dialog.row, 1) def test_create_entries(self): self.dialog.row = 0 self.engine.setpat('hello') self.dialog.create_entries() self.assertIn(self.dialog.ent.get(), 'hello') def test_make_frame(self): self.dialog.row = 0 self.dialog.top = Toplevel(self.root) frame, label = self.dialog.make_frame() self.assertEqual(label, '') self.assertIsInstance(frame, Frame) frame, label = self.dialog.make_frame('testlabel') self.assertEqual(label['text'], 'testlabel') self.assertIsInstance(frame, Frame) def btn_test_setup(self, meth): self.dialog.top = Toplevel(self.root) self.dialog.row = 0 return meth() def test_create_option_buttons(self): e = self.engine for state in (0, 1): for var in (e.revar, e.casevar, e.wordvar, e.wrapvar): var.set(state) frame, options = self.btn_test_setup( self.dialog.create_option_buttons) for spec, button in zip (options, frame.pack_slaves()): var, label = spec self.assertEqual(button['text'], label) self.assertEqual(var.get(), state) if state == 1: button.deselect() else: button.select() self.assertEqual(var.get(), 1 - state) def test_create_other_buttons(self): for state in (False, True): var = self.engine.backvar var.set(state) frame, others = self.btn_test_setup( self.dialog.create_other_buttons) buttons = frame.pack_slaves() for spec, button in zip(others, buttons): val, label = spec self.assertEqual(button['text'], label) if val == state: # hit other button, then this one # indexes depend on button order self.assertEqual(var.get(), state) buttons[val].select() self.assertEqual(var.get(), 1 - state) buttons[1-val].select() self.assertEqual(var.get(), state) def test_make_button(self): self.dialog.top = Toplevel(self.root) self.dialog.buttonframe = Frame(self.dialog.top) btn = self.dialog.make_button('Test', self.dialog.close) self.assertEqual(btn['text'], 'Test') def test_create_command_buttons(self): self.dialog.create_command_buttons() # Look for close button command in buttonframe closebuttoncommand = '' for child in self.dialog.buttonframe.winfo_children(): if child['text'] == 'close': closebuttoncommand = child['command'] self.assertIn('close', closebuttoncommand) if __name__ == '__main__': unittest.main(verbosity=2, exit=2) PK™e[ wwtest_idlehistory.pynu[import unittest from test.test_support import requires import Tkinter as tk from Tkinter import Text as tkText from idlelib.idle_test.mock_tk import Text as mkText from idlelib.IdleHistory import History from idlelib.configHandler import idleConf line1 = 'a = 7' line2 = 'b = a' class StoreTest(unittest.TestCase): '''Tests History.__init__ and History.store with mock Text''' @classmethod def setUpClass(cls): cls.text = mkText() cls.history = History(cls.text) def tearDown(self): self.text.delete('1.0', 'end') self.history.history = [] def test_init(self): self.assertIs(self.history.text, self.text) self.assertEqual(self.history.history, []) self.assertIsNone(self.history.prefix) self.assertIsNone(self.history.pointer) self.assertEqual(self.history.cyclic, idleConf.GetOption("main", "History", "cyclic", 1, "bool")) def test_store_short(self): self.history.store('a') self.assertEqual(self.history.history, []) self.history.store(' a ') self.assertEqual(self.history.history, []) def test_store_dup(self): self.history.store(line1) self.assertEqual(self.history.history, [line1]) self.history.store(line2) self.assertEqual(self.history.history, [line1, line2]) self.history.store(line1) self.assertEqual(self.history.history, [line2, line1]) def test_store_reset(self): self.history.prefix = line1 self.history.pointer = 0 self.history.store(line2) self.assertIsNone(self.history.prefix) self.assertIsNone(self.history.pointer) class TextWrapper: def __init__(self, master): self.text = tkText(master=master) self._bell = False def __getattr__(self, name): return getattr(self.text, name) def bell(self): self._bell = True class FetchTest(unittest.TestCase): '''Test History.fetch with wrapped tk.Text. ''' @classmethod def setUpClass(cls): requires('gui') cls.root = tk.Tk() cls.root.withdraw() def setUp(self): self.text = text = TextWrapper(self.root) text.insert('1.0', ">>> ") text.mark_set('iomark', '1.4') text.mark_gravity('iomark', 'left') self.history = History(text) self.history.history = [line1, line2] @classmethod def tearDownClass(cls): cls.root.destroy() del cls.root def fetch_test(self, reverse, line, prefix, index, bell=False): # Perform one fetch as invoked by Alt-N or Alt-P # Test the result. The line test is the most important. # The last two are diagnostic of fetch internals. History = self.history History.fetch(reverse) Equal = self.assertEqual Equal(self.text.get('iomark', 'end-1c'), line) Equal(self.text._bell, bell) if bell: self.text._bell = False Equal(History.prefix, prefix) Equal(History.pointer, index) Equal(self.text.compare("insert", '==', "end-1c"), 1) def test_fetch_prev_cyclic(self): prefix = '' test = self.fetch_test test(True, line2, prefix, 1) test(True, line1, prefix, 0) test(True, prefix, None, None, bell=True) def test_fetch_next_cyclic(self): prefix = '' test = self.fetch_test test(False, line1, prefix, 0) test(False, line2, prefix, 1) test(False, prefix, None, None, bell=True) # Prefix 'a' tests skip line2, which starts with 'b' def test_fetch_prev_prefix(self): prefix = 'a' self.text.insert('iomark', prefix) self.fetch_test(True, line1, prefix, 0) self.fetch_test(True, prefix, None, None, bell=True) def test_fetch_next_prefix(self): prefix = 'a' self.text.insert('iomark', prefix) self.fetch_test(False, line1, prefix, 0) self.fetch_test(False, prefix, None, None, bell=True) def test_fetch_prev_noncyclic(self): prefix = '' self.history.cyclic = False test = self.fetch_test test(True, line2, prefix, 1) test(True, line1, prefix, 0) test(True, line1, prefix, 0, bell=True) def test_fetch_next_noncyclic(self): prefix = '' self.history.cyclic = False test = self.fetch_test test(False, prefix, None, None, bell=True) test(True, line2, prefix, 1) test(False, prefix, None, None, bell=True) test(False, prefix, None, None, bell=True) def test_fetch_cursor_move(self): # Move cursor after fetch self.history.fetch(reverse=True) # initialization self.text.mark_set('insert', 'iomark') self.fetch_test(True, line2, None, None, bell=True) def test_fetch_edit(self): # Edit after fetch self.history.fetch(reverse=True) # initialization self.text.delete('iomark', 'insert', ) self.text.insert('iomark', 'a =') self.fetch_test(True, line1, 'a =', 0) # prefix is reset def test_history_prev_next(self): # Minimally test functions bound to events self.history.history_prev('dummy event') self.assertEqual(self.history.pointer, 1) self.history.history_next('dummy event') self.assertEqual(self.history.pointer, None) if __name__ == '__main__': unittest.main(verbosity=2, exit=2) PK™e[|NNtest_hyperparser.pycnu[ {fc@sdZddlZddlmZddlmZmZddlmZddl m Z dddYZ d ej fd YZ ed krejd d ndS(s Unittest for idlelib.HyperParseriN(trequires(tTktText(t EditorWindow(t HyperParsert DummyEditwincBs)eZdZejjZejjZRS(cCs1||_d|_d|_t|_d|_dS(Nii2ii(i2ii(ttextt indentwidthttabwidthtTruetcontext_use_ps1tnum_context_lines(tselfR((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyt__init__ s     (t__name__t __module__R Rt_build_char_in_string_functim_functis_char_in_string(((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyRs  tHyperParserTestcBsteZdZedZedZdZdZdZdZ dZ dZ d Z d Z RS( s"""This is a module docstring""" # this line is a comment x = "this is a string" y = 'this is also a string' l = [i for i in range(10)] m = [py*py for # comment py in l] x.__len__ z = ((r'asdf')+('a'))) [x for x in for = False cCsKtdt|_|jjt|j|_t|j|_dS(Ntgui(RRtroottwithdrawRRRteditwin(tcls((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyt setUpClass#s    cCs#|`|`|jj|`dS(N(RRRtdestroy(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyt tearDownClass+s  cCs|jjd|jdS(Ntinsert(RRtcode(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pytsetUp1scCs#|jjddt|j_dS(Ns1.0tend(RtdeleteR RR (R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyttearDown4scCst|j|S(s> Return a parser object with index at 'index' (RR(R tindex((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyt get_parser8scCs|jt,}|jjddd|jd}WdQX|jdt|jt|j _ |jd}|j |j |jj dd|jjd|jj ddd|jd }dS( s6 test corner cases in the init method tconsoles1.0s1.ends1.5NtprecedesRis54.5(t assertRaisest ValueErrorRttag_addR#tassertIntstrt exceptiontFalseRR t assertEqualtrawtexttgetR(R tvetp((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyt test_init>s "&cCs|j}|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|jdS(Ns1.0s1.4s2.3s3.3s3.7s4.6(R#t assertFalset is_in_stringt assertTrue(R R/R1((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyttest_is_in_stringRs       cCs|j}|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|jdS(Ns1.0s1.1s2.5s3.4s3.6s4.14(R#R5t is_in_codeR3(R R/R1((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyttest_is_in_codebs       cCs4|j}d}d}|d}|j|||j|||d}|j||d|j|||||d}|j||d|j|||||d }|j||d|j|||d }|j|||j||dS(NcSs|jdtS(Nt mustclose(tget_surrounding_bracketsR,(tparser((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pytwithout_mustcloseuscSs|jdtS(NR9(R:R (R;((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pytwith_mustclosezss3.2s5.6s5.4s5.25s5.23s5.21s5.24s6.15s6.4s6.ends9.end(s5.4s5.25(s5.21s5.24(s6.4s6.end(R#t assertIsNonetassertTupleEqual(R R/R<R=R1((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyttest_get_surrounding_bracketrs$        cCs|j}|d}|j|jd|d}|jt}|jWdQX|jdt|j|d}|j|jd|d}|j|jd|d }|j|jd |d }|j|jd|d }|j|jd |d}|j|jd|d}|jt}|jWdQX|jdt|j|d}|j|jd |d}|j|jd |d}|j|jddS(Ns4.2sy s4.7sis inside a codes5.25s range(10)s6.7tpys6.8ts7.9s8.ends x.__len__s9.13sr'asdf's9.17s10.0s11.3s11.11R,(R#R-tget_expressionR&R'R)R*R+(R R/R1R0((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyttest_get_expressions:             (RRRt classmethodRRRR!R#R2R6R8R@RD(((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyRs        !t__main__t verbosityi((t__doc__tunittestttest.test_supportRtTkinterRRtidlelib.EditorWindowRtidlelib.HyperParserRRtTestCaseRRtmain(((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyts   PK™e[|NNtest_hyperparser.pyonu[ {fc@sdZddlZddlmZddlmZmZddlmZddl m Z dddYZ d ej fd YZ ed krejd d ndS(s Unittest for idlelib.HyperParseriN(trequires(tTktText(t EditorWindow(t HyperParsert DummyEditwincBs)eZdZejjZejjZRS(cCs1||_d|_d|_t|_d|_dS(Nii2ii(i2ii(ttextt indentwidthttabwidthtTruetcontext_use_ps1tnum_context_lines(tselfR((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyt__init__ s     (t__name__t __module__R Rt_build_char_in_string_functim_functis_char_in_string(((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyRs  tHyperParserTestcBsteZdZedZedZdZdZdZdZ dZ dZ d Z d Z RS( s"""This is a module docstring""" # this line is a comment x = "this is a string" y = 'this is also a string' l = [i for i in range(10)] m = [py*py for # comment py in l] x.__len__ z = ((r'asdf')+('a'))) [x for x in for = False cCsKtdt|_|jjt|j|_t|j|_dS(Ntgui(RRtroottwithdrawRRRteditwin(tcls((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyt setUpClass#s    cCs#|`|`|jj|`dS(N(RRRtdestroy(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyt tearDownClass+s  cCs|jjd|jdS(Ntinsert(RRtcode(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pytsetUp1scCs#|jjddt|j_dS(Ns1.0tend(RtdeleteR RR (R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyttearDown4scCst|j|S(s> Return a parser object with index at 'index' (RR(R tindex((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyt get_parser8scCs|jt,}|jjddd|jd}WdQX|jdt|jt|j _ |jd}|j |j |jj dd|jjd|jj ddd|jd }dS( s6 test corner cases in the init method tconsoles1.0s1.ends1.5NtprecedesRis54.5(t assertRaisest ValueErrorRttag_addR#tassertIntstrt exceptiontFalseRR t assertEqualtrawtexttgetR(R tvetp((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyt test_init>s "&cCs|j}|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|jdS(Ns1.0s1.4s2.3s3.3s3.7s4.6(R#t assertFalset is_in_stringt assertTrue(R R/R1((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyttest_is_in_stringRs       cCs|j}|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|jdS(Ns1.0s1.1s2.5s3.4s3.6s4.14(R#R5t is_in_codeR3(R R/R1((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyttest_is_in_codebs       cCs4|j}d}d}|d}|j|||j|||d}|j||d|j|||||d}|j||d|j|||||d }|j||d|j|||d }|j|||j||dS(NcSs|jdtS(Nt mustclose(tget_surrounding_bracketsR,(tparser((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pytwithout_mustcloseuscSs|jdtS(NR9(R:R (R;((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pytwith_mustclosezss3.2s5.6s5.4s5.25s5.23s5.21s5.24s6.15s6.4s6.ends9.end(s5.4s5.25(s5.21s5.24(s6.4s6.end(R#t assertIsNonetassertTupleEqual(R R/R<R=R1((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyttest_get_surrounding_bracketrs$        cCs|j}|d}|j|jd|d}|jt}|jWdQX|jdt|j|d}|j|jd|d}|j|jd|d }|j|jd |d }|j|jd|d }|j|jd |d}|j|jd|d}|jt}|jWdQX|jdt|j|d}|j|jd |d}|j|jd |d}|j|jddS(Ns4.2sy s4.7sis inside a codes5.25s range(10)s6.7tpys6.8ts7.9s8.ends x.__len__s9.13sr'asdf's9.17s10.0s11.3s11.11R,(R#R-tget_expressionR&R'R)R*R+(R R/R1R0((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyttest_get_expressions:             (RRRt classmethodRRRR!R#R2R6R8R@RD(((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyRs        !t__main__t verbosityi((t__doc__tunittestttest.test_supportRtTkinterRRtidlelib.EditorWindowRtidlelib.HyperParserRRtTestCaseRRtmain(((s:/usr/lib64/python2.7/idlelib/idle_test/test_hyperparser.pyts   PK™e[}J0J0 mock_tk.pyonu[ {fc@sdZdefdYZdefdYZdefdYZdefdYZd d lmZd efd YZd S(sClasses that replace tkinter gui objects used by an object being tested. A gui object is anything with a master or parent parameter, which is typically required in spite of what the doc strings say. tEventcBseZdZdZRS(sMinimal mock with attributes for testing event handlers. This is not a gui object, but is used as an argument for callbacks that access attributes of the event passed. If a callback ignores the event, other than the fact that is happened, pass 'event'. Keyboard, mouse, window, and other sources generate Event instances. Event instances have the following attributes: serial (number of event), time (of event), type (of event as number), widget (in which event occurred), and x,y (position of mouse). There are other attributes for specific events, such as keycode for key events. tkinter.Event.__doc__ has more but is still not complete. cKs|jj|dS(s,Create event with attributes needed for testN(t__dict__tupdate(tselftkwds((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt__init__s(t__name__t __module__t__doc__R(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyRs tVarcBs2eZdZddddZdZdZRS(s)Use for String/Int/BooleanVar: incompletecCs||_||_||_dS(N(tmastertvaluetname(RR R R ((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyRs  cCs ||_dS(N(R (RR ((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytsetscCs|jS(N(R (R((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytget!sN(RRRtNoneRR R(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR s t Mbox_funccBs#eZdZddZdZRS(sGeneric mock for messagebox functions, which all have the same signature. Instead of displaying a message box, the mock's call method saves the arguments as instance attributes, which test functions can then examime. The test can set the result returned to ask function cCs ||_dS(N(tresult(RR((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR+scOs+||_||_||_||_|jS(N(ttitletmessagetargsRR(RRRRR((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt__call__-s     N(RRRRRR(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR$s tMboxcBsVeZdZeZeZeZeZeZeZ eZ eZ RS(s5Mock for tkinter.messagebox with an Mbox_func for each function. This module was 'tkMessageBox' in 2.x; hence the 'import as' in 3.x. Example usage in test_module.py for testing functions in module.py: --- from idlelib.idle_test.mock_tk import Mbox import module orig_mbox = module.tkMessageBox showerror = Mbox.showerror # example, for attribute access in test methods class Test(unittest.TestCase): @classmethod def setUpClass(cls): module.tkMessageBox = Mbox @classmethod def tearDownClass(cls): module.tkMessageBox = orig_mbox --- For 'ask' functions, set func.result return value before calling the method that uses the message function. When tkMessageBox functions are the only gui alls in a method, this replacement makes the method gui-free, ( RRRRt askokcancelt askquestiontaskretrycanceltaskyesnotaskyesnocancelt showerrortshowinfot showwarning(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR5s       i(tTclErrortTextcBseZdZdidZdZddZdZdZddZ ddZ d Z d Z d Z dd Zd ZdZdZddddZRS(sA semi-functional non-gui replacement for tkinter.Text text editors. The mock's data model is that a text is a list of -terminated lines. The mock adds an empty string at the beginning of the list so that the index of actual lines start at 1, as with Tk. The methods never see this. Tk initializes files with a terminal that cannot be deleted. It is invisible in the sense that one cannot move the cursor beyond it. This class is only tested (and valid) with strings of ascii chars. For testing, we are not concerned with Tk Text's treatment of, for instance, 0-width characters or character + accent. cKsddg|_dS(sInitialize mock, non-gui, text-only Text widget. At present, all args are ignored. Almost all affect visual behavior. There are just a few Text-only options that affect text behavior. ts N(tdata(RR tcnftkw((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyRgscCsd|j|ddS(sAReturn string version of index decoded according to current text.s%s.%stendflagi(t_decode(Rtindex((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR'osicCsqt|ttfr$t|}ny|j}Wn!tk rWtd|nXt|jd}|dkr|t|j|dfS|dkr|j |S|j d\}}t |}|dkrdS||kr|j |St|j|d}|j ds'|dkr1||fSt |}|dkrRd}n||krg|}n||fS( s7Return a (line, char) tuple of int indexes into self.data. This implements .index without converting the result back to a string. The result is contrained by the number of lines and linelengths of self.data. For many indexes, the result is initially (1, 0). The input index may have any of several possible forms: * line.char float: converted to 'line.char' string; * 'line.char' string, where line and char are decimal integers; * 'line.char lineend', where lineend='lineend' (and char is ignored); * 'line.end', where end='end' (same as above); * 'insert', the positions before terminal ; * 'end', whose meaning depends on the endflag passed to ._endex. * 'sel.first' or 'sel.last', where sel is a tag -- not implemented. sbad text index "%s"itinserttendt.is lineend(ii( t isinstancetfloattbyteststrtlowertAttributeErrorRtlenR"t_endextsplittinttendswith(RR'R%tlastlinetlinetchart linelength((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR&ss4              cCsNt|j}|dkr%|dfS|d8}|t|j||fSdS(sReturn position for 'end' or line overflow corresponding to endflag. -1: position before terminal ; for .insert(), .delete 0: position after terminal ; for .get, .delete index 1 1: same viewed as beginning of non-existent next line (for .index) iiN(R1R"(RR%tn((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR2s    cCs|s dS|jt}|dddkr=|jdn|j|d\}}|j|| }|j||}||d|j|<|d|j|d|d+|j|t|dc|7s>=s==s!=s=bad comparison operator "%s": must be <, <=, ==, >=, >, or !=(R&R(RRCtopRDtline1tchar1tline2tchar2((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytcompares  " " " "  cCsdS(s.Set mark *name* before the character at index.N((RR R'((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytmark_set scGsdS(sDelete all marks in markNames.N((Rt markNames((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt mark_unsetR!cCsdS(sARemove tag tagName from all characters between index1 and index2.N((RttagNameRCRD((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt tag_removescCsdS(s2Adjust the view of the text according to scan_markN((Rtxty((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt scan_dragtoR!cCsdS(s&Remember the current X, Y coordinates.N((RRYRZ((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt scan_markR!cCsdS(s8Scroll screen to make the character at INDEX is visible.N((RR'((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytsee!scCsdS(s>Bind to this widget at event sequence a call to function func.N((tsequencetfunctadd((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytbind(sN(RRRRRR'R&R2R(RRKRSRTRVRXR[R\R]Ra(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR Zs    3           N( RtobjectRR RRt_tkinterRR (((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyts  #PK™e[ F77test_formatparagraph.pycnu[ {fc@s7ddlZddlmZddlmZddlmZmZddl m Z dej fdYZ dej fd YZ d ej fd YZd ej fd YZdej fdYZdddYZdddYZdej fdYZedkr3ejddddndS(iN(tFormatParagraph(t EditorWindow(tTktText(trequirest Is_Get_TestcBsGeZdZdZdZdZdZdZdZdZ dZ RS( sTest the is_ and get_ functionss# This is a commentsThis is not a comments# This is a comment s # This is a comments This is not a commentcCsI|jtjd|jtjd|jtj|jdS(Nts (t assertTruetfpt is_all_whitet assertFalset test_comment(tself((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_is_all_whitescCsq|j}|tj|jd|tj|jd|tj|jd|tj|jddS(NRs (t assertEqualRt get_indentR ttrailingws_commenttleadingws_commenttleadingws_nocomment(R tEqual((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_get_indents  cCs|j}|tj|jd|tj|jd|tj|jd|tj|jd|tj|jddS(Nt#s #s R(RRtget_comment_headerR RRRttest_nocomment(R R((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_get_comment_headers  ( t__name__t __module__t__doc__R RRRRR RR(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR s  tFindTestcBs8eZdZedZdZdZdZRS(s`Test the find_paragraph function in FormatParagraph. Using the runcase() function, find_paragraph() is called with 'mark' set at multiple indexes before and inside the test paragraph. It appears that code with the same indentation as a quoted string is grouped as part of the same paragraph, which is probably incorrect behavior. cCs ddlm}||_dS(Ni(R(tidlelib.idle_test.mock_tkRttext(tclsR((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt setUpClass2sc Cs|j}|jd|xtd|D]v}t|jd|jdd}xGd|d|fD]2}d||f}|jtj|||qiWq)W|j dddS( Ns1.0is%d.endt.iis%d.%dtend( RtinserttrangetinttindextsplitRRtfind_paragraphtdelete( R t inserttexttstoplinetexpectedRtlinet linelengthtcolt tempindex((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pytruncase7s &$c Csdd}|j|dddd|dd!fd}|j|d d d d|d d !fd}|j|d d d d|d d!fd}|j|dd dd|d d!fd}|j|dd dd|d d!fd}|j|dd dd|d d!fd}|j|dd dd|d d!fd}|j|dd dd|d d!fdS(Ns;# Comment block with no blank lines before # Comment line is1.0s3.0Rii:sG # Comment block with whitespace line before and after # Comment line is2.0s4.0iiFsS # Indented comment block with whitespace before and after # Comment line s #iRs # Single line comment is4 # Single line comment with leading whitespace i3s0 # Comment immediately followed by code x = 42 i(s= # Indented comment immediately followed by code x = 42 i5s= # Comment immediately followed by indented code x = 42 i1(R1(R tcomment((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_find_commentDs &&&&&&&c Csd}|j|dddd|dd!fd}|j|d d d d|d d !fd}|j|d d d d|d d!fd}|j|dd dd|d d!fd}|j|dd dd|d d!fdS(Ns6"""String with no blank lines before String line """ is1.0s4.0Rii5sC """String with whitespace line before and after String line. """ is2.0s5.0iiBsV """Indented string with whitespace before and after Comment string. """ s iUs """Single line string.""" is3.0is8 """Single line string with leading whitespace.""" i7(R1(R t teststring((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_find_paragraphzs&&&&(RRRt classmethodR R1R3R5(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR(s  6tReformatFunctionTestcBseZdZdZRS(s?Test the reformat_paragraph function without the editor window.cCs*|j}tj}d}||ddd||ddd|||dd|||dd|||d d |||d d |||d dd }|||dd|||dd|||d d|||d d|||d d dS(Ns O hello worldt isHello worldis Hello worlds O hello worldiis O hello worldi i s O hello worlds O hello worlds O hello world(RRtreformat_paragraph(R Rtreformthw((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_reformat_paragraphs   (RRRR<(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR7stReformatCommentTestcBseZdZdZRS(s=Test the reformat_comment function without the editor window.cCsi|j}d}tj|dd}d}|||d}tj|dd}d}|||dS(Nsu """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""iFs sy """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""sm# this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?Rso# this is a test of a reformat for a triple quoted string will it # reformat to less than 70 characters for me?(RRtreformat_comment(R Rt test_stringtresultR,R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_reformat_comments  (RRRRA(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR=stFormatClassTestcBseZdZRS(cCsCtjd}|j|jd|j|j|jddS(Nteditor(RRRteditwintclosetNone(R tinstance((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_init_closes (RRRH(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRBst TextWrappercBs,eZdZdZdZdZRS(cCstd||_dS(Ntmaster(RR(R RJ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt__init__scCst|j|S(N(tgetattrR(R tname((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt __getattr__scCsdS(N((R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pytundo_block_startRcCsdS(N((R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pytundo_block_stopR(RRRKRNRORP(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRIs   tEditorcBseZdZejjZRS(cCst||_dS(N(RIR(R troot((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRKs(RRRKRtget_selection_indicestim_func(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRQs tFormatEventTestcBsbeZdZdZdZdZedZedZdZ dZ dZ d Z RS( sTest the formatting of text inside a Text widget. This is done with FormatParagraph.format.paragraph_event, which calls functions in the module as appropriate. sv '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?''' s '''The first line is under the max width. The second line's length is way over the max width. It goes on and on until it is over 100 characters long. Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it. ''' s,# The first line is under the max width. # The second line's length is way over the max width. It goes on and on until it is over 100 characters long. # Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it. # The fourth line is short like the first line.cCsPtdt|_td|j}|jj|_tj|j|_dS(NtguiRR( RRRRRQRRRtformat_paragraph_eventt formatter(RRC((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR s   cCs#|`|`|jj|`dS(N(RRXRRtdestroy(R((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt tearDownClasss  cCsV|jjdd|jd|j|jjddd|jjdddS(Ns1.0s Short line tDummyR#R"(RR#RXRtgetR)(R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_short_lines cCs|j}|jd|j|jdd|jddd|jdd}d}|j|||jdd|jd|j|jdd d |jddd|jdd}d }|j|||jdddS( Ns1.0R#tParameterDoesNothingtlimitiFsz '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?''' R"tsels1.11s1.endsv '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?'''( RR#R?tmark_setRXR\RR)ttag_add(R RR@R,((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_long_line!s cCs~|j}|jd|j|jddd|jddd|jdd}d }|j|||jdd dS( Ns1.0R`s2.0s4.0R^R_iFR#s The second line's length is way over the max width. It goes on and on until it is over 100 characters long. Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it. R"(RR#tmultiline_test_stringRbRXR\RR)(R RR@R,((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_multiple_lines<s cCs|j}|jd|j|jddd|jdd}d}|j|||jdd|jd|j|jdd d |jddd|jdd}d }|j|||jdddS( Ns1.0R^R_iFR#s/# The first line is under the max width. The second line's length is # way over the max width. It goes on and on until it is over 100 # characters long. Same thing with the third line. It is also way over # the max width, but FormatParagraph will fix it. The fourth line is # short like the first line. R"R`s2.0s3.0s# The first line is under the max width. # The second line's length is way over the max width. It goes on and # on until it is over 100 characters long. (RR#tmultiline_test_commentRXR\RR)Rb(R RR@R,((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_comment_blockKs ( RRRR?RdRfR6R RZR]RcReRg(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRUs    t__main__t verbosityitexit(((tunittesttidlelibRRtidlelib.EditorWindowRtTkinterRRttest.test_supportRtTestCaseRRR7R=RBRIRQRURtmain(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyts w PK™e[test_autocomplete.pycnu[ {fc@sddlZddlmZddlmZmZddljZddl j Z ddl m Z ddlmZdddYZ ddd YZd ejfd YZed krejd dndS(iN(trequires(tTktText(tFunc(tEventtAutoCompleteWindowcBseZdZRS(cCsdS(N((((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pytcomplete s(t__name__t __module__R(((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyR st DummyEditwincBseZdZRS(cCs1||_||_d|_d|_t|_dS(Ni(trootttextt indentwidthttabwidthtTruetcontext_use_ps1(tselfR R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyt__init__s     (RRR(((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyR stAutoCompleteTestcBseZedZedZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZRS(cCsDtdt|_t|j|_t|j|j|_dS(Ntgui(RRR RR R teditor(tcls((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyt setUpClasss  cCs#|`|`|jj|`dS(N(RR R tdestroy(R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyt tearDownClass s  cCs/|jjjddtj|j|_dS(Ns1.0tend(RR tdeletetact AutoCompletet autocomplete(R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pytsetUp&scCs|j|jj|jdS(N(t assertEqualRteditwinR(R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyt test_init*scCs&|jj}|j|tjdS(N(Rt_make_autocomplete_windowtassertIsInstancetacwR(Rttestwin((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_make_autocomplete_window-scCs9|jj|j_|jj|j|jjdS(N(RR"tautocompletewindowt_remove_autocomplete_windowt assertIsNone(R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_remove_autocomplete_window1s cCsEt}||j_|jjd|j|jtttfdS(Ntevent(RRtopen_completionstforce_open_completions_eventRtargsRtFalse(Rto_cs((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyt!test_force_open_completions_event7s  cCs|j}|j}|jj}t}||_|d||jd|jjdd|d||jt t t df|jj dd|jjdd|d||jt t t dfdS(NR+s1.0sre.iRs"./Lib/i( RRttry_open_completions_eventRt_open_completions_laterR.tNoneR tinsertR/R(RtEqualRttrycompletionsto_c_l((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_try_open_completions_event>s        cCs|j}|j}tdt}|j|j||`|jjdd||jj|d|j t }||_ ||jj|d||j tttft|_||jj|d||j tttfdS(Ntmc_states1.0sre.tbreak(RRRRR)tautocomplete_eventR:R R5R(RR,R4R.R/tresult(RR6RtevR0((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_autocomplete_eventTs      cCsdS(N((R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_open_completions_laternscCsdS(N((R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_delayed_open_completionsrscCsdS(N((R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_open_completionsxscCsdS(N((R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_fetch_completions}scCsdS(N((R((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyttest_get_entitys(RRt classmethodRRRR!R&R*R1R9R?R@RARBRCRD(((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyRs           t__main__t verbosityi(((tunittestttest.test_supportRtTkinterRRtidlelib.AutoCompleteRRtidlelib.AutoCompleteWindowRR$tidlelib.idle_test.mock_idleRtidlelib.idle_test.mock_tkRR tTestCaseRRtmain(((s;/usr/lib64/python2.7/idlelib/idle_test/test_autocomplete.pyts  t PK™e[055htest.pynu['''Run human tests of Idle's window, dialog, and popup widgets. run(*tests) Create a master Tk window. Within that, run each callable in tests after finding the matching test spec in this file. If tests is empty, run an htest for each spec dict in this file after finding the matching callable in the module named in the spec. Close the window to skip or end the test. In a tested module, let X be a global name bound to a callable (class or function) whose .__name__ attrubute is also X (the usual situation). The first parameter of X must be 'parent'. When called, the parent argument will be the root window. X must create a child Toplevel window (or subclass thereof). The Toplevel may be a test widget or dialog, in which case the callable is the corresonding class. Or the Toplevel may contain the widget to be tested or set up a context in which a test widget is invoked. In this latter case, the callable is a wrapper function that sets up the Toplevel and other objects. Wrapper function names, such as _editor_window', should start with '_'. End the module with if __name__ == '__main__': from idlelib.idle_test.htest import run run(X) To have wrapper functions and test invocation code ignored by coveragepy reports, put '# htest #' on the def statement header line. def _wrapper(parent): # htest # Also make sure that the 'if __name__' line matches the above. Then have make sure that .coveragerc includes the following. [report] exclude_lines = .*# htest # if __name__ == .__main__.: (The "." instead of "'" is intentional and necessary.) To run any X, this file must contain a matching instance of the following template, with X.__name__ prepended to '_spec'. When all tests are run, the prefix is use to get X. _spec = { 'file': '', 'kwds': {'title': ''}, 'msg': "" } file (no .py): run() imports file.py. kwds: augmented with {'parent':root} and passed to X as **kwds. title: an example kwd; some widgets need this, delete if not. msg: master window hints about testing the widget. Modules and classes not being tested at the moment: PyShell.PyShellEditorWindow Debugger.Debugger AutoCompleteWindow.AutoCompleteWindow OutputWindow.OutputWindow (indirectly being tested with grep test) ''' from importlib import import_module from idlelib.macosxSupport import _initializeTkVariantTests import Tkinter as tk AboutDialog_spec = { 'file': 'aboutDialog', 'kwds': {'title': 'aboutDialog test', '_htest': True, }, 'msg': "Test every button. Ensure Python, TK and IDLE versions " "are correctly displayed.\n [Close] to exit.", } _calltip_window_spec = { 'file': 'CallTipWindow', 'kwds': {}, 'msg': "Typing '(' should display a calltip.\n" "Typing ') should hide the calltip.\n" } _class_browser_spec = { 'file': 'ClassBrowser', 'kwds': {}, 'msg': "Inspect names of module, class(with superclass if " "applicable), methods and functions.\nToggle nested items.\n" "Double clicking on items prints a traceback for an exception " "that is ignored." } _color_delegator_spec = { 'file': 'ColorDelegator', 'kwds': {}, 'msg': "The text is sample Python code.\n" "Ensure components like comments, keywords, builtins,\n" "string, definitions, and break are correctly colored.\n" "The default color scheme is in idlelib/config-highlight.def" } ConfigDialog_spec = { 'file': 'configDialog', 'kwds': {'title': 'ConfigDialogTest', '_htest': True,}, 'msg': "IDLE preferences dialog.\n" "In the 'Fonts/Tabs' tab, changing font face, should update the " "font face of the text in the area below it.\nIn the " "'Highlighting' tab, try different color schemes. Clicking " "items in the sample program should update the choices above it." "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings " "of interest." "\n[Ok] to close the dialog.[Apply] to apply the settings and " "and [Cancel] to revert all changes.\nRe-run the test to ensure " "changes made have persisted." } # TODO Improve message _dyn_option_menu_spec = { 'file': 'dynOptionMenuWidget', 'kwds': {}, 'msg': "Select one of the many options in the 'old option set'.\n" "Click the button to change the option set.\n" "Select one of the many options in the 'new option set'." } # TODO edit wrapper _editor_window_spec = { 'file': 'EditorWindow', 'kwds': {}, 'msg': "Test editor functions of interest.\n" "Best to close editor first." } GetCfgSectionNameDialog_spec = { 'file': 'configSectionNameDialog', 'kwds': {'title':'Get Name', 'message':'Enter something', 'used_names': {'abc'}, '_htest': True}, 'msg': "After the text entered with [Ok] is stripped, , " "'abc', or more that 30 chars are errors.\n" "Close 'Get Name' with a valid entry (printed to Shell), " "[Cancel], or [X]", } GetHelpSourceDialog_spec = { 'file': 'configHelpSourceEdit', 'kwds': {'title': 'Get helpsource', '_htest': True}, 'msg': "Enter menu item name and help file path\n " " and more than 30 chars are invalid menu item names.\n" ", file does not exist are invalid path items.\n" "Test for incomplete web address for help file path.\n" "A valid entry will be printed to shell with [0k].\n" "[Cancel] will print None to shell", } # Update once issue21519 is resolved. GetKeysDialog_spec = { 'file': 'keybindingDialog', 'kwds': {'title': 'Test keybindings', 'action': 'find-again', 'currentKeySequences': [''] , '_htest': True, }, 'msg': "Test for different key modifier sequences.\n" " is invalid.\n" "No modifier key is invalid.\n" "Shift key with [a-z],[0-9], function key, move key, tab, space " "is invalid.\nNo validitity checking if advanced key binding " "entry is used." } _grep_dialog_spec = { 'file': 'GrepDialog', 'kwds': {}, 'msg': "Click the 'Show GrepDialog' button.\n" "Test the various 'Find-in-files' functions.\n" "The results should be displayed in a new '*Output*' window.\n" "'Right-click'->'Goto file/line' anywhere in the search results " "should open that file \nin a new EditorWindow." } _io_binding_spec = { 'file': 'IOBinding', 'kwds': {}, 'msg': "Test the following bindings.\n" " to open file from dialog.\n" "Edit the file.\n" " to print the file.\n" " to save the file.\n" " to save-as another file.\n" " to save-copy-as another file.\n" "Check that changes were saved by opening the file elsewhere." } _multi_call_spec = { 'file': 'MultiCall', 'kwds': {}, 'msg': "The following actions should trigger a print to console or IDLE" " Shell.\nEntering and leaving the text area, key entry, " ",\n, , " ", \n, and " "focusing out of the window\nare sequences to be tested." } _multistatus_bar_spec = { 'file': 'MultiStatusBar', 'kwds': {}, 'msg': "Ensure presence of multi-status bar below text area.\n" "Click 'Update Status' to change the multi-status text" } _object_browser_spec = { 'file': 'ObjectBrowser', 'kwds': {}, 'msg': "Double click on items upto the lowest level.\n" "Attributes of the objects and related information " "will be displayed side-by-side at each level." } _path_browser_spec = { 'file': 'PathBrowser', 'kwds': {}, 'msg': "Test for correct display of all paths in sys.path.\n" "Toggle nested items upto the lowest level.\n" "Double clicking on an item prints a traceback\n" "for an exception that is ignored." } _percolator_spec = { 'file': 'Percolator', 'kwds': {}, 'msg': "There are two tracers which can be toggled using a checkbox.\n" "Toggling a tracer 'on' by checking it should print tracer " "output to the console or to the IDLE shell.\n" "If both the tracers are 'on', the output from the tracer which " "was switched 'on' later, should be printed first\n" "Test for actions like text entry, and removal." } _replace_dialog_spec = { 'file': 'ReplaceDialog', 'kwds': {}, 'msg': "Click the 'Replace' button.\n" "Test various replace options in the 'Replace dialog'.\n" "Click [Close] or [X] to close the 'Replace Dialog'." } _search_dialog_spec = { 'file': 'SearchDialog', 'kwds': {}, 'msg': "Click the 'Search' button.\n" "Test various search options in the 'Search dialog'.\n" "Click [Close] or [X] to close the 'Search Dialog'." } _scrolled_list_spec = { 'file': 'ScrolledList', 'kwds': {}, 'msg': "You should see a scrollable list of items\n" "Selecting (clicking) or double clicking an item " "prints the name to the console or Idle shell.\n" "Right clicking an item will display a popup." } show_idlehelp_spec = { 'file': 'help', 'kwds': {}, 'msg': "If the help text displays, this works.\n" "Text is selectable. Window is scrollable." } _stack_viewer_spec = { 'file': 'StackViewer', 'kwds': {}, 'msg': "A stacktrace for a NameError exception.\n" "Expand 'idlelib ...' and ''.\n" "Check that exc_value, exc_tb, and exc_type are correct.\n" } _tabbed_pages_spec = { 'file': 'tabbedpages', 'kwds': {}, 'msg': "Toggle between the two tabs 'foo' and 'bar'\n" "Add a tab by entering a suitable name for it.\n" "Remove an existing tab by entering its name.\n" "Remove all existing tabs.\n" " is an invalid add page and remove page name.\n" } TextViewer_spec = { 'file': 'textView', 'kwds': {'title': 'Test textView', 'text':'The quick brown fox jumps over the lazy dog.\n'*35, '_htest': True}, 'msg': "Test for read-only property of text.\n" "Text is selectable. Window is scrollable.", } _tooltip_spec = { 'file': 'ToolTip', 'kwds': {}, 'msg': "Place mouse cursor over both the buttons\n" "A tooltip should appear with some text." } _tree_widget_spec = { 'file': 'TreeWidget', 'kwds': {}, 'msg': "The canvas is scrollable.\n" "Click on folders upto to the lowest level." } _undo_delegator_spec = { 'file': 'UndoDelegator', 'kwds': {}, 'msg': "Click [Undo] to undo any action.\n" "Click [Redo] to redo any action.\n" "Click [Dump] to dump the current state " "by printing to the console or the IDLE shell.\n" } _widget_redirector_spec = { 'file': 'WidgetRedirector', 'kwds': {}, 'msg': "Every text insert should be printed to the console " "or the IDLE shell." } def run(*tests): root = tk.Tk() root.title('IDLE htest') root.resizable(0, 0) _initializeTkVariantTests(root) # a scrollable Label like constant width text widget. frameLabel = tk.Frame(root, padx=10) frameLabel.pack() text = tk.Text(frameLabel, wrap='word') text.configure(bg=root.cget('bg'), relief='flat', height=4, width=70) scrollbar = tk.Scrollbar(frameLabel, command=text.yview) text.config(yscrollcommand=scrollbar.set) scrollbar.pack(side='right', fill='y', expand=False) text.pack(side='left', fill='both', expand=True) test_list = [] # List of tuples of the form (spec, callable widget) if tests: for test in tests: test_spec = globals()[test.__name__ + '_spec'] test_spec['name'] = test.__name__ test_list.append((test_spec, test)) else: for k, d in globals().items(): if k.endswith('_spec'): test_name = k[:-5] test_spec = d test_spec['name'] = test_name mod = import_module('idlelib.' + test_spec['file']) test = getattr(mod, test_name) test_list.append((test_spec, test)) test_name = [tk.StringVar('')] callable_object = [None] test_kwds = [None] def next(): if len(test_list) == 1: next_button.pack_forget() test_spec, callable_object[0] = test_list.pop() test_kwds[0] = test_spec['kwds'] test_kwds[0]['parent'] = root test_name[0].set('Test ' + test_spec['name']) text.configure(state='normal') # enable text editing text.delete('1.0','end') text.insert("1.0",test_spec['msg']) text.configure(state='disabled') # preserve read-only property def run_test(): widget = callable_object[0](**test_kwds[0]) try: print(widget.result) except AttributeError: pass button = tk.Button(root, textvariable=test_name[0], command=run_test) button.pack() next_button = tk.Button(root, text="Next", command=next) next_button.pack() next() root.mainloop() if __name__ == '__main__': run() PK™e[)WWtest_editmenu.pyonu[ {fc@szdZddlmZddlZddlZddlmZdejfdYZ e dkrvej dd ndS( sTTest (selected) IDLE Edit menu items. Edit modules have their own test files files i(trequiresN(tPyShellt PasteTestcBsbeZdZedZedZdZdZdZdZ dZ dZ RS( seTest pasting into widgets that allow pasting. On X11, replacing selections requires tk fix. cCstdtj|_}|jtj|tj||_tj ||_ tj ||_ |j |jddS(Ntguittwo(RttktTktroottwithdrawRt fix_x11_pastetTextttexttEntrytentrytSpinboxtspintclipboard_cleartclipboard_append(tclsR((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyt setUpClasss    cCsP|`|`|`|jj|jj|jj|jj|`dS(N(R R RRRtupdate_idletaskstupdatetdestroy(R((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyt tearDownClasss     cCse|j}d\}}|jdd|jdd||jd|j|jdd|dS( s+Test pasting into text without a selection.tsonetwo s1.0tendtones <>N(Rsonetwo (R tdeletetinserttevent_generatet assertEqualtget(tselfR ttagtans((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_text_no_selection&s    cCse|j}d\}}|jdd|jdd||jd|j|jdd|dS( s(Test pasting into text with a selection.tselstwo s1.0RRs <>N(R$stwo (R RRRRR(R R R!R"((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_text_selection/s    cCsl|j}d\}}|jdd|jdd|jd||jd|j|j|dS(s/Test pasting into an entry without a selection.itonetwoRRs <>N(iR&(R RRt select_rangeRRR(R R RR"((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_entry_no_selection8s   cCsl|j}d\}}|jdd|jdd|jd||jd|j|j|dS(s,Test pasting into an entry with a selection.RRiRs <>N(RR(R RRR'RRR(R R RR"((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_entry_selectionDs   cCso|j}d\}}|jdd|jdd|jdd||jd|j|j|dS( s0Test pasting into a spinbox without a selection.iR&RRtranges <>N(iR&(RRRt selectionRRR(R RRR"((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_spin_no_selectionNs   cCso|j}d\}}|jdd|jdd|jdd||jd|j|j|dS( s-Test pasting into a spinbox with a selection.RRiRR*s <>N(RR(RRRR+RRR(R RRR"((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyttest_paste_spin_selectionYs   ( t__name__t __module__t__doc__t classmethodRRR#R%R(R)R,R-(((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyR s  t__main__t verbosityi( R0ttest.test_supportRtTkinterRtunittesttidlelibRtTestCaseRR.tmain(((s7/usr/lib64/python2.7/idlelib/idle_test/test_editmenu.pyts  Y PK™e[мtest_widgetredir.pyonu[ {fc@sdZddlmZddlZddlmZddlmZmZm Z ddl m Z dej fdYZ d ej fd YZed krejd d ndS(s5Unittest for idlelib.WidgetRedirector 100% coverage i(trequiresN(tFunc(tTktTexttTclError(tWidgetRedirectort InitCloseTestcBs8eZedZedZdZdZRS(cCs9tdt|_|jjt|j|_dS(Ntgui(RRtroottwithdrawRttext(tcls((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt setUpClasss   cCs|`|jj|`dS(N(R Rtdestroy(R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt tearDownClasss cCsbt|j}|j|j|j|j|j|jj|jtt|j|jdS(N(RR t assertEqualtwidgetttkt assertRaisesRtclose(tselftredir((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt test_inits cCsYt|j}|jdt|j|j|ji|jt|jddS(NtinsertR( RR tregisterRRRt _operationst assertFalsethasattr(RR((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt test_close"s  (t__name__t __module__t classmethodR RRR(((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyR s tWidgetRedirectorTestcBseZedZedZdZdZdZdZdZ dZ dZ d Z d Z d Zd ZRS( cCs9tdt|_|jjt|j|_dS(NR(RRRR RR (R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyR ,s   cCs|`|jj|`dS(N(R RR (R ((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyR3s cCsPt|j|_t|_|jjd|j|_|jjdddS(NRtasdf(RR RRtfuncRt orig_insertR(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pytsetUp9s cCs$|jjdd|jjdS(Ns1.0tend(R tdeleteRR(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttearDown?scCs6|jdt|j|jdt|jdS(Nt RedirectortOriginal(tassertIntreprRR#(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt test_reprCscCs~|j|jjddd|j|jjd|jd|jj|jd|jj|j|jj |jdS(Ns1.0R%s RR!(RR!( RR tgetR"targsR*RRt__dict__R(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyt test_registerGs cCsh|j|jjd|j|jj|jjj|jdd|j|jjddddS(NRR!s1.0R%sasdf (RR#t operationttk_callR RtcallR-(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_original_commandNscCsh|j|jjd|j|jjd|j|jd|jj|jd|jjdS(Nsinvalid operation nameR( t assertIsNoneRt unregisterRR"t assertNotInRR R/(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_unregisterTscCs,|j`|j|jjd|jdS(NR(R RRRR6R"(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_unregister_no_attributeZs cCsG|jjt|j|jjdt|j|jjddS(NRi( R"t__init__tTruet assertTrueRtdispatchtFalseRR.(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_dispatch_intercept^scCsU|jdd|j|jjdddd|j|jjddddS(NRR!R&s1.0R%ts (R#RRR=R R-(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_dispatch_bypasscs"cCsR|jjt|j|jjdtd|j|jjdddS(NRR@tinvalid(R"R:RRRR=R>(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_dispatch_erroriscCs|jj|jjdd|j|jjd|j|jjddd|jjt |j|jj|jjddddS( NRthellos1.0R%s tbooR@(RD( RR3R t_wRR"R.R-R:R(R((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyttest_command_dispatchns (RRRR RR$R'R,R0R4R8R9R?RARCRG(((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyR *s          t__main__t verbosityi(t__doc__ttest.test_supportRtunittesttidlelib.idle_test.mock_idleRtTkinterRRRtidlelib.WidgetRedirectorRtTestCaseRR Rtmain(((s:/usr/lib64/python2.7/idlelib/idle_test/test_widgetredir.pyts Q PK™e[ޅy8181 htest.pycnu[ {fc@sdZddlmZddlmZddlZidd6idd6ed 6d 6d d 6Zid d6id 6dd 6Z idd6id 6dd 6Z idd6id 6dd 6Z idd6idd6ed 6d 6dd 6Z idd6id 6dd 6Z idd6id 6dd 6Zidd6idd6dd6dhd6ed 6d 6d d 6Zid!d6id"d6ed 6d 6d#d 6Zid$d6id%d6d&d'6d(gd)6ed 6d 6d*d 6Zid+d6id 6d,d 6Zid-d6id 6d.d 6Zid/d6id 6d0d 6Zid1d6id 6d2d 6Zid3d6id 6d4d 6Zid5d6id 6d6d 6Zid7d6id 6d8d 6Zid9d6id 6d:d 6Zid;d6id 6d<d 6Zid=d6id 6d>d 6Zid?d6id 6d@d 6ZidAd6id 6dBd 6ZidCd6id 6dDd 6ZidEd6idFd6dGdHdI6ed 6d 6dJd 6ZidKd6id 6dLd 6Z idMd6id 6dNd 6Z!idOd6id 6dPd 6Z"idQd6id 6dRd 6Z#dSZ$e%dTkre$ndS(UsRun human tests of Idle's window, dialog, and popup widgets. run(*tests) Create a master Tk window. Within that, run each callable in tests after finding the matching test spec in this file. If tests is empty, run an htest for each spec dict in this file after finding the matching callable in the module named in the spec. Close the window to skip or end the test. In a tested module, let X be a global name bound to a callable (class or function) whose .__name__ attrubute is also X (the usual situation). The first parameter of X must be 'parent'. When called, the parent argument will be the root window. X must create a child Toplevel window (or subclass thereof). The Toplevel may be a test widget or dialog, in which case the callable is the corresonding class. Or the Toplevel may contain the widget to be tested or set up a context in which a test widget is invoked. In this latter case, the callable is a wrapper function that sets up the Toplevel and other objects. Wrapper function names, such as _editor_window', should start with '_'. End the module with if __name__ == '__main__': from idlelib.idle_test.htest import run run(X) To have wrapper functions and test invocation code ignored by coveragepy reports, put '# htest #' on the def statement header line. def _wrapper(parent): # htest # Also make sure that the 'if __name__' line matches the above. Then have make sure that .coveragerc includes the following. [report] exclude_lines = .*# htest # if __name__ == .__main__.: (The "." instead of "'" is intentional and necessary.) To run any X, this file must contain a matching instance of the following template, with X.__name__ prepended to '_spec'. When all tests are run, the prefix is use to get X. _spec = { 'file': '', 'kwds': {'title': ''}, 'msg': "" } file (no .py): run() imports file.py. kwds: augmented with {'parent':root} and passed to X as **kwds. title: an example kwd; some widgets need this, delete if not. msg: master window hints about testing the widget. Modules and classes not being tested at the moment: PyShell.PyShellEditorWindow Debugger.Debugger AutoCompleteWindow.AutoCompleteWindow OutputWindow.OutputWindow (indirectly being tested with grep test) i(t import_module(t_initializeTkVariantTestsNt aboutDialogtfilesaboutDialog testttitlet_htesttkwdssaTest every button. Ensure Python, TK and IDLE versions are correctly displayed. [Close] to exit.tmsgt CallTipWindowsHTyping '(' should display a calltip. Typing ') should hide the calltip. t ClassBrowsersInspect names of module, class(with superclass if applicable), methods and functions. Toggle nested items. Double clicking on items prints a traceback for an exception that is ignored.tColorDelegatorsThe text is sample Python code. Ensure components like comments, keywords, builtins, string, definitions, and break are correctly colored. The default color scheme is in idlelib/config-highlight.deft configDialogtConfigDialogTestsIDLE preferences dialog. In the 'Fonts/Tabs' tab, changing font face, should update the font face of the text in the area below it. In the 'Highlighting' tab, try different color schemes. Clicking items in the sample program should update the choices above it. In the 'Keys', 'General' and 'Extensions' tabs, test settings of interest. [Ok] to close the dialog.[Apply] to apply the settings and and [Cancel] to revert all changes. Re-run the test to ensure changes made have persisted.tdynOptionMenuWidgetsSelect one of the many options in the 'old option set'. Click the button to change the option set. Select one of the many options in the 'new option set'.t EditorWindows>Test editor functions of interest. Best to close editor first.tconfigSectionNameDialogsGet NamesEnter somethingtmessagetabct used_namessAfter the text entered with [Ok] is stripped, , 'abc', or more that 30 chars are errors. Close 'Get Name' with a valid entry (printed to Shell), [Cancel], or [X]tconfigHelpSourceEditsGet helpsources%Enter menu item name and help file path and more than 30 chars are invalid menu item names. , file does not exist are invalid path items. Test for incomplete web address for help file path. A valid entry will be printed to shell with [0k]. [Cancel] will print None to shelltkeybindingDialogsTest keybindingss find-againtactionttcurrentKeySequencessTest for different key modifier sequences. is invalid. No modifier key is invalid. Shift key with [a-z],[0-9], function key, move key, tab, space is invalid. No validitity checking if advanced key binding entry is used.t GrepDialogsClick the 'Show GrepDialog' button. Test the various 'Find-in-files' functions. The results should be displayed in a new '*Output*' window. 'Right-click'->'Goto file/line' anywhere in the search results should open that file in a new EditorWindow.t IOBindingsTest the following bindings. to open file from dialog. Edit the file. to print the file. to save the file. to save-as another file. to save-copy-as another file. Check that changes were saved by opening the file elsewhere.t MultiCallsThe following actions should trigger a print to console or IDLE Shell. Entering and leaving the text area, key entry, , , , , , and focusing out of the window are sequences to be tested.tMultiStatusBarsjEnsure presence of multi-status bar below text area. Click 'Update Status' to change the multi-status textt ObjectBrowsersDouble click on items upto the lowest level. Attributes of the objects and related information will be displayed side-by-side at each level.t PathBrowsersTest for correct display of all paths in sys.path. Toggle nested items upto the lowest level. Double clicking on an item prints a traceback for an exception that is ignored.t PercolatorsAThere are two tracers which can be toggled using a checkbox. Toggling a tracer 'on' by checking it should print tracer output to the console or to the IDLE shell. If both the tracers are 'on', the output from the tracer which was switched 'on' later, should be printed first Test for actions like text entry, and removal.t ReplaceDialogsClick the 'Replace' button. Test various replace options in the 'Replace dialog'. Click [Close] or [X] to close the 'Replace Dialog'.t SearchDialogsClick the 'Search' button. Test various search options in the 'Search dialog'. Click [Close] or [X] to close the 'Search Dialog'.t ScrolledListsYou should see a scrollable list of items Selecting (clicking) or double clicking an item prints the name to the console or Idle shell. Right clicking an item will display a popup.thelpsPIf the help text displays, this works. Text is selectable. Window is scrollable.t StackViewersA stacktrace for a NameError exception. Expand 'idlelib ...' and ''. Check that exc_value, exc_tb, and exc_type are correct. t tabbedpagessToggle between the two tabs 'foo' and 'bar' Add a tab by entering a suitable name for it. Remove an existing tab by entering its name. Remove all existing tabs. is an invalid add page and remove page name. ttextViews Test textViews-The quick brown fox jumps over the lazy dog. i#ttextsNTest for read-only property of text. Text is selectable. Window is scrollable.tToolTipsPPlace mouse cursor over both the buttons A tooltip should appear with some text.t TreeWidgetsDThe canvas is scrollable. Click on folders upto to the lowest level.t UndoDelegatorsClick [Undo] to undo any action. Click [Redo] to redo any action. Click [Dump] to dump the current state by printing to the console or the IDLE shell. tWidgetRedirectorsEEvery text insert should be printed to the console or the IDLE shell.c stjjdjddttjdd}|jtj|ddjdj ddd d d d d tj |dj }j d|j |jdddddtjdddddtg|rIx|D]:}t|jd}|j|d<j||fqWnxtjD]n\}}|jdrY|d |}|dBs                                             B PK™e[ __init__.pyonu[ {fc@s#dZddlmZdZdS(sidlelib.idle_test is a private implementation of test.test_idle, which tests the IDLE application as part of the stdlib test suite. Run IDLE tests alone with "python -m test.test_idle". This package and its contained modules are subject to change and any direct use is at your own risk. i(tdirnamecCsMtt}tt|}|jd|ddd|}|j||S(Nt start_dirtpatternstest*.pyt top_level_dir(Rt__file__tdiscovertaddTests(tloadertstandard_testsRtthis_dirttop_dirt package_tests((s2/usr/lib64/python2.7/idlelib/idle_test/__init__.pyt load_tests s    N(t__doc__tos.pathRR (((s2/usr/lib64/python2.7/idlelib/idle_test/__init__.pytsPK™e[ lastline: return self._endex(endflag) linelength = len(self.data[line]) -1 # position before/at \n if char.endswith(' lineend') or char == 'end': return line, linelength # Tk requires that ignored chars before ' lineend' be valid int # Out of bounds char becomes first or last index of line char = int(char) if char < 0: char = 0 elif char > linelength: char = linelength return line, char def _endex(self, endflag): '''Return position for 'end' or line overflow corresponding to endflag. -1: position before terminal \n; for .insert(), .delete 0: position after terminal \n; for .get, .delete index 1 1: same viewed as beginning of non-existent next line (for .index) ''' n = len(self.data) if endflag == 1: return n, 0 else: n -= 1 return n, len(self.data[n]) + endflag def insert(self, index, chars): "Insert chars before the character at index." if not chars: # ''.splitlines() is [], not [''] return chars = chars.splitlines(True) if chars[-1][-1] == '\n': chars.append('') line, char = self._decode(index, -1) before = self.data[line][:char] after = self.data[line][char:] self.data[line] = before + chars[0] self.data[line+1:line+1] = chars[1:] self.data[line+len(chars)-1] += after def get(self, index1, index2=None): "Return slice from index1 to index2 (default is 'index1+1')." startline, startchar = self._decode(index1) if index2 is None: endline, endchar = startline, startchar+1 else: endline, endchar = self._decode(index2) if startline == endline: return self.data[startline][startchar:endchar] else: lines = [self.data[startline][startchar:]] for i in range(startline+1, endline): lines.append(self.data[i]) lines.append(self.data[endline][:endchar]) return ''.join(lines) def delete(self, index1, index2=None): '''Delete slice from index1 to index2 (default is 'index1+1'). Adjust default index2 ('index+1) for line ends. Do not delete the terminal \n at the very end of self.data ([-1][-1]). ''' startline, startchar = self._decode(index1, -1) if index2 is None: if startchar < len(self.data[startline])-1: # not deleting \n endline, endchar = startline, startchar+1 elif startline < len(self.data) - 1: # deleting non-terminal \n, convert 'index1+1 to start of next line endline, endchar = startline+1, 0 else: # do not delete terminal \n if index1 == 'insert' return else: endline, endchar = self._decode(index2, -1) # restricting end position to insert position excludes terminal \n if startline == endline and startchar < endchar: self.data[startline] = self.data[startline][:startchar] + \ self.data[startline][endchar:] elif startline < endline: self.data[startline] = self.data[startline][:startchar] + \ self.data[endline][endchar:] startline += 1 for i in range(startline, endline+1): del self.data[startline] def compare(self, index1, op, index2): line1, char1 = self._decode(index1) line2, char2 = self._decode(index2) if op == '<': return line1 < line2 or line1 == line2 and char1 < char2 elif op == '<=': return line1 < line2 or line1 == line2 and char1 <= char2 elif op == '>': return line1 > line2 or line1 == line2 and char1 > char2 elif op == '>=': return line1 > line2 or line1 == line2 and char1 >= char2 elif op == '==': return line1 == line2 and char1 == char2 elif op == '!=': return line1 != line2 or char1 != char2 else: raise TclError('''bad comparison operator "%s": ''' '''must be <, <=, ==, >=, >, or !=''' % op) # The following Text methods normally do something and return None. # Whether doing nothing is sufficient for a test will depend on the test. def mark_set(self, name, index): "Set mark *name* before the character at index." pass def mark_unset(self, *markNames): "Delete all marks in markNames." def tag_remove(self, tagName, index1, index2=None): "Remove tag tagName from all characters between index1 and index2." pass # The following Text methods affect the graphics screen and return None. # Doing nothing should always be sufficient for tests. def scan_dragto(self, x, y): "Adjust the view of the text according to scan_mark" def scan_mark(self, x, y): "Remember the current X, Y coordinates." def see(self, index): "Scroll screen to make the character at INDEX is visible." pass # The following is a Misc method inherited by Text. # It should properly go in a Misc mock, but is included here for now. def bind(sequence=None, func=None, add=None): "Bind to this widget at event sequence a call to function func." pass PK™e[test_autoexpand.pyonu[ {fc@sdZddlZddlmZddlmZmZddlmZdd dYZ dej fd YZ e d krej d d ndS(s!Unit tests for idlelib.AutoExpandiN(trequires(tTexttTk(t AutoExpandt Dummy_EditwincBseZdZRS(cCs ||_dS(N(ttext(tselfR((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyt__init__ s(t__name__t __module__R(((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyR stAutoExpandTestcBs\eZedZedZdZdZdZdZdZ dZ RS(cCsedttkr=tdt|_t|j|_n t|_tt|j|_dS(NtTkintertgui( tstrRRRttkRRRt auto_expand(tcls((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyt setUpClasss    cCs5|`|`t|dr1|jj|`ndS(NR(RRthasattrRtdestroy(R((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyt tearDownClasss  cCs|jjdddS(Ns1.0tend(Rtdelete(R((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttearDown!scCs|j}|jj}|j}||d|jdd||d|jdd||d|jdd||d|jdd||d|jdd||d |jd d||d|jd d ||ddS( Nttinsertttthistthist tiss sample stringtstrings3.0s1.0R(RRt getprevwordt assertEqualRR(RRtprevioustequal((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttest_get_prevword$s$   cCs|jj}|jj}|j}|jjdd||jjddddg|d||d|d||d|d||d|d||ddS(NRsab ac bx ad ab atabtadtactatevent(RR texpand_word_eventR!RRtgetwords(RR"texpandR#((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttest_before_only@s   "    cCs|j}|jj}|jj}|j}|jdd|jdd||jjddddg|d||d|d||d|d||d|d||ddS( NRs a, [ab] ac: () bx"" cd ac= ad yas1.1R%R'R&R(R)(RRR R*R!Rtmark_setR+(RRR"R,R#((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttest_after_onlyPs    "    cCs|j}|jj}|jj}|j}|jdd|jdd|jdd||jjdddg|d||d|d||d|d||ddS( NRs ab xy yz s a ac by acs2.1R%R'R(R)(RRR R*R!RR.R+(RRR"R,R#((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttest_both_before_aftercs       cCs|j}|jj}|j}||jjg||dd|jdd||jjg|jdd|jdd|d|jj}|jdd|d|jj}|j||dS(NR)tbreakRs bx cy dz asac xy a ac ad as1.7s1.end( RRR*R!R+RR.tstatetassertNotEqual(RRR,R#t initial_statet new_state((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyttest_other_expand_casesus       ( RR t classmethodRRRR$R-R/R0R6(((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyR s      t__main__t verbosityi((t__doc__tunittestttest.test_supportRR RRtidlelib.AutoExpandRRtTestCaseR Rtmain(((s9/usr/lib64/python2.7/idlelib/idle_test/test_autoexpand.pyts ~ PK™e[F*7; ; test_helpabout.pycnu[ {fc@sdZddlmZddlmZddlmZddlm Z ddl Z ej Z dddYZ d e jfd YZed kre jd d ndS(s$Test idlelib.help_about. Coverage: i(t aboutDialog(ttextView(tFunc(tMboxNtDummy_about_dialogcBs8eZejjZejjZejjZ ej jZ RS(( t__name__t __module__tAbouttShowIDLECreditstim_funct idle_creditst ShowIDLEAboutt idle_readmet ShowIDLENEWSt idle_newstdisplay_file_text(((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyR s   tDisplayFileTestcBs>eZdZeZedZedZdZRS(s4Test that .txt files are found and properly decoded.cCsXtj|_tj|_t|_t|_|jt_|jt_t |_ dS(N( ttextviewt tkMessageBoxt orig_mboxt view_textt orig_viewRtmboxRtviewRR(tcls((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyt setUpClasss      cCs|jt_|jjt_dS(N(RRRRR R(R((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyt tearDownClass#s cCsxz|jj|jj|jjfD]W}d|jj_t|j_ ||j |jjjd|j |jj t q"WdS(Nt( tdialogR R RRt showerrortmessagetFalseRtcalledt assertEqualtTrue(tselfthandler((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyttest_file_isplay(s   ( RRt__doc__RRt classmethodRRR%(((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyRs   t__main__t verbosityi((R&tidlelibRt help_aboutRRtidlelib.idle_test.mock_idleRtidlelib.idle_test.mock_tkRtunittestt AboutDialogRRtTestCaseRRtmain(((s8/usr/lib64/python2.7/idlelib/idle_test/test_helpabout.pyts    PK™e[H''test_delegator.pyonu[ {fc@s^ddlZddlmZdejfdYZedkrZejddddndS( iN(t Delegatort DelegatorTestcBseZdZRS(cCs0tt}|j|jt|j|jt|jt|j d|j }|j|tj |j|j dtj |j|jdh|j |j|jddh|` |j d|j |jd|j|jt|j|jt|j d|j |j|jtdS(Ntxyzt bit_lengtht numerator(RtinttassertIstdelegatet assertEqualt_Delegator__cachetsett assertRaisestAttributeErrort __getattr__Rt__dict__Rt assertNotIntassertInt setdelegatetfloat(tselftmydeltbl((s8/usr/lib64/python2.7/idlelib/idle_test/test_delegator.pyt test_mydels"   (t__name__t __module__R(((s8/usr/lib64/python2.7/idlelib/idle_test/test_delegator.pyRst__main__t verbosityitexit(tunittesttidlelib.DelegatorRtTestCaseRRtmain(((s8/usr/lib64/python2.7/idlelib/idle_test/test_delegator.pyts  PK™e[ޅy8181 htest.pyonu[ {fc@sdZddlmZddlmZddlZidd6idd6ed 6d 6d d 6Zid d6id 6dd 6Z idd6id 6dd 6Z idd6id 6dd 6Z idd6idd6ed 6d 6dd 6Z idd6id 6dd 6Z idd6id 6dd 6Zidd6idd6dd6dhd6ed 6d 6d d 6Zid!d6id"d6ed 6d 6d#d 6Zid$d6id%d6d&d'6d(gd)6ed 6d 6d*d 6Zid+d6id 6d,d 6Zid-d6id 6d.d 6Zid/d6id 6d0d 6Zid1d6id 6d2d 6Zid3d6id 6d4d 6Zid5d6id 6d6d 6Zid7d6id 6d8d 6Zid9d6id 6d:d 6Zid;d6id 6d<d 6Zid=d6id 6d>d 6Zid?d6id 6d@d 6ZidAd6id 6dBd 6ZidCd6id 6dDd 6ZidEd6idFd6dGdHdI6ed 6d 6dJd 6ZidKd6id 6dLd 6Z idMd6id 6dNd 6Z!idOd6id 6dPd 6Z"idQd6id 6dRd 6Z#dSZ$e%dTkre$ndS(UsRun human tests of Idle's window, dialog, and popup widgets. run(*tests) Create a master Tk window. Within that, run each callable in tests after finding the matching test spec in this file. If tests is empty, run an htest for each spec dict in this file after finding the matching callable in the module named in the spec. Close the window to skip or end the test. In a tested module, let X be a global name bound to a callable (class or function) whose .__name__ attrubute is also X (the usual situation). The first parameter of X must be 'parent'. When called, the parent argument will be the root window. X must create a child Toplevel window (or subclass thereof). The Toplevel may be a test widget or dialog, in which case the callable is the corresonding class. Or the Toplevel may contain the widget to be tested or set up a context in which a test widget is invoked. In this latter case, the callable is a wrapper function that sets up the Toplevel and other objects. Wrapper function names, such as _editor_window', should start with '_'. End the module with if __name__ == '__main__': from idlelib.idle_test.htest import run run(X) To have wrapper functions and test invocation code ignored by coveragepy reports, put '# htest #' on the def statement header line. def _wrapper(parent): # htest # Also make sure that the 'if __name__' line matches the above. Then have make sure that .coveragerc includes the following. [report] exclude_lines = .*# htest # if __name__ == .__main__.: (The "." instead of "'" is intentional and necessary.) To run any X, this file must contain a matching instance of the following template, with X.__name__ prepended to '_spec'. When all tests are run, the prefix is use to get X. _spec = { 'file': '', 'kwds': {'title': ''}, 'msg': "" } file (no .py): run() imports file.py. kwds: augmented with {'parent':root} and passed to X as **kwds. title: an example kwd; some widgets need this, delete if not. msg: master window hints about testing the widget. Modules and classes not being tested at the moment: PyShell.PyShellEditorWindow Debugger.Debugger AutoCompleteWindow.AutoCompleteWindow OutputWindow.OutputWindow (indirectly being tested with grep test) i(t import_module(t_initializeTkVariantTestsNt aboutDialogtfilesaboutDialog testttitlet_htesttkwdssaTest every button. Ensure Python, TK and IDLE versions are correctly displayed. [Close] to exit.tmsgt CallTipWindowsHTyping '(' should display a calltip. Typing ') should hide the calltip. t ClassBrowsersInspect names of module, class(with superclass if applicable), methods and functions. Toggle nested items. Double clicking on items prints a traceback for an exception that is ignored.tColorDelegatorsThe text is sample Python code. Ensure components like comments, keywords, builtins, string, definitions, and break are correctly colored. The default color scheme is in idlelib/config-highlight.deft configDialogtConfigDialogTestsIDLE preferences dialog. In the 'Fonts/Tabs' tab, changing font face, should update the font face of the text in the area below it. In the 'Highlighting' tab, try different color schemes. Clicking items in the sample program should update the choices above it. In the 'Keys', 'General' and 'Extensions' tabs, test settings of interest. [Ok] to close the dialog.[Apply] to apply the settings and and [Cancel] to revert all changes. Re-run the test to ensure changes made have persisted.tdynOptionMenuWidgetsSelect one of the many options in the 'old option set'. Click the button to change the option set. Select one of the many options in the 'new option set'.t EditorWindows>Test editor functions of interest. Best to close editor first.tconfigSectionNameDialogsGet NamesEnter somethingtmessagetabct used_namessAfter the text entered with [Ok] is stripped, , 'abc', or more that 30 chars are errors. Close 'Get Name' with a valid entry (printed to Shell), [Cancel], or [X]tconfigHelpSourceEditsGet helpsources%Enter menu item name and help file path and more than 30 chars are invalid menu item names. , file does not exist are invalid path items. Test for incomplete web address for help file path. A valid entry will be printed to shell with [0k]. [Cancel] will print None to shelltkeybindingDialogsTest keybindingss find-againtactionttcurrentKeySequencessTest for different key modifier sequences. is invalid. No modifier key is invalid. Shift key with [a-z],[0-9], function key, move key, tab, space is invalid. No validitity checking if advanced key binding entry is used.t GrepDialogsClick the 'Show GrepDialog' button. Test the various 'Find-in-files' functions. The results should be displayed in a new '*Output*' window. 'Right-click'->'Goto file/line' anywhere in the search results should open that file in a new EditorWindow.t IOBindingsTest the following bindings. to open file from dialog. Edit the file. to print the file. to save the file. to save-as another file. to save-copy-as another file. Check that changes were saved by opening the file elsewhere.t MultiCallsThe following actions should trigger a print to console or IDLE Shell. Entering and leaving the text area, key entry, , , , , , and focusing out of the window are sequences to be tested.tMultiStatusBarsjEnsure presence of multi-status bar below text area. Click 'Update Status' to change the multi-status textt ObjectBrowsersDouble click on items upto the lowest level. Attributes of the objects and related information will be displayed side-by-side at each level.t PathBrowsersTest for correct display of all paths in sys.path. Toggle nested items upto the lowest level. Double clicking on an item prints a traceback for an exception that is ignored.t PercolatorsAThere are two tracers which can be toggled using a checkbox. Toggling a tracer 'on' by checking it should print tracer output to the console or to the IDLE shell. If both the tracers are 'on', the output from the tracer which was switched 'on' later, should be printed first Test for actions like text entry, and removal.t ReplaceDialogsClick the 'Replace' button. Test various replace options in the 'Replace dialog'. Click [Close] or [X] to close the 'Replace Dialog'.t SearchDialogsClick the 'Search' button. Test various search options in the 'Search dialog'. Click [Close] or [X] to close the 'Search Dialog'.t ScrolledListsYou should see a scrollable list of items Selecting (clicking) or double clicking an item prints the name to the console or Idle shell. Right clicking an item will display a popup.thelpsPIf the help text displays, this works. Text is selectable. Window is scrollable.t StackViewersA stacktrace for a NameError exception. Expand 'idlelib ...' and ''. Check that exc_value, exc_tb, and exc_type are correct. t tabbedpagessToggle between the two tabs 'foo' and 'bar' Add a tab by entering a suitable name for it. Remove an existing tab by entering its name. Remove all existing tabs. is an invalid add page and remove page name. ttextViews Test textViews-The quick brown fox jumps over the lazy dog. i#ttextsNTest for read-only property of text. Text is selectable. Window is scrollable.tToolTipsPPlace mouse cursor over both the buttons A tooltip should appear with some text.t TreeWidgetsDThe canvas is scrollable. Click on folders upto to the lowest level.t UndoDelegatorsClick [Undo] to undo any action. Click [Redo] to redo any action. Click [Dump] to dump the current state by printing to the console or the IDLE shell. tWidgetRedirectorsEEvery text insert should be printed to the console or the IDLE shell.c stjjdjddttjdd}|jtj|ddjdj ddd d d d d tj |dj }j d|j |jdddddtjdddddtg|rIx|D]:}t|jd}|j|d<j||fqWnxtjD]n\}}|jdrY|d |}|dBs                                             B PK™e[7غi1i1test_searchengine.pyonu[ {fc@sydZddlZddlZddlmZmZmZddlZddlm Z ddl m Z m Z ddl mZdZdZd dd YZd ejfd YZd ejfdYZdejfdYZdejfdYZdejfdYZdejfdYZdejfdYZedkruejddddndS(s9Test functions and SearchEngine class in SearchEngine.py.iN(t BooleanVart StringVartTclError(t SearchEngine(tVartMbox(tTextcCstt_tt_tt_dS(N(RtseRRRt tkMessageBox(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt setUpModules  cCstt_tt_tt_dS(N(RRRR(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttearDownModules  tMockcBseZdZRS(cOsdS(N((tselftargstkwargs((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt__init__t(t__name__t __module__R(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR stGetTestcBseZdZRS(cCs~tj}tt_z[t}tj|}|j|tj|j|j||jtj||Wd|t_XdS(N(RRR tgettassertIsInstancetassertIst _searchengine(R t saved_Enginetroottengine((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_get#s   (RRR(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR!stGetLineColTestcBseZdZRS(cCsb|jtjdd|jtjdd |jttjd|jttjddS( Ns1.0iis1.11i s 1.0 lineendtend(ii(ii (t assertEqualRt get_line_colt assertRaisest ValueError(R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_get_line_col1s(RRR"(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR/stGetSelectionTestcBseZdZRS(cCsst}|jddd}||_|jtj|dd}||_|jtj|ddS( Ns1.0s Hello World!cSs*|dkrdS|dkr dStdS(Ns sel.firsts1.0ssel.lasts1.12(R(ts((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pytselKs   s1.12cSs|dkrdStdS(Ntinserts1.5(R(R$((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pytmarkSs s1.5(s1.0s1.12(s1.5s1.5(tmockTextR&tindexRRt get_selection(R ttextR%R'((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_get_selectionEs     (RRR,(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR#8s tReverseSearchTestcBseZdZRS(cCs|j}d}tjd}|tj||t|jd |tj||djd |tj||djd |tj||djd |tj||dddS( NsHere is an 'is' test text.tisi ii iii(i i(i i(ii(ii(RtretcompileRtsearch_reversetlentspantNone(R tEqualtlinetprog((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_search_reverse]s ("""(RRR8(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR-[stSearchEngineTestcBs>eZdZdZdZdZdZdZRS(cCstjdd|_dS(NR(RRR4R(R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pytsetUpkscCsW|j}|j}||jd|jd||jd||jt|jjd||jt||j t|j jd||j t||j t|j jd||j t||j t|jjd||j t||jt|jjd||jtdS(NRthelloii(RRtgetpattsetpattisretFalsetrevartsettTruetiscasetcasevartiswordtwordvartiswraptwrapvartisbacktbackvar(R RR5((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt test_is_getps(   cCsc|j}|jd|j|jd|jjd|jd|j|jddS(Ns\sis\\s(Rt setcookedpatRR<R@RA(R R((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_setcookedpats    cCs|j}|j}||jd|jd||jd|jjt||jd|jjt|jd||jd|jjt||jddS(NRR;s \bhello\bs\ss\\s( RRt getcookedpatR=RFRARBR?R@(R RR5((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_getcookedpats    cCs|j}|j}|jd|j}||jtjdtjj|jj d|j}||jtjdjd|jd||jd|jd|j j d||jd|jt j jddS(NtHelloiiRt+s#Error: nothing to repeat Pattern: +(RRR=tgetprogtpatternR/R0t IGNORECASERDRAR4R@Rt showerrortmessage(R RR5ttemppat((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt test_getprogs    "   cCstj}|j}d}d}||jj||d||jdd|d}||j|||jj||dd||jd|d7}||j|dS(Ns[a-zs$unexpected end of regular expressionsRegular expression errorsError: s Pattern: [a-zis Offset: 5(RRURRt report_errorR4ttitleRV(R RUR5tpattmsgtexpected_message((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_report_errors   (RRR:RKRMRORXR^(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR9hs      t SearchTestcBs eZedZdZRS(cCskt|_d}|jjd|tjd|_tjd|_ d|j _ d|j _ dS(Ns&First line Line with target Last line s1.0ttargetcWs d|fS(Ntf((R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pytRcWs d|fS(Ntb((R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyRbR( R(R+R&R/R0R[RRR4Rtsearch_forwardtsearch_backward(tclst test_text((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt setUpClasss c Cs|j}|j}|j}|j}|j}|jjd|||dd}||_||||d||ddt t ff|j jt ||||d||ddt t ff|j jt |j jt ||||d||ddt t ff|j jt d}||_||||d||ddt t ff||||t d||dd t t ff|j jt ||||d||dd t t ff||||t d||ddt t ffdS( NcSs|dkrdStdS(NR&s1.5(R(R$((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR's RaiiRccSs*|dkrdS|dkr dStdS(Ns sel.firsts2.10ssel.lasts2.16(R(R$((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR%s   iii ( RRt search_textR+R[tpatvarRAR4R)RBR?RHRJ(R R5RtsearchR+R[R'R%((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt test_searchs.       ...  .1.(RRt classmethodRhRl(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR_stForwardBackwardTestcBs2eZedZdZdZdZRS(cCstjd|_t|_d|j_d}|jjd|tj d|_ dd f|_ tj d|_ tj d |_ dS( NcSsdS(Ns4.0((R)((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyRbRs&First line Line with target Last line s1.0R`ii itxyzs\w*(i i(RRR4RR(R+R)R&R/R0R[trestfailpattemptypat(RfRg((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyRh s csdfd}|S(Nics@j|||||}|r<|d|djfS|S(Nii(R+R3(R[R6tcoltwraptokRp(tfuncR (s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyRk s((R RvRk((RvR s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt make_searchscCs|j}|j|jj}|j}|||ddt|j|||ddt|j|||ddtd|||ddt|j|||j ddtd|||j ddtdtddf|||j ddt|jdS( Niiiii i Ru(i i ( RRwRRdR[RBRpR?R4RqRr(R R5tforwardR[((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_search_forward&s  +cCs|j}|j|jj}|j}|||ddt|j|||ddt|j|||ddtd|||ddt|j|||j ddtd|||j ddtdtdd f|||j ddtdd fdS( Niiiiii i Ru(i i (ii ( RRwRReR[RBRpR?R4RqRr(R R5tbackwardR[((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_search_backward7s  +(RRRmRhRwRyR{(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyRns  t__main__t verbosityitexit((t__doc__R/tunittesttTkinterRRRRtidlelibRRtidlelib.idle_test.mock_tkRRRR(R R R tTestCaseRRR#R-R9R_RnRtmain(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyts&      # `=C PK™e[ - - test_io.pycnu[ {fc@sddlZddlZddlmZmZddlmZdefdYZ de e fdYZ de e fd YZ d e efd YZd dd YZdejfdYZdejfdYZdZedkrendS(iN(tPseudoInputFiletPseudoOutputFile(t test_supporttBasecBs>eZdZdZdZdZdZdZRS(cCsdt|jS(Ns%s:str(ttypet__name__(tself((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt__str__scCsdt|jS(Ns %s:unicode(RR(R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt __unicode__ scCsdS(Ni((R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt__len__ scCs tdS(Ntabc(titer(R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt__iter__scGsdt|jS(Ns%s:item(RR(Rtargs((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt __getitem__scGsdt|jS(Ns%s:slice(RR(RR ((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt __getslice__s(Rt __module__RRR R RR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRs      tScBseZRS((RR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRstUcBseZRS((RR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRstBAcBseZRS((RR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRst MockShellcBs>eZdZdZdZdZdZdZRS(cCs|jdS(N(treset(R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt__init__scGs|jj|dS(N(twrittentappend(RR ((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pytwrite"scCs |jjS(N(tlinestpop(R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pytreadline%scCsdS(N((R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pytclose(scCs g|_dS(N(R(R((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyR+scCs t|ddd|_dS(Ni(tlistR(RR((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pytpush.s(RRRRRRRR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRs      tPseudeOutputFilesTestcBs5eZdZdZdZdZdZRS(cCst}t|dd}|j|tj|j|jd|j|j|j|j |j|j d|j |j |j |j|j |j|j |j|j |jdS(Ntstdoutsutf-8s(RRtassertIsInstancetiot TextIOBaset assertEqualtencodingt assertIsNoneterrorstnewlinestnamet assertFalsetclosedt assertTruetisattytreadabletwritabletseekable(Rtshelltf((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_misc3s cCst}t|dd}|jt|j|jt|j|jt|jd|jt|jd|jt|jddS(NR!sutf-8i( RRt assertRaisestIOErrortfilenottelltseektreadR(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyttest_unsupportedAs cCst}t|dd}|jd|j|jd g|j|jd|j|jd g|j|jd|j|jd g|j|jtd|j|jd g|jt|jddt|j|jt d|j|jd g|jt|jddt|j|jt d|j|jdg|jt|jddt |j|j t |j|j|jg|j t |jd|j|jg|j t |jdd|j|jgdS(NR!sutf-8ttestststutèstii{tspam(R<R!(ststR!(utèstR!(ststR!(ststR!(utèstR!(RRRR%RRRRtstrRRtunicodeR5t TypeError(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_writeJs:       ! ! ! cCst}t|dd}|jg|j|jg|j|jddg|j|jd dg|j|jddg|j|jddg|j|jddg|j|jddg|j|jtd g|j|jdg|jt|jd d t|j|jt d g|j|jdg|jt|jd d t|j|jt d g|j|jdg|jt|jd d t |j|j t |j|j|jg|j t |jd |j|jg|j t |jd g|j|jg|j t |jgg|j|jgdS(NR!sutf-8sone ttwoson stwuonè utwòststiutèsti{(sone R!(RBR!(son R!(stwR!(uonè R!(utwòR!(ststR!(ststR!(utèstR!(RRt writelinesR%RRRRR>RRR?R5R@(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyttest_writelinesksJ            ! ! ! cCst}t|dd}|j|j|jd|j|j|j|jt|jd|j |j dg|j|jt |jddS(NR!sutf-8R<txi(R<R!( RRR+R,RRR-R5t ValueErrorR%RR@(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_closes    (RRR4R;RARDRG(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyR 2s   ! )tPseudeInputFilesTestcBs>eZdZdZdZdZdZdZRS(cCst}t|dd}|j|tj|j|jd|j|j|j|j |j|j d|j |j |j |j|j |j|j |j|j |jdS(Ntstdinsutf-8s(RRR"R#R$R%R&R'R(R)R*R+R,R-R.R/R0R1(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyR4s cCst}t|dd}|jt|j|jt|j|jt|jd|jt|jd|jt|jdgdS(NRIsutf-8iRE( RRR5R6R7R8R9RRC(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyR;s cCs~t}t|dd}|jdddg|j|jd|jdddg|j|jdd|jdddg|j|jdd|jddddg|j|jd d |j|jd d |j|jd d|jddg|j|jdd|jt|jd|jt|jd|jt|jdddS(NRIsutf-8sone stwo tsone two isthree itonise ti s wo three ig?t1i(RRRR%R:tNoneR5R@(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_reads" cCst}t|dd}|jddddg|j|jd|j|jdd|j|jdd|jdg|j|jd|j|jd|jd d d g|j|jd |j|jd |jdddg|j|jd d |j|jdd|j|jdd|j|jdd|jddg|j|jdd|jt|jd|jt|jd|jt|jdddS(NRIsutf-8sone stwo sthree sfour isone two toneRBtthreeiRKites i iRJg?RL( RRRR%RRMR5R@t readlines(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_readlines, cCst}t|dd}|jdddg|j|jddg|jdddg|j|jdddg|jdddg|j|jdddg|jdddg|j|jdddg|jdddg|j|jddg|jdddg|j|jd ddg|jdddg|jt|jd |jt|jd |jt|jd d dS( NRIsutf-8sone stwo RJiiiig?RLi(RRRR%RRRMR5R@(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyttest_readliness$ cCst}t|dd}|jdddg|j|j|j|jd|j|j|j|j|jd|jt |jddS(NRIsutf-8sone stwo RJi( RRRR+R,R%RRR5R@(RR2R3((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRGs  (RRR4R;RNRSRTRG(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyRHs     cCstjttdS(N(tsupportt run_unittestR RH(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyt test_mainst__main__((tunittestR#tidlelib.PyShellRRR<RRUtobjectRR>RR?Rt bytearrayRRtTestCaseR RHRWR(((s1/usr/lib64/python2.7/idlelib/idle_test/test_io.pyts  of  PK™e[H XX test_text.pynu[# Test mock_tk.Text class against tkinter.Text class by running same tests with both. import unittest from test.test_support import requires from _tkinter import TclError class TextTest(object): hw = 'hello\nworld' # usual initial insert after initialization hwn = hw+'\n' # \n present at initialization, before insert Text = None def setUp(self): self.text = self.Text() def test_init(self): self.assertEqual(self.text.get('1.0'), '\n') self.assertEqual(self.text.get('end'), '') def test_index_empty(self): index = self.text.index for dex in (-1.0, 0.3, '1.-1', '1.0', '1.0 lineend', '1.end', '1.33', 'insert'): self.assertEqual(index(dex), '1.0') for dex in 'end', 2.0, '2.1', '33.44': self.assertEqual(index(dex), '2.0') def test_index_data(self): index = self.text.index self.text.insert('1.0', self.hw) for dex in -1.0, 0.3, '1.-1', '1.0': self.assertEqual(index(dex), '1.0') for dex in '1.0 lineend', '1.end', '1.33': self.assertEqual(index(dex), '1.5') for dex in 'end', '33.44': self.assertEqual(index(dex), '3.0') def test_get(self): get = self.text.get Equal = self.assertEqual self.text.insert('1.0', self.hw) Equal(get('end'), '') Equal(get('end', 'end'), '') Equal(get('1.0'), 'h') Equal(get('1.0', '1.1'), 'h') Equal(get('1.0', '1.3'), 'hel') Equal(get('1.1', '1.3'), 'el') Equal(get('1.0', '1.0 lineend'), 'hello') Equal(get('1.0', '1.10'), 'hello') Equal(get('1.0 lineend'), '\n') Equal(get('1.1', '2.3'), 'ello\nwor') Equal(get('1.0', '2.5'), self.hw) Equal(get('1.0', 'end'), self.hwn) Equal(get('0.0', '5.0'), self.hwn) def test_insert(self): insert = self.text.insert get = self.text.get Equal = self.assertEqual insert('1.0', self.hw) Equal(get('1.0', 'end'), self.hwn) insert('1.0', '') # nothing Equal(get('1.0', 'end'), self.hwn) insert('1.0', '*') Equal(get('1.0', 'end'), '*hello\nworld\n') insert('1.0 lineend', '*') Equal(get('1.0', 'end'), '*hello*\nworld\n') insert('2.3', '*') Equal(get('1.0', 'end'), '*hello*\nwor*ld\n') insert('end', 'x') Equal(get('1.0', 'end'), '*hello*\nwor*ldx\n') insert('1.4', 'x\n') Equal(get('1.0', 'end'), '*helx\nlo*\nwor*ldx\n') def test_no_delete(self): # if index1 == 'insert' or 'end' or >= end, there is no deletion delete = self.text.delete get = self.text.get Equal = self.assertEqual self.text.insert('1.0', self.hw) delete('insert') Equal(get('1.0', 'end'), self.hwn) delete('end') Equal(get('1.0', 'end'), self.hwn) delete('insert', 'end') Equal(get('1.0', 'end'), self.hwn) delete('insert', '5.5') Equal(get('1.0', 'end'), self.hwn) delete('1.4', '1.0') Equal(get('1.0', 'end'), self.hwn) delete('1.4', '1.4') Equal(get('1.0', 'end'), self.hwn) def test_delete_char(self): delete = self.text.delete get = self.text.get Equal = self.assertEqual self.text.insert('1.0', self.hw) delete('1.0') Equal(get('1.0', '1.end'), 'ello') delete('1.0', '1.1') Equal(get('1.0', '1.end'), 'llo') # delete \n and combine 2 lines into 1 delete('1.end') Equal(get('1.0', '1.end'), 'lloworld') self.text.insert('1.3', '\n') delete('1.10') Equal(get('1.0', '1.end'), 'lloworld') self.text.insert('1.3', '\n') delete('1.3', '2.0') Equal(get('1.0', '1.end'), 'lloworld') def test_delete_slice(self): delete = self.text.delete get = self.text.get Equal = self.assertEqual self.text.insert('1.0', self.hw) delete('1.0', '1.0 lineend') Equal(get('1.0', 'end'), '\nworld\n') delete('1.0', 'end') Equal(get('1.0', 'end'), '\n') self.text.insert('1.0', self.hw) delete('1.0', '2.0') Equal(get('1.0', 'end'), 'world\n') delete('1.0', 'end') Equal(get('1.0', 'end'), '\n') self.text.insert('1.0', self.hw) delete('1.2', '2.3') Equal(get('1.0', 'end'), 'held\n') def test_multiple_lines(self): # insert and delete self.text.insert('1.0', 'hello') self.text.insert('1.3', '1\n2\n3\n4\n5') self.assertEqual(self.text.get('1.0', 'end'), 'hel1\n2\n3\n4\n5lo\n') self.text.delete('1.3', '5.1') self.assertEqual(self.text.get('1.0', 'end'), 'hello\n') def test_compare(self): compare = self.text.compare Equal = self.assertEqual # need data so indexes not squished to 1,0 self.text.insert('1.0', 'First\nSecond\nThird\n') self.assertRaises(TclError, compare, '2.2', 'op', '2.2') for op, less1, less0, equal, greater0, greater1 in ( ('<', True, True, False, False, False), ('<=', True, True, True, False, False), ('>', False, False, False, True, True), ('>=', False, False, True, True, True), ('==', False, False, True, False, False), ('!=', True, True, False, True, True), ): Equal(compare('1.1', op, '2.2'), less1, op) Equal(compare('2.1', op, '2.2'), less0, op) Equal(compare('2.2', op, '2.2'), equal, op) Equal(compare('2.3', op, '2.2'), greater0, op) Equal(compare('3.3', op, '2.2'), greater1, op) class MockTextTest(TextTest, unittest.TestCase): @classmethod def setUpClass(cls): from idlelib.idle_test.mock_tk import Text cls.Text = Text def test_decode(self): # test endflags (-1, 0) not tested by test_index (which uses +1) decode = self.text._decode Equal = self.assertEqual self.text.insert('1.0', self.hw) Equal(decode('end', -1), (2, 5)) Equal(decode('3.1', -1), (2, 5)) Equal(decode('end', 0), (2, 6)) Equal(decode('3.1', 0), (2, 6)) class TkTextTest(TextTest, unittest.TestCase): @classmethod def setUpClass(cls): requires('gui') from Tkinter import Tk, Text cls.Text = Text cls.root = Tk() @classmethod def tearDownClass(cls): cls.root.destroy() del cls.root if __name__ == '__main__': unittest.main(verbosity=2, exit=False) PK™e[Ǹ/ test_warning.pynu['''Test warnings replacement in PyShell.py and run.py. This file could be expanded to include traceback overrides (in same two modules). If so, change name. Revise if output destination changes (http://bugs.python.org/issue18318). Make sure warnings module is left unaltered (http://bugs.python.org/issue18081). ''' import unittest from test.test_support import captured_stderr import warnings # Try to capture default showwarning before Idle modules are imported. showwarning = warnings.showwarning # But if we run this file within idle, we are in the middle of the run.main loop # and default showwarnings has already been replaced. running_in_idle = 'idle' in showwarning.__name__ from idlelib import run from idlelib import PyShell as shell # The following was generated from PyShell.idle_formatwarning # and checked as matching expectation. idlemsg = ''' Warning (from warnings module): File "test_warning.py", line 99 Line of code UserWarning: Test ''' shellmsg = idlemsg + ">>> " class RunWarnTest(unittest.TestCase): @unittest.skipIf(running_in_idle, "Does not work when run within Idle.") def test_showwarnings(self): self.assertIs(warnings.showwarning, showwarning) run.capture_warnings(True) self.assertIs(warnings.showwarning, run.idle_showwarning_subproc) run.capture_warnings(False) self.assertIs(warnings.showwarning, showwarning) def test_run_show(self): with captured_stderr() as f: run.idle_showwarning_subproc( 'Test', UserWarning, 'test_warning.py', 99, f, 'Line of code') # The following uses .splitlines to erase line-ending differences self.assertEqual(idlemsg.splitlines(), f.getvalue().splitlines()) class ShellWarnTest(unittest.TestCase): @unittest.skipIf(running_in_idle, "Does not work when run within Idle.") def test_showwarnings(self): self.assertIs(warnings.showwarning, showwarning) shell.capture_warnings(True) self.assertIs(warnings.showwarning, shell.idle_showwarning) shell.capture_warnings(False) self.assertIs(warnings.showwarning, showwarning) def test_idle_formatter(self): # Will fail if format changed without regenerating idlemsg s = shell.idle_formatwarning( 'Test', UserWarning, 'test_warning.py', 99, 'Line of code') self.assertEqual(idlemsg, s) def test_shell_show(self): with captured_stderr() as f: shell.idle_showwarning( 'Test', UserWarning, 'test_warning.py', 99, f, 'Line of code') self.assertEqual(shellmsg.splitlines(), f.getvalue().splitlines()) if __name__ == '__main__': unittest.main(verbosity=2, exit=False) PK™e[Rwwtest_configdialog.pycnu[ {fc@sdZddlZddlmZddlmZddlmZddlm Z dej fdYZ e d krej d d ndS( soUnittests for idlelib/configHandler.py Coverage: 46% just by creating dialog. The other half is change code. iN(trequires(tTk(t ConfigDialog(t_initializeTkVariantTeststConfigDialogTestcBs/eZedZedZdZRS(cCs4tdt|_|jjt|jdS(Ntgui(RRtroottwithdrawR(tcls((s;/usr/lib64/python2.7/idlelib/idle_test/test_configdialog.pyt setUpClasss   cCs|jj|`dS(N(Rtdestroy(R((s;/usr/lib64/python2.7/idlelib/idle_test/test_configdialog.pyt tearDownClasss cCs&t|jddt}|jdS(NtTestt_utest(RRtTruetremove_var_callbacks(tselftd((s;/usr/lib64/python2.7/idlelib/idle_test/test_configdialog.pyt test_dialogs(t__name__t __module__t classmethodR R R(((s;/usr/lib64/python2.7/idlelib/idle_test/test_configdialog.pyR st__main__t verbosityi(t__doc__tunittestttest.test_supportRtTkinterRtidlelib.configDialogRtidlelib.macosxSupportRtTestCaseRRtmain(((s;/usr/lib64/python2.7/idlelib/idle_test/test_configdialog.pyts  PK™e[[') self.assertFalse(f.closed) self.assertTrue(f.isatty()) self.assertFalse(f.readable()) self.assertTrue(f.writable()) self.assertFalse(f.seekable()) def test_unsupported(self): shell = MockShell() f = PseudoOutputFile(shell, 'stdout', 'utf-8') self.assertRaises(IOError, f.fileno) self.assertRaises(IOError, f.tell) self.assertRaises(IOError, f.seek, 0) self.assertRaises(IOError, f.read, 0) self.assertRaises(IOError, f.readline, 0) def test_write(self): shell = MockShell() f = PseudoOutputFile(shell, 'stdout', 'utf-8') f.write('test') self.assertEqual(shell.written, [('test', 'stdout')]) shell.reset() f.write('t\xe8st') self.assertEqual(shell.written, [('t\xe8st', 'stdout')]) shell.reset() f.write(u't\xe8st') self.assertEqual(shell.written, [(u't\xe8st', 'stdout')]) shell.reset() f.write(S('t\xe8st')) self.assertEqual(shell.written, [('t\xe8st', 'stdout')]) self.assertEqual(type(shell.written[0][0]), str) shell.reset() f.write(BA('t\xe8st')) self.assertEqual(shell.written, [('t\xe8st', 'stdout')]) self.assertEqual(type(shell.written[0][0]), str) shell.reset() f.write(U(u't\xe8st')) self.assertEqual(shell.written, [(u't\xe8st', 'stdout')]) self.assertEqual(type(shell.written[0][0]), unicode) shell.reset() self.assertRaises(TypeError, f.write) self.assertEqual(shell.written, []) self.assertRaises(TypeError, f.write, 123) self.assertEqual(shell.written, []) self.assertRaises(TypeError, f.write, 'test', 'spam') self.assertEqual(shell.written, []) def test_writelines(self): shell = MockShell() f = PseudoOutputFile(shell, 'stdout', 'utf-8') f.writelines([]) self.assertEqual(shell.written, []) shell.reset() f.writelines(['one\n', 'two']) self.assertEqual(shell.written, [('one\n', 'stdout'), ('two', 'stdout')]) shell.reset() f.writelines(['on\xe8\n', 'tw\xf2']) self.assertEqual(shell.written, [('on\xe8\n', 'stdout'), ('tw\xf2', 'stdout')]) shell.reset() f.writelines([u'on\xe8\n', u'tw\xf2']) self.assertEqual(shell.written, [(u'on\xe8\n', 'stdout'), (u'tw\xf2', 'stdout')]) shell.reset() f.writelines([S('t\xe8st')]) self.assertEqual(shell.written, [('t\xe8st', 'stdout')]) self.assertEqual(type(shell.written[0][0]), str) shell.reset() f.writelines([BA('t\xe8st')]) self.assertEqual(shell.written, [('t\xe8st', 'stdout')]) self.assertEqual(type(shell.written[0][0]), str) shell.reset() f.writelines([U(u't\xe8st')]) self.assertEqual(shell.written, [(u't\xe8st', 'stdout')]) self.assertEqual(type(shell.written[0][0]), unicode) shell.reset() self.assertRaises(TypeError, f.writelines) self.assertEqual(shell.written, []) self.assertRaises(TypeError, f.writelines, 123) self.assertEqual(shell.written, []) self.assertRaises(TypeError, f.writelines, [123]) self.assertEqual(shell.written, []) self.assertRaises(TypeError, f.writelines, [], []) self.assertEqual(shell.written, []) def test_close(self): shell = MockShell() f = PseudoOutputFile(shell, 'stdout', 'utf-8') self.assertFalse(f.closed) f.write('test') f.close() self.assertTrue(f.closed) self.assertRaises(ValueError, f.write, 'x') self.assertEqual(shell.written, [('test', 'stdout')]) f.close() self.assertRaises(TypeError, f.close, 1) class PseudeInputFilesTest(unittest.TestCase): def test_misc(self): shell = MockShell() f = PseudoInputFile(shell, 'stdin', 'utf-8') self.assertIsInstance(f, io.TextIOBase) self.assertEqual(f.encoding, 'utf-8') self.assertIsNone(f.errors) self.assertIsNone(f.newlines) self.assertEqual(f.name, '') self.assertFalse(f.closed) self.assertTrue(f.isatty()) self.assertTrue(f.readable()) self.assertFalse(f.writable()) self.assertFalse(f.seekable()) def test_unsupported(self): shell = MockShell() f = PseudoInputFile(shell, 'stdin', 'utf-8') self.assertRaises(IOError, f.fileno) self.assertRaises(IOError, f.tell) self.assertRaises(IOError, f.seek, 0) self.assertRaises(IOError, f.write, 'x') self.assertRaises(IOError, f.writelines, ['x']) def test_read(self): shell = MockShell() f = PseudoInputFile(shell, 'stdin', 'utf-8') shell.push(['one\n', 'two\n', '']) self.assertEqual(f.read(), 'one\ntwo\n') shell.push(['one\n', 'two\n', '']) self.assertEqual(f.read(-1), 'one\ntwo\n') shell.push(['one\n', 'two\n', '']) self.assertEqual(f.read(None), 'one\ntwo\n') shell.push(['one\n', 'two\n', 'three\n', '']) self.assertEqual(f.read(2), 'on') self.assertEqual(f.read(3), 'e\nt') self.assertEqual(f.read(10), 'wo\nthree\n') shell.push(['one\n', 'two\n']) self.assertEqual(f.read(0), '') self.assertRaises(TypeError, f.read, 1.5) self.assertRaises(TypeError, f.read, '1') self.assertRaises(TypeError, f.read, 1, 1) def test_readline(self): shell = MockShell() f = PseudoInputFile(shell, 'stdin', 'utf-8') shell.push(['one\n', 'two\n', 'three\n', 'four\n']) self.assertEqual(f.readline(), 'one\n') self.assertEqual(f.readline(-1), 'two\n') self.assertEqual(f.readline(None), 'three\n') shell.push(['one\ntwo\n']) self.assertEqual(f.readline(), 'one\n') self.assertEqual(f.readline(), 'two\n') shell.push(['one', 'two', 'three']) self.assertEqual(f.readline(), 'one') self.assertEqual(f.readline(), 'two') shell.push(['one\n', 'two\n', 'three\n']) self.assertEqual(f.readline(2), 'on') self.assertEqual(f.readline(1), 'e') self.assertEqual(f.readline(1), '\n') self.assertEqual(f.readline(10), 'two\n') shell.push(['one\n', 'two\n']) self.assertEqual(f.readline(0), '') self.assertRaises(TypeError, f.readlines, 1.5) self.assertRaises(TypeError, f.readlines, '1') self.assertRaises(TypeError, f.readlines, 1, 1) def test_readlines(self): shell = MockShell() f = PseudoInputFile(shell, 'stdin', 'utf-8') shell.push(['one\n', 'two\n', '']) self.assertEqual(f.readlines(), ['one\n', 'two\n']) shell.push(['one\n', 'two\n', '']) self.assertEqual(f.readlines(-1), ['one\n', 'two\n']) shell.push(['one\n', 'two\n', '']) self.assertEqual(f.readlines(None), ['one\n', 'two\n']) shell.push(['one\n', 'two\n', '']) self.assertEqual(f.readlines(0), ['one\n', 'two\n']) shell.push(['one\n', 'two\n', '']) self.assertEqual(f.readlines(3), ['one\n']) shell.push(['one\n', 'two\n', '']) self.assertEqual(f.readlines(4), ['one\n', 'two\n']) shell.push(['one\n', 'two\n', '']) self.assertRaises(TypeError, f.readlines, 1.5) self.assertRaises(TypeError, f.readlines, '1') self.assertRaises(TypeError, f.readlines, 1, 1) def test_close(self): shell = MockShell() f = PseudoInputFile(shell, 'stdin', 'utf-8') shell.push(['one\n', 'two\n', '']) self.assertFalse(f.closed) self.assertEqual(f.readline(), 'one\n') f.close() self.assertFalse(f.closed) self.assertEqual(f.readline(), 'two\n') self.assertRaises(TypeError, f.close, 1) def test_main(): support.run_unittest(PseudeOutputFilesTest, PseudeInputFilesTest) if __name__ == '__main__': test_main() PK™e[zxtest_pathbrowser.pynu[import unittest import os import sys import idlelib from idlelib import PathBrowser class PathBrowserTest(unittest.TestCase): def test_DirBrowserTreeItem(self): # Issue16226 - make sure that getting a sublist works d = PathBrowser.DirBrowserTreeItem('') d.GetSubList() self.assertEqual('', d.GetText()) dir = os.path.split(os.path.abspath(idlelib.__file__))[0] self.assertEqual(d.ispackagedir(dir), True) self.assertEqual(d.ispackagedir(dir + '/Icons'), False) def test_PathBrowserTreeItem(self): p = PathBrowser.PathBrowserTreeItem() self.assertEqual(p.GetText(), 'sys.path') sub = p.GetSubList() self.assertEqual(len(sub), len(sys.path)) # Following fails in 2.7 because old-style class #self.assertEqual(type(sub[0]), PathBrowser.DirBrowserTreeItem) if __name__ == '__main__': unittest.main(verbosity=2, exit=False) PK™e['ttest_autoexpand.pynu["""Unit tests for idlelib.AutoExpand""" import unittest from test.test_support import requires from Tkinter import Text, Tk #from idlelib.idle_test.mock_tk import Text from idlelib.AutoExpand import AutoExpand class Dummy_Editwin: # AutoExpand.__init__ only needs .text def __init__(self, text): self.text = text class AutoExpandTest(unittest.TestCase): @classmethod def setUpClass(cls): if 'Tkinter' in str(Text): requires('gui') cls.tk = Tk() cls.text = Text(cls.tk) else: cls.text = Text() cls.auto_expand = AutoExpand(Dummy_Editwin(cls.text)) @classmethod def tearDownClass(cls): del cls.text, cls.auto_expand if hasattr(cls, 'tk'): cls.tk.destroy() del cls.tk def tearDown(self): self.text.delete('1.0', 'end') def test_get_prevword(self): text = self.text previous = self.auto_expand.getprevword equal = self.assertEqual equal(previous(), '') text.insert('insert', 't') equal(previous(), 't') text.insert('insert', 'his') equal(previous(), 'this') text.insert('insert', ' ') equal(previous(), '') text.insert('insert', 'is') equal(previous(), 'is') text.insert('insert', '\nsample\nstring') equal(previous(), 'string') text.delete('3.0', 'insert') equal(previous(), '') text.delete('1.0', 'end') equal(previous(), '') def test_before_only(self): previous = self.auto_expand.getprevword expand = self.auto_expand.expand_word_event equal = self.assertEqual self.text.insert('insert', 'ab ac bx ad ab a') equal(self.auto_expand.getwords(), ['ab', 'ad', 'ac', 'a']) expand('event') equal(previous(), 'ab') expand('event') equal(previous(), 'ad') expand('event') equal(previous(), 'ac') expand('event') equal(previous(), 'a') def test_after_only(self): # Also add punctuation 'noise' that shoud be ignored. text = self.text previous = self.auto_expand.getprevword expand = self.auto_expand.expand_word_event equal = self.assertEqual text.insert('insert', 'a, [ab] ac: () bx"" cd ac= ad ya') text.mark_set('insert', '1.1') equal(self.auto_expand.getwords(), ['ab', 'ac', 'ad', 'a']) expand('event') equal(previous(), 'ab') expand('event') equal(previous(), 'ac') expand('event') equal(previous(), 'ad') expand('event') equal(previous(), 'a') def test_both_before_after(self): text = self.text previous = self.auto_expand.getprevword expand = self.auto_expand.expand_word_event equal = self.assertEqual text.insert('insert', 'ab xy yz\n') text.insert('insert', 'a ac by ac') text.mark_set('insert', '2.1') equal(self.auto_expand.getwords(), ['ab', 'ac', 'a']) expand('event') equal(previous(), 'ab') expand('event') equal(previous(), 'ac') expand('event') equal(previous(), 'a') def test_other_expand_cases(self): text = self.text expand = self.auto_expand.expand_word_event equal = self.assertEqual # no expansion candidate found equal(self.auto_expand.getwords(), []) equal(expand('event'), 'break') text.insert('insert', 'bx cy dz a') equal(self.auto_expand.getwords(), []) # reset state by successfully expanding once # move cursor to another position and expand again text.insert('insert', 'ac xy a ac ad a') text.mark_set('insert', '1.7') expand('event') initial_state = self.auto_expand.state text.mark_set('insert', '1.end') expand('event') new_state = self.auto_expand.state self.assertNotEqual(initial_state, new_state) if __name__ == '__main__': unittest.main(verbosity=2) PK™e[; 88test_formatparagraph.pynu[# Test the functions and main class method of FormatParagraph.py import unittest from idlelib import FormatParagraph as fp from idlelib.EditorWindow import EditorWindow from Tkinter import Tk, Text from test.test_support import requires class Is_Get_Test(unittest.TestCase): """Test the is_ and get_ functions""" test_comment = '# This is a comment' test_nocomment = 'This is not a comment' trailingws_comment = '# This is a comment ' leadingws_comment = ' # This is a comment' leadingws_nocomment = ' This is not a comment' def test_is_all_white(self): self.assertTrue(fp.is_all_white('')) self.assertTrue(fp.is_all_white('\t\n\r\f\v')) self.assertFalse(fp.is_all_white(self.test_comment)) def test_get_indent(self): Equal = self.assertEqual Equal(fp.get_indent(self.test_comment), '') Equal(fp.get_indent(self.trailingws_comment), '') Equal(fp.get_indent(self.leadingws_comment), ' ') Equal(fp.get_indent(self.leadingws_nocomment), ' ') def test_get_comment_header(self): Equal = self.assertEqual # Test comment strings Equal(fp.get_comment_header(self.test_comment), '#') Equal(fp.get_comment_header(self.trailingws_comment), '#') Equal(fp.get_comment_header(self.leadingws_comment), ' #') # Test non-comment strings Equal(fp.get_comment_header(self.leadingws_nocomment), ' ') Equal(fp.get_comment_header(self.test_nocomment), '') class FindTest(unittest.TestCase): """Test the find_paragraph function in FormatParagraph. Using the runcase() function, find_paragraph() is called with 'mark' set at multiple indexes before and inside the test paragraph. It appears that code with the same indentation as a quoted string is grouped as part of the same paragraph, which is probably incorrect behavior. """ @classmethod def setUpClass(cls): from idlelib.idle_test.mock_tk import Text cls.text = Text() def runcase(self, inserttext, stopline, expected): # Check that find_paragraph returns the expected paragraph when # the mark index is set to beginning, middle, end of each line # up to but not including the stop line text = self.text text.insert('1.0', inserttext) for line in range(1, stopline): linelength = int(text.index("%d.end" % line).split('.')[1]) for col in (0, linelength//2, linelength): tempindex = "%d.%d" % (line, col) self.assertEqual(fp.find_paragraph(text, tempindex), expected) text.delete('1.0', 'end') def test_find_comment(self): comment = ( "# Comment block with no blank lines before\n" "# Comment line\n" "\n") self.runcase(comment, 3, ('1.0', '3.0', '#', comment[0:58])) comment = ( "\n" "# Comment block with whitespace line before and after\n" "# Comment line\n" "\n") self.runcase(comment, 4, ('2.0', '4.0', '#', comment[1:70])) comment = ( "\n" " # Indented comment block with whitespace before and after\n" " # Comment line\n" "\n") self.runcase(comment, 4, ('2.0', '4.0', ' #', comment[1:82])) comment = ( "\n" "# Single line comment\n" "\n") self.runcase(comment, 3, ('2.0', '3.0', '#', comment[1:23])) comment = ( "\n" " # Single line comment with leading whitespace\n" "\n") self.runcase(comment, 3, ('2.0', '3.0', ' #', comment[1:51])) comment = ( "\n" "# Comment immediately followed by code\n" "x = 42\n" "\n") self.runcase(comment, 3, ('2.0', '3.0', '#', comment[1:40])) comment = ( "\n" " # Indented comment immediately followed by code\n" "x = 42\n" "\n") self.runcase(comment, 3, ('2.0', '3.0', ' #', comment[1:53])) comment = ( "\n" "# Comment immediately followed by indented code\n" " x = 42\n" "\n") self.runcase(comment, 3, ('2.0', '3.0', '#', comment[1:49])) def test_find_paragraph(self): teststring = ( '"""String with no blank lines before\n' 'String line\n' '"""\n' '\n') self.runcase(teststring, 4, ('1.0', '4.0', '', teststring[0:53])) teststring = ( "\n" '"""String with whitespace line before and after\n' 'String line.\n' '"""\n' '\n') self.runcase(teststring, 5, ('2.0', '5.0', '', teststring[1:66])) teststring = ( '\n' ' """Indented string with whitespace before and after\n' ' Comment string.\n' ' """\n' '\n') self.runcase(teststring, 5, ('2.0', '5.0', ' ', teststring[1:85])) teststring = ( '\n' '"""Single line string."""\n' '\n') self.runcase(teststring, 3, ('2.0', '3.0', '', teststring[1:27])) teststring = ( '\n' ' """Single line string with leading whitespace."""\n' '\n') self.runcase(teststring, 3, ('2.0', '3.0', ' ', teststring[1:55])) class ReformatFunctionTest(unittest.TestCase): """Test the reformat_paragraph function without the editor window.""" def test_reformat_paragraph(self): Equal = self.assertEqual reform = fp.reformat_paragraph hw = "O hello world" Equal(reform(' ', 1), ' ') Equal(reform("Hello world", 20), "Hello world") # Test without leading newline Equal(reform(hw, 1), "O\nhello\nworld") Equal(reform(hw, 6), "O\nhello\nworld") Equal(reform(hw, 7), "O hello\nworld") Equal(reform(hw, 12), "O hello\nworld") Equal(reform(hw, 13), "O hello world") # Test with leading newline hw = "\nO hello world" Equal(reform(hw, 1), "\nO\nhello\nworld") Equal(reform(hw, 6), "\nO\nhello\nworld") Equal(reform(hw, 7), "\nO hello\nworld") Equal(reform(hw, 12), "\nO hello\nworld") Equal(reform(hw, 13), "\nO hello world") class ReformatCommentTest(unittest.TestCase): """Test the reformat_comment function without the editor window.""" def test_reformat_comment(self): Equal = self.assertEqual # reformat_comment formats to a minimum of 20 characters test_string = ( " \"\"\"this is a test of a reformat for a triple quoted string" " will it reformat to less than 70 characters for me?\"\"\"") result = fp.reformat_comment(test_string, 70, " ") expected = ( " \"\"\"this is a test of a reformat for a triple quoted string will it\n" " reformat to less than 70 characters for me?\"\"\"") Equal(result, expected) test_comment = ( "# this is a test of a reformat for a triple quoted string will " "it reformat to less than 70 characters for me?") result = fp.reformat_comment(test_comment, 70, "#") expected = ( "# this is a test of a reformat for a triple quoted string will it\n" "# reformat to less than 70 characters for me?") Equal(result, expected) class FormatClassTest(unittest.TestCase): def test_init_close(self): instance = fp.FormatParagraph('editor') self.assertEqual(instance.editwin, 'editor') instance.close() self.assertEqual(instance.editwin, None) # For testing format_paragraph_event, Initialize FormatParagraph with # a mock Editor with .text and .get_selection_indices. The text must # be a Text wrapper that adds two methods # A real EditorWindow creates unneeded, time-consuming baggage and # sometimes emits shutdown warnings like this: # "warning: callback failed in WindowList # : invalid command name ".55131368.windows". # Calling EditorWindow._close in tearDownClass prevents this but causes # other problems (windows left open). class TextWrapper: def __init__(self, master): self.text = Text(master=master) def __getattr__(self, name): return getattr(self.text, name) def undo_block_start(self): pass def undo_block_stop(self): pass class Editor: def __init__(self, root): self.text = TextWrapper(root) get_selection_indices = EditorWindow. get_selection_indices.im_func class FormatEventTest(unittest.TestCase): """Test the formatting of text inside a Text widget. This is done with FormatParagraph.format.paragraph_event, which calls functions in the module as appropriate. """ test_string = ( " '''this is a test of a reformat for a triple " "quoted string will it reformat to less than 70 " "characters for me?'''\n") multiline_test_string = ( " '''The first line is under the max width.\n" " The second line's length is way over the max width. It goes " "on and on until it is over 100 characters long.\n" " Same thing with the third line. It is also way over the max " "width, but FormatParagraph will fix it.\n" " '''\n") multiline_test_comment = ( "# The first line is under the max width.\n" "# The second line's length is way over the max width. It goes on " "and on until it is over 100 characters long.\n" "# Same thing with the third line. It is also way over the max " "width, but FormatParagraph will fix it.\n" "# The fourth line is short like the first line.") @classmethod def setUpClass(cls): requires('gui') cls.root = Tk() editor = Editor(root=cls.root) cls.text = editor.text.text # Test code does not need the wrapper. cls.formatter = fp.FormatParagraph(editor).format_paragraph_event # Sets the insert mark just after the re-wrapped and inserted text. @classmethod def tearDownClass(cls): del cls.text, cls.formatter cls.root.destroy() del cls.root def test_short_line(self): self.text.insert('1.0', "Short line\n") self.formatter("Dummy") self.assertEqual(self.text.get('1.0', 'insert'), "Short line\n" ) self.text.delete('1.0', 'end') def test_long_line(self): text = self.text # Set cursor ('insert' mark) to '1.0', within text. text.insert('1.0', self.test_string) text.mark_set('insert', '1.0') self.formatter('ParameterDoesNothing', limit=70) result = text.get('1.0', 'insert') # find function includes \n expected = ( " '''this is a test of a reformat for a triple quoted string will it\n" " reformat to less than 70 characters for me?'''\n") # yes self.assertEqual(result, expected) text.delete('1.0', 'end') # Select from 1.11 to line end. text.insert('1.0', self.test_string) text.tag_add('sel', '1.11', '1.end') self.formatter('ParameterDoesNothing', limit=70) result = text.get('1.0', 'insert') # selection excludes \n expected = ( " '''this is a test of a reformat for a triple quoted string will it reformat\n" " to less than 70 characters for me?'''") # no self.assertEqual(result, expected) text.delete('1.0', 'end') def test_multiple_lines(self): text = self.text # Select 2 long lines. text.insert('1.0', self.multiline_test_string) text.tag_add('sel', '2.0', '4.0') self.formatter('ParameterDoesNothing', limit=70) result = text.get('2.0', 'insert') expected = ( " The second line's length is way over the max width. It goes on and\n" " on until it is over 100 characters long. Same thing with the third\n" " line. It is also way over the max width, but FormatParagraph will\n" " fix it.\n") self.assertEqual(result, expected) text.delete('1.0', 'end') def test_comment_block(self): text = self.text # Set cursor ('insert') to '1.0', within block. text.insert('1.0', self.multiline_test_comment) self.formatter('ParameterDoesNothing', limit=70) result = text.get('1.0', 'insert') expected = ( "# The first line is under the max width. The second line's length is\n" "# way over the max width. It goes on and on until it is over 100\n" "# characters long. Same thing with the third line. It is also way over\n" "# the max width, but FormatParagraph will fix it. The fourth line is\n" "# short like the first line.\n") self.assertEqual(result, expected) text.delete('1.0', 'end') # Select line 2, verify line 1 unaffected. text.insert('1.0', self.multiline_test_comment) text.tag_add('sel', '2.0', '3.0') self.formatter('ParameterDoesNothing', limit=70) result = text.get('1.0', 'insert') expected = ( "# The first line is under the max width.\n" "# The second line's length is way over the max width. It goes on and\n" "# on until it is over 100 characters long.\n") self.assertEqual(result, expected) text.delete('1.0', 'end') # The following block worked with EditorWindow but fails with the mock. # Lines 2 and 3 get pasted together even though the previous block left # the previous line alone. More investigation is needed. ## # Select lines 3 and 4 ## text.insert('1.0', self.multiline_test_comment) ## text.tag_add('sel', '3.0', '5.0') ## self.formatter('ParameterDoesNothing') ## result = text.get('3.0', 'insert') ## expected = ( ##"# Same thing with the third line. It is also way over the max width,\n" ##"# but FormatParagraph will fix it. The fourth line is short like the\n" ##"# first line.\n") ## self.assertEqual(result, expected) ## text.delete('1.0', 'end') if __name__ == '__main__': unittest.main(verbosity=2, exit=2) PK™e[b檇 __init__.pynu['''idlelib.idle_test is a private implementation of test.test_idle, which tests the IDLE application as part of the stdlib test suite. Run IDLE tests alone with "python -m test.test_idle". This package and its contained modules are subject to change and any direct use is at your own risk. ''' from os.path import dirname def load_tests(loader, standard_tests, pattern): this_dir = dirname(__file__) top_dir = dirname(dirname(this_dir)) package_tests = loader.discover(start_dir=this_dir, pattern='test*.py', top_level_dir=top_dir) standard_tests.addTests(package_tests) return standard_tests PK™e[jPPtest_parenmatch.pycnu[PK™e[,test_rstrip.pyonu[PK™e[>8== mock_idle.pynu[PK™e[,8#test_rstrip.pycnu[PK™e[I+ d*test_warning.pycnu[PK™e[мz7test_widgetredir.pycnu[PK™e[j? ? Pmock_idle.pycnu[PK™e[H''*\test_delegator.pycnu[PK™e[7غi1i1atest_searchengine.pycnu[PK™e[ggAtest_textview.pyonu[PK™e[jPP5test_parenmatch.pyonu[PK™e[bF_ _ Ⱥtest_editmenu.pynu[PK™e[gtest_autoexpand.pycnu[PK™e[Rwwptest_configdialog.pyonu[PK™e[r,test_pathbrowser.pycnu[PK™e[=test_autocomplete.pyonu[PK™e[j? ? fmock_idle.pyonu[PK™e[L) test_calltips.pynu[PK™e[F*7; ; &test_helpabout.pyonu[PK™e[^c/c//test_calltips.pyonu[PK™e[' '_test_text.pyonu[PK™e[Hvp8test_delegator.pynu[PK™e[p-test_config_name.pyonu[PK™e[)WWwtest_editmenu.pycnu[PK™e[1uftest_searchdialogbase.pycnu[PK™e[ F77test_formatparagraph.pyonu[PK™e[c$' 9test_config_name.pynu[PK™e[b$test_idlehistory.pyonu[PK™e[k 6#test_grep.pyonu[PK™e[^c/c/#2test_calltips.pycnu[PK™e[I+ atest_warning.pyonu[PK™e[ n__init__.pycnu[PK™e[̏d44rtest_hyperparser.pynu[PK™e[}J0J0 #mock_tk.pycnu[PK™e[ - - test_io.pyonu[PK™e[G% test_textview.pynu[PK™e[fMM"test_rstrip.pynu[PK™e[`test_parenmatch.pynu[PK™e[sOtt README.txtnu[PK™e[rtest_pathbrowser.pyonu[PK™e[A::#test_autocomplete.pynu[PK™e[s",,7test_searchengine.pynu[PK™e[J_ =dtest_grep.pynu[PK™e[1ufCotest_searchdialogbase.pyonu[PK™e[ '.QQ7test_widgetredir.pynu[PK™e[gg˚test_textview.pycnu[PK™e[qiItest_configdialog.pynu[PK™e[p-test_config_name.pycnu[PK™e[' test_text.pycnu[PK™e[k test_grep.pycnu[PK™e[btest_idlehistory.pycnu[PK™e[ZKKtest_helpabout.pynu[PK™e[Ytest_searchdialogbase.pynu[PK™e[ ww,test_idlehistory.pynu[PK™e[|NNBtest_hyperparser.pycnu[PK™e[|NN]test_hyperparser.pyonu[PK™e[}J0J0 wmock_tk.pyonu[PK™e[ F77/test_formatparagraph.pycnu[PK™e[etest_autocomplete.pycnu[PK™e[055htest.pynu[PK™e[)WW-test_editmenu.pyonu[PK™e[м1?test_widgetredir.pyonu[PK™e[ޅy8181 eXhtest.pycnu[PK™e[ ։__init__.pyonu[PK™e[