a 9êdgÄã@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ú;/usr/local/lib/python3.9/idlelib/idle_test/test_textview.pyÚ setUpModulesrcCst ¡t ¡bdSr ©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 ¡dSr )rrÚ__init__rr©ÚselfrrrÚsetUp,s  zViewWindowTest.setUpcCsBttddƒ}| tjj¡| tjj¡| tjj¡| ¡dS)NÚTitleú test text)rrÚ assertTruerÚcalledrrÚok©r!ÚviewrrrÚtest_init_modal1s  zViewWindowTest.test_init_modalcCsFttdddd}| tjj¡| tjj¡| tjj¡| ¡dS©Nr#r$F©Úmodal)rrZ assertFalserr&rrr'r(rrrÚtest_init_nonmodal8s z!ViewWindowTest.test_init_nonmodalcCs>ttdddd}tƒ|_| ¡| |jj¡|`| ¡dSr+)rrr rr'r%r&r(rrrÚtest_ok?s zViewWindowTest.test_okN)rrrr"r*r.r/rrrrr*src@seZdZdd„ZdS)ÚAutoHideScrollbarTestcCs*t t¡}| t|j¡| t|j¡dSr )ÚtvZAutoHideScrollbarrZ assertRaisesrÚpackZplace)r!ZscrollrrrÚtest_forbidden_geometryJs z-AutoHideScrollbarTest.test_forbidden_geometryN)rrrr3rrrrr0Hsr0c@s@eZdZedd„ƒZedd„ƒZefdd„Zdd„Zd d „Z d S) ÚScrollableTextFrameTestcCstƒ|_}| ¡dSr r ©ÚclsrrrrÚ setUpClassRs z"ScrollableTextFrameTest.setUpClasscCs|j ¡|j ¡|`dSr r©r6rrrÚ tearDownClassWs  z%ScrollableTextFrameTest.tearDownClassc s2tj|jfd|i|¤Ž‰‡fdd„}| |¡ˆS)NÚwrapcsˆ ¡ˆ ¡dSr )rrr©ÚframerrÚ cleanup_frame_sz9ScrollableTextFrameTest.make_frame..cleanup_frame)r1ZScrollableTextFramerÚ addCleanup)r!r:Úkwargsr=rr;rÚ make_frame]s  z"ScrollableTextFrameTest.make_framecCs0| ¡}|j dd¡| |j dd¡d¡dS)Nú1.0r$ú1.end)r@ÚtextÚinsertÚ assertEqualÚget)r!r<rrrÚ test_line1esz"ScrollableTextFrameTest.test_line1c Cs–|jtd}| |j d¡t¡| |j¡ttfD]\}|j |d<|j|d}| |j d¡|¡|  |j¡Wdƒq41s†0Yq4dS)N)r:r:) r@rrErCÚcgetZassertIsNotNoneZxscrollrrZsubTestÚ assertIsNone)r!r<r:rrrÚtest_horiz_scrollbarjs    z,ScrollableTextFrameTest.test_horiz_scrollbarN) rrrÚ classmethodr7r9rr@rGrJrrrrr4Ps   r4c@s,eZdZedd„ƒZedd„ƒZdd„ZdS)Ú ViewFrameTestcCs&tƒ|_}| ¡t |d¡|_dS)Nr$)rrrr1Ú ViewFramer<r5rrrr7~s zViewFrameTest.setUpClasscCs |`|j ¡|j ¡|`dSr )r<rrrr8rrrr9„s  zViewFrameTest.tearDownClasscCs |jjj}| |ddƒd¡dS)NrArBr$)r<rCrFrE)r!rFrrrrG‹s zViewFrameTest.test_line1N)rrrrKr7r9rGrrrrrL|s   rLc@sLeZdZedd„ƒZedd„ƒZdd„Zdd„Zd d „Zd d „Z d d„Z dS)ÚViewFunctionTestcCstj|_tƒt_dSr )r1Ú showerrorÚ orig_errorr r8rrrr7“szViewFunctionTest.setUpClasscCs|jt_|`dSr )rPr1rOr8rrrr9˜szViewFunctionTest.tearDownClasscCs>tjtdddd}| |tj¡| |jtj¡|j ¡dSr+)r1Ú view_textrÚassertIsInstanceÚ ViewWindowÚ viewframerMr'r(rrrÚtest_view_textszViewFunctionTest.test_view_textcCs\tjtdtddd}| |tj¡| |jtj¡|jjj j }|  d|ddƒ¡|  ¡dS)Nr#ÚasciiFr,ZTestrArB) r1Ú view_filerÚ__file__rRrSrTrMÚ textframerCrFZassertInr')r!r)rFrrrÚtest_view_file£s  zViewFunctionTest.test_view_filecCs2tjtddddd}| |¡| tjjd¡dS)Nr#zabc.xyzrVFr,zFile Load Error)r1rWrrIrErOÚtitler(rrrÚ test_bad_file«s zViewFunctionTest.test_bad_filecCsRtj}| | | t¡dd¡¡}tjtd|ddd}|  |¡|  tj j d¡dS)Nz..z CREDITS.txtr#rVFr,zUnicode Decode Error) ÚosÚpathÚabspathÚjoinÚdirnamerXr1rWrrIrErOr[)r!ÚpÚfnr)rrrÚtest_bad_encoding±s  z"ViewFunctionTest.test_bad_encodingcCs4tjtddddd}|jjj}| | d¡d¡dS)Nr#ÚtestFZnone)r-r:r:)r1rQrrTrYrCrErH)r!r)Z text_widgetrrrÚ test_nowrap¸s zViewFunctionTest.test_nowrapN) rrrrKr7r9rUrZr\rdrfrrrrrN‘s  rNc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚButtonClickTestcCsd|_d|_dS)NF)r)r&r rrrr"ÁszButtonClickTest.setUpcCs|jr|j ¡dSr )r)rr rrrÚ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&r1rQrr)rr rrÚ_commandÊszAButtonClickTest.test_view_text_bind_with_button.._commandÚBUTTON©rCZcommandTrirArBrj) r rÚinvoker>rrEr&r)r[rTrYrCrF)r!rlÚbuttonrr rÚtest_view_text_bind_with_buttonÉs  ÿz/ButtonClickTest.test_view_text_bind_with_buttoncsćfdd„}ttd|d}| ¡ˆ |j¡ˆ ˆjd¡ˆ ˆj ¡d¡ˆjj j j j }t tƒL}ˆ |ddƒ| ¡ ¡¡| ¡ˆ |d d ƒ| ¡ ¡¡Wdƒn1s¶0YdS) Ncs dˆ_tjtdtdddˆ_dS)NTÚ TITLE_FILErV)Úencodingrk)r&r1rWrrXr)rr rrrl×s ÿzAButtonClickTest.test_view_file_bind_with_button.._commandrmrnTrrrArBz3.0z3.end)r rror>rrEr&r)r[rTrYrCrFÚopenrXÚreadlineÚstrip)r!rlrprFÚfrr rÚtest_view_file_bind_with_buttonÖs   z/ButtonClickTest.test_view_file_bind_with_buttonN)rrrr"rhrqrxrrrrrg¿s rgÚ__main__é)Ú verbosity)!Ú__doc__Zidlelibrr1Z test.supportrr]ZunittestÚtkinterrrrrrZ tkinter.ttkr Zidlelib.idle_test.mock_idler Zidlelib.idle_test.mock_tkr rrrSrZTestCaserr0r4rLrNrgrÚmainrrrrÚs(      ,.)