B „ fÄã@sdZddlmZddlmZedƒddlZddlZddlm Z m Z m Z m Z m Z ddlmZddlmZdd lmZd d „Zd d „ZGdd„dejƒZGdd„dejƒZGdd„dejƒZGdd„dejƒZGdd„dejƒZGdd„dejƒZGdd„dejƒZedkrej dddS)aTest textview, coverage 100%. Since all methods and functions create (or destroy) a ViewWindow, which is a widget containing a widget, etcetera, all tests must be gui tests. Using mock Text would not change this. Other mocks are used to retrieve information about calls. é)Útextview)ÚrequiresZguiN)ÚTkÚTclErrorÚCHARÚNONEÚWORD)ÚButton)ÚFunc)Ú Mbox_funccCstƒat ¡dS)N)rÚrootÚwithdraw©rrúD/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_textview.pyÚ setUpModulesrcCst ¡t ¡bdS)N)r Úupdate_idletasksÚdestroyrrrrÚtearDownModulesrc@seZdZeƒZeƒZeƒZdS)ÚVWN)Ú__name__Ú __module__Ú __qualname__r Ú transientÚgrab_setÚ wait_windowrrrrr#src@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚViewWindowTestcCs"tj ¡tj ¡tj ¡dS)N)rrÚ__init__rr)ÚselfrrrÚsetUp,s  zViewWindowTest.setUpcCsBttddƒ}| tjj¡| tjj¡| tjj¡| ¡dS)NÚTitlez test text)rr Ú assertTruerÚcalledrrÚok)rÚviewrrrÚtest_init_modal1s  zViewWindowTest.test_init_modalcCsFttdddd}| tjj¡| tjj¡| tjj¡| ¡dS)Nrz test textF)Úmodal)rr Z assertFalserr!rrr")rr#rrrÚtest_init_nonmodal8s z!ViewWindowTest.test_init_nonmodalcCs>ttdddd}tƒ|_| ¡| |jj¡|`| ¡dS)Nrz test textF)r%)rr r rr"r r!)rr#rrrÚtest_ok?s zViewWindowTest.test_okN)rrrrr$r&r'rrrrr*src@seZdZdd„ZdS)ÚAutoHideScrollbarTestcCs*t t¡}| t|j¡| t|j¡dS)N)ÚtvZAutoHideScrollbarr Z assertRaisesrZpackZplace)rZscrollrrrÚtest_forbidden_geometryJs z-AutoHideScrollbarTest.test_forbidden_geometryN)rrrr*rrrrr(Hsr(c@s@eZdZedd„ƒZedd„ƒZefdd„Zdd„Zd d „Z d S) ÚScrollableTextFrameTestcCstƒ|_}| ¡dS)N)rr r )Úclsr rrrÚ setUpClassRs z"ScrollableTextFrameTest.setUpClasscCs|j ¡|j ¡|`dS)N)r rr)r,rrrÚ tearDownClassWs  z%ScrollableTextFrameTest.tearDownClassc s2tj|jfd|i|—މ‡fdd„}| |¡ˆS)NÚwrapcsˆ ¡ˆ ¡dS)N)rrr)ÚframerrÚ cleanup_frame_sz9ScrollableTextFrameTest.make_frame..cleanup_frame)r)ZScrollableTextFramer Ú addCleanup)rr/Úkwargsr1r)r0rÚ make_frame]s  z"ScrollableTextFrameTest.make_framecCs0| ¡}|j dd¡| |j dd¡d¡dS)Nz1.0z test textz1.end)r4ÚtextÚinsertÚ assertEqualÚget)rr0rrrÚ test_line1esz"ScrollableTextFrameTest.test_line1c Cs†|jtd}| |j d¡t¡| |j¡xTttgD]H}|j |d2|j|d}| |j d¡|¡|  |j¡WdQRXq6WdS)N)r/r/) r4rr7r5ÚcgetZassertIsNotNoneZxscrollrrZsubTestÚ assertIsNone)rr0r/rrrÚtest_horiz_scrollbarjs   z,ScrollableTextFrameTest.test_horiz_scrollbarN) rrrÚ classmethodr-r.rr4r9r<rrrrr+Ps    r+c@s,eZdZedd„ƒZedd„ƒZdd„ZdS)Ú ViewFrameTestcCs&tƒ|_}| ¡t |d¡|_dS)Nz test text)rr r r)Ú ViewFramer0)r,r rrrr-~s zViewFrameTest.setUpClasscCs |`|j ¡|j ¡|`dS)N)r0r rr)r,rrrr.„s  zViewFrameTest.tearDownClasscCs |jjj}| |ddƒd¡dS)Nz1.0z1.endz test text)r0r5r8r7)rr8rrrr9‹s zViewFrameTest.test_line1N)rrrr=r-r.r9rrrrr>|s  r>c@sLeZdZedd„ƒZedd„ƒZdd„Zdd„Zd d „Zd d „Z d d„Z dS)ÚViewFunctionTestcCstj|_tƒt_dS)N)r)Ú showerrorÚ orig_errorr )r,rrrr-“szViewFunctionTest.setUpClasscCs|jt_|`dS)N)rBr)rA)r,rrrr.˜szViewFunctionTest.tearDownClasscCs>tjtdddd}| |tj¡| |jtj¡|j ¡dS)Nrz test textF)r%)r)Ú view_textr ÚassertIsInstanceÚ ViewWindowÚ viewframer?r")rr#rrrÚtest_view_textszViewFunctionTest.test_view_textcCs\tjtdtddd}| |tj¡| |jtj¡|jjj j }|  d|ddƒ¡|  ¡dS)NrÚasciiF)r%ZTestz1.0z1.end) r)Ú view_filer Ú__file__rDrErFr?Ú textframer5r8ZassertInr")rr#r8rrrÚtest_view_file£s  zViewFunctionTest.test_view_filecCs2tjtddddd}| |¡| tjjd¡dS)Nrzabc.xyzrHF)r%zFile Load Error)r)rIr r;r7rAÚtitle)rr#rrrÚ test_bad_file«s zViewFunctionTest.test_bad_filecCsRtj}| | | t¡dd¡¡}tjtd|ddd}|  |¡|  tj j d¡dS)Nz..z CREDITS.txtrrHF)r%zUnicode Decode Error) ÚosÚpathÚabspathÚjoinÚdirnamerJr)rIr r;r7rArM)rÚpÚfnr#rrrÚtest_bad_encoding±s  z"ViewFunctionTest.test_bad_encodingcCs4tjtddddd}|jjj}| | d¡d¡dS)NrZtestFZnone)r%r/r/)r)rCr rFrKr5r7r:)rr#Z text_widgetrrrÚ test_nowrap¸s zViewFunctionTest.test_nowrapN) rrrr=r-r.rGrLrNrVrWrrrrr@‘s  r@c@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚButtonClickTestcCsd|_d|_dS)NF)r#r!)rrrrrÁszButtonClickTest.setUpcCs|jr|j ¡dS)N)r#r)rrrrÚtearDownÅszButtonClickTest.tearDowncsn‡fdd„}ttd|d}| ¡ˆ |j¡ˆ ˆjd¡ˆ ˆj ¡d¡ˆ ˆjj j j   dd¡d ¡dS) Ncsdˆ_tjtddddˆ_dS)NTÚ TITLE_TEXTÚCOMMAND)Ú_utest)r!r)rCr r#r)rrrÚ_commandÊszAButtonClickTest.test_view_text_bind_with_button.._commandÚBUTTON)r5ÚcommandTrZz1.0z1.endr[) r r Úinvoker2rr7r!r#rMrFrKr5r8)rr]Úbuttonr)rrÚtest_view_text_bind_with_buttonÉs  z/ButtonClickTest.test_view_text_bind_with_buttonc s°‡fdd„}ttd|d}| ¡ˆ |j¡ˆ ˆjd¡ˆ ˆj ¡d¡ˆjj j j j }t tƒB}ˆ |ddƒ| ¡ ¡¡| ¡ˆ |d d ƒ| ¡ ¡¡WdQRXdS) Ncs dˆ_tjtdtdddˆ_dS)NTÚ TITLE_FILErH)Úencodingr\)r!r)rIr rJr#r)rrrr]×s zAButtonClickTest.test_view_file_bind_with_button.._commandr^)r5r_Trcz1.0z1.endz3.0z3.end)r r r`r2rr7r!r#rMrFrKr5r8ÚopenrJÚreadlineÚstrip)rr]rar8Úfr)rrÚtest_view_file_bind_with_buttonÖs   z/ButtonClickTest.test_view_file_bind_with_buttonN)rrrrrYrbrirrrrrX¿s rXÚ__main__é)Ú verbosity)!Ú__doc__Zidlelibrr)Z test.supportrrOZunittestZtkinterrrrrrZ tkinter.ttkr Zidlelib.idle_test.mock_idler Zidlelib.idle_test.mock_tkr rrrErZTestCaserr(r+r>r@rXrÚmainrrrrÚs(      ,.)