a  ze@sddlmZddlmZedddlZddlZddlmZm Z m Z m Z m Z ddl mZddlmZddlmZd d Zd d ZGd ddejZGdddejZGdddejZGdddejZGdddejZGdddejZGdddejZedkrejdddS))textview)requiresZguiN)TkTclErrorCHARNONEWORD)Button)Func) Mbox_funccCstatdSNrrootwithdrawrrS/opt/bitninja-python-dojo/embedded/lib/python3.9/idlelib/idle_test/test_textview.py setUpModulesrcCsttbdSr rupdate_idletasksdestroyrrrrtearDownModulesrc@seZdZeZeZeZdS)VWN)__name__ __module__ __qualname__r transientgrab_set wait_windowrrrrr#src@s,eZdZddZddZddZddZd S) ViewWindowTestcCs"tjtjtjdSr )rr__init__rrselfrrrsetUp,s  zViewWindowTest.setUpcCsBttdd}|tjj|tjj|tjj|dS)NTitle test text)rr assertTruercalledrrokr!viewrrrtest_init_modal1s  zViewWindowTest.test_init_modalcCsFttdddd}|tjj|tjj|tjj|dSNr#r$Fmodal)rrZ assertFalserr&rrr'r(rrrtest_init_nonmodal8s z!ViewWindowTest.test_init_nonmodalcCs>ttdddd}t|_|||jj|`|dSr+)rrr rr'r%r&r(rrrtest_ok?s zViewWindowTest.test_okN)rrrr"r*r.r/rrrrr*src@seZdZddZdS)AutoHideScrollbarTestcCs*tt}|t|j|t|jdSr )tvZAutoHideScrollbarrZ assertRaisesrpackZplace)r!Zscrollrrrtest_forbidden_geometryJs z-AutoHideScrollbarTest.test_forbidden_geometryN)rrrr3rrrrr0Hsr0c@s@eZdZeddZeddZefddZddZd d Z d S) ScrollableTextFrameTestcCst|_}|dSr r clsrrrr setUpClassRs z"ScrollableTextFrameTest.setUpClasscCs|j|j|`dSr rr6rrr tearDownClassWs  z%ScrollableTextFrameTest.tearDownClassc s2tj|jfd|i|fdd}||S)NwrapcsdSr )rrrframerr cleanup_frame_sz9ScrollableTextFrameTest.make_frame..cleanup_frame)r1ZScrollableTextFramer addCleanup)r!r:kwargsr=rr;r make_frame]s  z"ScrollableTextFrameTest.make_framecCs0|}|jdd||jddddS)N1.0r$1.end)r@textinsert assertEqualget)r!r<rrr test_line1esz"ScrollableTextFrameTest.test_line1c Cs|jtd}||jdt||jttfD]\}|j |d<|j|d}||jd|| |jWdq41s0Yq4dS)N)r:r:) r@rrErCcgetZassertIsNotNoneZxscrollrrZsubTest assertIsNone)r!r<r:rrrtest_horiz_scrollbarjs    z,ScrollableTextFrameTest.test_horiz_scrollbarN) rrr classmethodr7r9rr@rGrJrrrrr4Ps   r4c@s,eZdZeddZeddZddZdS) ViewFrameTestcCs&t|_}|t|d|_dS)Nr$)rrrr1 ViewFramer<r5rrrr7~s zViewFrameTest.setUpClasscCs |`|j|j|`dSr )r<rrrr8rrrr9s  zViewFrameTest.tearDownClasscCs |jjj}||ddddS)NrArBr$)r<rCrFrE)r!rFrrrrGs zViewFrameTest.test_line1N)rrrrKr7r9rGrrrrrL|s   rLc@sLeZdZeddZeddZddZddZd d Zd d Z d dZ dS)ViewFunctionTestcCstj|_tt_dSr )r1 showerror orig_errorr r8rrrr7szViewFunctionTest.setUpClasscCs|jt_|`dSr )rPr1rOr8rrrr9szViewFunctionTest.tearDownClasscCs>tjtdddd}||tj||jtj|jdSr+)r1 view_textrassertIsInstance ViewWindow viewframerMr'r(rrrtest_view_textszViewFunctionTest.test_view_textcCs\tjtdtddd}||tj||jtj|jjj j }| d|dd| dS)Nr#asciiFr,ZTestrArB) r1 view_filer__file__rRrSrTrM textframerCrFZassertInr')r!r)rFrrrtest_view_files  zViewFunctionTest.test_view_filecCs2tjtddddd}|||tjjddS)Nr#zabc.xyzrVFr,zFile Load Error)r1rWrrIrErOtitler(rrr test_bad_files zViewFunctionTest.test_bad_filecCsRtj}|||tdd}tjtd|ddd}| || tj j ddS)Nz..z CREDITS.txtr#rVFr,zUnicode Decode Error) ospathabspathjoindirnamerXr1rWrrIrErOr[)r!pfnr)rrrtest_bad_encodings  z"ViewFunctionTest.test_bad_encodingcCs4tjtddddd}|jjj}||dddS)Nr#testFZnone)r-r:r:)r1rQrrTrYrCrErH)r!r)Z text_widgetrrr test_nowraps zViewFunctionTest.test_nowrapN) rrrrKr7r9rUrZr\rdrfrrrrrNs  rNc@s,eZdZddZddZddZddZd S) ButtonClickTestcCsd|_d|_dS)NF)r)r&r rrrr"szButtonClickTest.setUpcCs|jr|jdSr )r)rr rrrtearDownszButtonClickTest.tearDowncsnfdd}ttd|d}||jjdjdjj j j ddd dS) Ncsd_tjtdddd_dS)NT TITLE_TEXTCOMMAND)_utest)r&r1rQrr)rr rr_commandszAButtonClickTest.test_view_text_bind_with_button.._commandBUTTONrCZcommandTrirArBrj) r rinvoker>rrEr&r)r[rTrYrCrF)r!rlbuttonrr rtest_view_text_bind_with_buttons  z/ButtonClickTest.test_view_text_bind_with_buttoncsfdd}ttd|d}||jjdjdjj j j j }t tL}|dd|||d d |Wdn1s0YdS) Ncs d_tjtdtddd_dS)NT TITLE_FILErV)encodingrk)r&r1rWrrXr)rr rrrls zAButtonClickTest.test_view_file_bind_with_button.._commandrmrnTrrrArBz3.0z3.end)r rror>rrEr&r)r[rTrYrCrFopenrXreadlinestrip)r!rlrprFfrr rtest_view_file_bind_with_buttons   z/ButtonClickTest.test_view_file_bind_with_buttonN)rrrr"rhrqrxrrrrrgs rg__main__) verbosity) Zidlelibrr1Z test.supportrr]ZunittesttkinterrrrrrZ tkinter.ttkr Zidlelib.idle_test.mock_idler Zidlelib.idle_test.mock_tkr rrrSrZTestCaserr0r4rLrNrgrmainrrrrs&      ,.)