ó {fc@sydZddlZddlZddlmZmZmZddlZddlm Z ddl m Z m Z ddl mZd„Zd„Zd dd „ƒYZd ejfd „ƒYZd ejfd„ƒYZdejfd„ƒYZdejfd„ƒYZdejfd„ƒYZdejfd„ƒYZdejfd„ƒYZedkruejddddƒndS(s9Test functions and SearchEngine class in SearchEngine.py.iÿÿÿÿN(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  tMockcBseZd„ZRS(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 stGetTestcBseZd„ZRS(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!stGetLineColTestcBseZd„ZRS(cCsb|jtjdƒdƒ|jtjdƒd ƒ|jttjdƒ|jttjdƒdS( 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/stGetSelectionTestcBseZd„ZRS(cCsstƒ}|jddƒd„}||_|jtj|ƒdƒd„}||_|jtj|ƒdƒdS( Ns1.0s Hello World!cSs*|dkrdS|dkr dSt‚dS(Ns sel.firsts1.0ssel.lasts1.12(R(ts((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pytselKs   s1.12cSs|dkrdSt‚dS(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 tReverseSearchTestcBseZd„ZRS(cCsÌ|j}d}tjdƒ}|tj||t|ƒƒjƒd ƒ|tj||dƒjƒd ƒ|tj||dƒjƒd ƒ|tj||dƒjƒd ƒ|tj||dƒdƒdS( 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>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCstjddƒ|_dS(NR(RRR4R(R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pytsetUpkscCsW|j}|j}||jƒdƒ|jdƒ||jƒdƒ||jƒtƒ|jjdƒ||jƒtƒ||j ƒtƒ|j jdƒ||j ƒtƒ||j ƒtƒ|j jdƒ||j ƒtƒ||j ƒtƒ|jjdƒ||j ƒtƒ||jƒtƒ|jjdƒ||jƒtƒdS(NRthelloii(RRtgetpattsetpattisretFalsetrevartsettTruetiscasetcasevartiswordtwordvartiswraptwrapvartisbacktbackvar(R RR5((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt test_is_getps(   cCsc|j}|jdƒ|j|jƒdƒ|jjdƒ|jdƒ|j|jƒdƒdS(Ns\sis\\s(Rt setcookedpatRR<R@RA(R R((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_setcookedpatŒs    cCs¿|j}|j}||jƒdƒ|jdƒ||jƒdƒ|jjtƒ||jƒdƒ|jjtƒ|jdƒ||jƒdƒ|jjtƒ||jƒdƒdS(NRR;s \bhello\bs\ss\\s( RRt getcookedpatR=RFRARBR?R@(R RR5((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyttest_getcookedpat”s    cCsò|j}|j}|jdƒ|jƒ}||jtjdtjƒjƒ|jj dƒ|jƒ}||jtjdƒjdƒ|jdƒ||jƒdƒ|jdƒ|j j dƒ||jƒdƒ|jt j jdƒdS(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_getprog¤s    "   cCsµtj}|j}d}d}||jj||ƒdƒ||jdƒd|d}||j|ƒ||jj||dƒdƒ||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_error·s   (RRR:RKRMRORXR^(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR9hs      t SearchTestcBs eZed„ƒZd„ZRS(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.pytÙRcWs d|fS(Ntb((R ((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyRbÚR( R(R+R&R/R0R[RRR4Rtsearch_forwardtsearch_backward(tclst test_text((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyt setUpClassËs c Cs|j}|j}|j}|j}|j}|jjdƒ|||ƒdƒd„}||_||||ƒ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 ffƒdS( NcSs|dkrdSt‚dS(NR&s1.5(R(R$((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR'ìs RaiiRccSs*|dkrdS|dkr dSt‚dS(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_searchás.       ...  .1.(RRt classmethodRhRl(((s;/usr/lib64/python2.7/idlelib/idle_test/test_searchengine.pyR_ÈstForwardBackwardTestcBs2eZed„ƒZd„Zd„Zd„ZRS(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 csd‡‡fd†}|S(Nics@ˆˆj|||||ƒ}|r<|d|djƒfS|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ƒ|||ddtƒdƒ|||ddtƒ|jƒ|||j ddtƒdƒ|||j ddtdtƒddfƒ|||j ddtƒ|jƒdS( 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ƒ|||ddtƒdƒ|||ddtƒ|jƒ|||j ddtƒdƒ|||j ddtdtƒdd fƒ|||j ddtƒdd fƒdS( 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