a 9êdgPã@s€dZddlmZddlZddlmZddlmZmZm Z ddl m Z Gdd„dej ƒZ Gd d „d ej ƒZed kr|ejd d dS)zTest redirector, coverage 100%.é)ÚWidgetRedirectorN)Úrequires)ÚTkÚTextÚTclError)ÚFuncc@s4eZdZedd„ƒZedd„ƒZdd„Zdd„Zd S) Ú InitCloseTestcCs*tdƒtƒ|_|j ¡t|jƒ|_dS©NZgui©rrÚrootZwithdrawrÚtext©Úcls©rú=/usr/local/lib/python3.9/idlelib/idle_test/test_redirector.pyÚ setUpClass s zInitCloseTest.setUpClasscCs|`|j ¡|`dS©N)r r Údestroyr rrrÚ tearDownClasss zInitCloseTest.tearDownClasscCsHt|jƒ}| |j|j¡| |j|jj¡| tt|j¡| ¡dSr)rr Ú assertEqualÚwidgetÚtkZ assertRaisesrÚclose©ÚselfÚredirrrrÚ test_inits  zInitCloseTest.test_initcCsBt|jƒ}| dt¡| ¡| |ji¡| t|jdƒ¡dS)NÚinsertr) rr ÚregisterrrrÚ _operationsÚ assertFalseÚhasattrrrrrÚ test_close s   zInitCloseTest.test_closeN)Ú__name__Ú __module__Ú __qualname__Ú classmethodrrrr"rrrrr s   rc@s|eZdZedd„ƒZedd„ƒZdd„Zdd„Zd d „Zd d „Z d d„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„ZdS)ÚWidgetRedirectorTestcCs*tdƒtƒ|_|j ¡t|jƒ|_dSr r r rrrr*s zWidgetRedirectorTest.setUpClasscCs |`|j ¡|j ¡|`dSr)r r Zupdate_idletasksrr rrrr1s  z"WidgetRedirectorTest.tearDownClasscCs8t|jƒ|_tƒ|_|j d|j¡|_|j dd¡dS)NrÚasdf)rr rrÚfuncrÚ orig_insertr©rrrrÚsetUp8s zWidgetRedirectorTest.setUpcCs|j dd¡|j ¡dS)Nú1.0Úend)r Údeleterrr+rrrÚtearDown>szWidgetRedirectorTest.tearDowncCs(| dt|jƒ¡| dt|jƒ¡dS)NZ RedirectorZOriginal)ÚassertInÚreprrr*r+rrrÚ test_reprBszWidgetRedirectorTest.test_reprcCs\| |j dd¡d¡| |jjd¡| d|jj¡| d|jj¡| |jj |j¡dS)Nr-r.Ú )rr(r) rr Úgetr)Úargsr1rrÚ__dict__rr+rrrÚ test_registerFs z"WidgetRedirectorTest.test_registercCsL| |jjd¡| |jj|jjj¡| dd¡| |j dd¡d¡dS)Nrr(r-r.zasdf )rr*Z operationZtk_callr rÚcallr5r+rrrÚtest_original_commandMs z*WidgetRedirectorTest.test_original_commandcCsL| |j d¡¡| |j d¡|j¡| d|jj¡| d|jj¡dS)Nzinvalid operation namer) Z assertIsNonerÚ unregisterrr)Z assertNotInrr r7r+rrrÚtest_unregisterSsz$WidgetRedirectorTest.test_unregistercCs |j`| |j d¡|j¡dS)Nr)r rrrr;r)r+rrrÚtest_unregister_no_attributeYsz1WidgetRedirectorTest.test_unregister_no_attributecCs6|j d¡| |j dd¡¡| |jjd¡dS)NTrFr)r)Ú__init__Z assertTruerÚdispatchr r6r+rrrÚtest_dispatch_intercept]s z,WidgetRedirectorTest.test_dispatch_interceptcCs>| dd¡| |j ddd¡d¡| |j dd¡d¡dS)Nrr(r/r-r.Úr4)r*rrr?r r5r+rrrÚtest_dispatch_bypassbs z)WidgetRedirectorTest.test_dispatch_bypasscCs<|j tƒ¡| |j dd¡d¡| |j d¡d¡dS)NrFrAÚinvalid)r)r>rrrr?r+rrrÚtest_dispatch_errorhsz(WidgetRedirectorTest.test_dispatch_errorcCsh|j |jjdd¡| |jjd¡| |j dd¡d¡|j t ƒ¡| |j |jjdd¡d¡dS) NrÚhello)rEr-r.r4ZboorA) r r9r Z_wrr)r6r5r>rr+rrrÚtest_command_dispatchms z*WidgetRedirectorTest.test_command_dispatchN)r#r$r%r&rrr,r0r3r8r:r<r=r@rBrDrFrrrrr'(s  r'Ú__main__é)Ú verbosity)Ú__doc__Zidlelib.redirectorrZunittestZ test.supportrÚtkinterrrrZidlelib.idle_test.mock_idlerZTestCaserr'r#ÚmainrrrrÚs   Q