3 2a@sddlmZddlZddlmZedddlZddlmZddl m Z ddl m Z ddl mZd d Zd d ZGd ddejZGdddejZGdddejZGdddejZGdddejZedkrejdddS))textviewN)requiresZgui)Tk)Button)Func) Mbox_funccCstatjdS)N)rrootwithdrawr r 2/opt/alt/python36/lib64/python3.6/test_textview.py setUpModulesr cCstjtjbdS)N)rupdate_idletasksdestroyr r r r tearDownModulesrc@seZdZeZeZeZdS)VWN)__name__ __module__ __qualname__r transientgrab_set wait_windowr r r r r#src@s,eZdZddZddZddZddZd S) ViewWindowTestcCs"tjjtjjtjjdS)N)rr__init__rr)selfr r r setUp,s  zViewWindowTest.setUpcCsBttdd}|jtjj|jtjj|jtjj|jdS)NTitlez test text)rr assertTruercalledrrok)rviewr r r test_init_modal1s  zViewWindowTest.test_init_modalcCsFttdddd}|jtjj|jtjj|jtjj|jdS)Nrz test textF)modal)rrZ assertFalserrrrr)rrr r r test_init_nonmodal8s z!ViewWindowTest.test_init_nonmodalcCs>ttdddd}t|_|j|j|jj|`|jdS)Nrz test textF)r!)rrrrrrr)rrr r r test_ok?s zViewWindowTest.test_okN)rrrrr r"r#r r r r r*src@s,eZdZeddZeddZddZdS) TextFrameTestcCs&t|_}|jtj|d|_dS)Nz test text)rrr tvZ TextFrameframe)clsrr r r setUpClassJs zTextFrameTest.setUpClasscCs |`|jj|jj|`dS)N)r&rr r)r'r r r tearDownClassPs  zTextFrameTest.tearDownClasscCs |jjj}|j|ddddS)Nz1.0z1.endz test text)r&textget assertEqual)rr+r r r test_line1Ws zTextFrameTest.test_line1N)rrr classmethodr(r)r-r r r r r$Hs  r$c@sLeZdZeddZeddZddZddZd d Zd d Z d dZ dS)ViewFunctionTestcCstj|_tt_dS)N)r% showerror orig_errorr)r'r r r r(_szViewFunctionTest.setUpClasscCs|jt_|`dS)N)r1r%r0)r'r r r r)dszViewFunctionTest.tearDownClasscCs>tjtdddd}|j|tj|j|jtj|jjdS)Nrz test textF)r!)r% view_textrassertIsInstance ViewWindow viewframe ViewFramer)rrr r r test_view_textiszViewFunctionTest.test_view_textcCs\tjtdtddd}|j|tj|j|jtj|jjj j }|j d|dd|j dS)NrasciiF)r!ZTestz1.0z1.end) r% view_filer__file__r3r4r5r6 textframer*r+ZassertInr)rrr+r r r test_view_fileos  zViewFunctionTest.test_view_filecCs2tjtddddd}|j||jtjjddS)Nrzabc.xyzr8F)r!zFile Load Error)r%r9r assertIsNoner,r0title)rrr r r test_bad_filews zViewFunctionTest.test_bad_filecCsRtj}|j|j|jtdd}tjtd|ddd}|j ||j tj j ddS)Nz..z CREDITS.txtrr8F)r!zUnicode Decode Error) ospathabspathjoindirnamer:r%r9rr=r,r0r>)rpfnrr r r test_bad_encoding}s  z"ViewFunctionTest.test_bad_encodingcCs4tjtddddd}|jjj}|j|jdddS)NrZtestFZnone)r!wraprH)r%r2rr5r;r*r,Zcget)rrZ text_widgetr r r test_nowraps zViewFunctionTest.test_nowrapN) rrrr.r(r)r7r<r?rGrIr r r r r/]s  r/c@s,eZdZddZddZddZddZd S) ButtonClickTestcCsd|_d|_dS)NF)rr)rr r r rszButtonClickTest.setUpcCs|jr|jjdS)N)rr)rr r r tearDownszButtonClickTest.tearDowncsnfdd}ttd|d}|jj|jjjdjjjdjjj j j j ddd dS) Ncsd_tjtdddd_dS)NT TITLE_TEXTCOMMAND)_utest)rr%r2rrr )rr r _commandszAButtonClickTest.test_view_text_bind_with_button.._commandBUTTON)r*commandTrLz1.0z1.endrM) rrinvoke addCleanuprr,rrr>r5r;r*r+)rrObuttonr )rr test_view_text_bind_with_buttons  z/ButtonClickTest.test_view_text_bind_with_buttonc sfdd}ttd|d}|jj|jjjdjjjdjj j j j }t tB}j|dd|jj|jj|d d |jjWdQRXdS) Ncs d_tjtdtddd_dS)NT TITLE_FILEr8)encodingrN)rr%r9rr:rr )rr r rOs zAButtonClickTest.test_view_file_bind_with_button.._commandrP)r*rQTrVz1.0z1.endz3.0z3.end)rrrRrSrr,rrr>r5r;r*r+openr:readlinestrip)rrOrTr+fr )rr test_view_file_bind_with_buttons   z/ButtonClickTest.test_view_file_bind_with_buttonN)rrrrrKrUr\r r r r rJs rJ__main__) verbosity)Zidlelibrr%ZunittestZ test.supportrr@ZtkinterrZ tkinter.ttkrZidlelib.idle_test.mock_idlerZidlelib.idle_test.mock_tkrr rr4rZTestCaserr$r/rJrmainr r r r s"       .)