JJޱ`&SrSSKrSSKrSSKrSSKJr SSKJr SSKJr SSK J r SSK J r \ R"S5r "S S 5r\ "S S \R\55r"S S\R\5r\S:Xa\R&"5 gg)zCTest InteractiveConsole and InteractiveInterpreter from code moduleN)dedent) ExitStack)mock)force_not_colorized_test_class) import_helpercodec\rSrSrSrSrg)MockSysc[5nURUR5 UR[R "SSS95UlUR[R "S55UlUR[R "S55Ul[R "S[R[RS9nURU5Ul [R[RLa%URRURl UR?UR?g) z.Mock system environment for InteractiveConsolez code.inputT)createzcode.sys.stdoutzcode.sys.stderrzcode.sys)wrapsspecN)r addCleanupclose enter_contextrpatchinfuncstdoutstderrrsyssysmod excepthook__excepthook__ps1ps2)selfstackprepatchs >S// /%)[[%?%?DKK " KKO KKO)rrrrN)__name__ __module__ __qualname____firstlineno__r!__static_attributes__r#r r r sr#r c~\rSrSrSrSrSrSrSrSr Sr S r S r S r S rS rSrSrSrSrSrSrSrg)TestInteractiveConsole!NcV[R5UlUR5 gNrInteractiveConsoleconsoler!rs r setUpTestInteractiveConsole.setUp%s..0  r#cZ[S5URlURR 5 UR UR RS5 SUR lURR 5 UR UR RS5 g)NFinishedz>>> z custom1> )EOFErrorr side_effectr1interact assertEqualrrr2s r test_ps1TestInteractiveConsole.test_ps1)n"*:"6   &1%   +6r#cZ[S5URlURR 5 UR UR RS5 SUR lURR 5 UR UR RS5 g)Nr6z... z custom2> )r7rr8r1r9r:rrr2s r test_ps2TestInteractiveConsole.test_ps21r=r#cSS[S5/URlURR 5 [ UR R5HnSSRUS5;dM g [S5e)Nz 'antioch'r6antiochzno console stdout) r7rr8r1r9listr method_callsjoinAssertionError)rcalls r test_console_stderr*TestInteractiveConsole.test_console_stderr9si#.HZ4H"I  112DBGGDG,,3!!45 5r#c:SSS[S5/URlURR 5 SR SUR R55nXRS5SnUSURS5nURUR5SS/S Q5 URURR[5 UR[URR 5[5 UR#URR$5 UR#URR R&5 URURR(URR 5 g) Ndef f(): x = ?rBr6c3J# UHnSRUS5v M g7frBrDNrG.0rIs r ;TestInteractiveConsole.test_syntax_error..H"O6Nda))6N!#(InteractiveConsole) now exitingrD)z File "", line 2rNz ^zSyntaxError: invalid syntax)r7rr8r1r9rGrrFindexr: splitlinesassertIsr last_type SyntaxErrortype last_value assertIsNonelast_traceback __traceback__last_excroutputs r test_syntax_error(TestInteractiveConsole.test_syntax_errorBs0#-#.#%$,Z$8#:  Odkk6N6NOO %;<=>6o67 **,QR03+ , dkk++[9 d4;;112K@ $++445 $++00>>? dkk**DKK,B,BCr#c6S[S5/URlURR 5 SR SUR R55nXRS5SnUSURS5nURUR5SS/SQ5 URURR[5 UR[URR 5[5 UR#URR$5 UR#URR R&5 URURR(URR 5 g) N 1r6rBc3J# UHnSRUS5v M g7frPrQrRs r rT@TestInteractiveConsole.test_indentation_error..YrVrWrXrYrD)z File "", line 1z 1z#IndentationError: unexpected indent)r7rr8r1r9rGrrFrZr:r[r\rr]IndentationErrorr_r`rarbrcrdres r test_indentation_error-TestInteractiveConsole.test_indentation_errorVs'#((:*>"?  Odkk6N6NOO %;<=>6o67 **,QR033 4 dkk++-=> d4;;1124DE $++445 $++00>>? dkk**DKK,B,BCr#c2S[S5/URlURR 5 SR SUR R55nXRS5SnXRS5S-SnURURS5U5 URURR[5 UR[URR 5[5 UR#URR$5 UR#URR R&5 URURR(URR 5 g) Nu''r6rBc3J# UHnSRUS5v M g7frPrQrRs r rT.irVrWrX rDzUnicodeEncodeError: )r7rr8r1r9rGrrFrZ assertTrue startswithr\rr]UnicodeEncodeErrorr_r`rarbrcrdres r test_unicode_error)TestInteractiveConsole.test_unicode_errorfs#-x /C"D  Odkk6N6NOO %;<=> T*Q./0 ))*@A6J dkk++-?@ d4;;1124FG $++445 $++00>>? dkk**DKK,B,BCr#cSSSS[S5/URl[R"5nXR lURR5 UR5 URUR RUR RUR R5 URUR R[5 UR[!UR R5[5 URUR RUR RR"5 URUR R$UR R5 UR'[(R*"UR R$5/SQ5 g)NrMz raise ValueError('BOOM!')rBzf()r6)z#Traceback (most recent call last): z( File "", line 1, in z! File "", line 2, in f zValueError: BOOM! )r7rr8rMockrrr1r9 assert_calledassert_called_withr]r`rbr\ ValueErrorr_rcrdr: tracebackformat_exceptionrhooks r test_sysexcepthook)TestInteractiveConsole.test_sysexcepthookss7#-#B#%#($,Z$8 #:  yy{!%     5 5 $ 6 6 $ : : < dkk++Z8 d4;;112J? dkk00$++2H2H2V2VW dkk**DKK,B,BC 33DKK4H4HIL# $r#cSSS[S5/URl[R"5nXR lURR5 UR5 URUR RUR RUR R5 URUR R[5 UR[!UR R5[5 UR#UR R5 UR#UR RR$5 URUR R&UR R5 UR)[*R,"UR R&5/SQ5 g)NrMrNrBr6)z File "", line 2 z x = ? z ^ zSyntaxError: invalid syntax )r7rr8rrzrrr1r9r{r|r]r`rbr\r^r_rarcrdr:r~rrs r test_sysexcepthook_syntax_error6TestInteractiveConsole.test_sysexcepthook_syntax_errorsB#-#.#%$,Z$8#: yy{!%     5 5 $ 6 6 $ : : < dkk++[9 d4;;112K@ $++445 $++00>>? dkk**DKK,B,BC 33DKK4H4HIL- .r#cS[S5/URl[R"5nXR lURR5 UR5 URUR RUR RUR R5 URUR R[5 UR[!UR R5[5 UR#UR R5 UR#UR RR$5 URUR R&UR R5 UR)[*R,"UR R&5/SQ5 g)Nrjr6)z File "", line 1 z 1 z$IndentationError: unexpected indent )r7rr8rrzrrr1r9r{r|r]r`rbr\rmr_rarcrdr:r~rrs r $test_sysexcepthook_indentation_error;TestInteractiveConsole.test_sysexcepthook_indentation_errors9#((:*>"? yy{!%     5 5 $ 6 6 $ : : < dkk++-=> d4;;1124DE $++445 $++00>>? dkk**DKK,B,BC 33DKK4H4HIL5 6r#cSSS[S5/URlSURlUR R 5 URSS0/URRS5 S RS URR55nURS U5 URURS 5S5 URS U5 URSU5 g)N1/0a = 123print(a)r6rDwrite123rrBc3T# UHoSS:XdM URSv M g7frrNargsrRs r rTWTestInteractiveConsole.test_sysexcepthook_crashing_doesnt_close_repl..'`1IRSWX_M_  ! 1I ((Error in sys.excepthook:z'int' object is not callableOriginal exception was:division by zeror7rr8rrr1r9r:rrFrGrassertIncount)rerrors r -test_sysexcepthook_crashing_doesnt_close_replDTestInteractiveConsole.test_sysexcepthook_crashing_doesnt_close_repls#()Z*AU"V !"   '9b14;;3K3KA3NO`1I1I`` 0%8 %CDaH /7 (%0r#c^SSS[S5/URlSmU4SjnXRlUR R 5 URSS0/URRS 5 S RS URR55nURS U5 URURS5S 5 URSU5 URSU5 g)Nrrrr6z not so fastc>[T5er.) BaseException)rkwargsss r raise_baseSTestInteractiveConsole.test_sysexcepthook_raising_BaseException..raise_bases" "r#rrrrBc3T# UHoSS:XdM URSv M g7frrrRs r rTRTestInteractiveConsole.test_sysexcepthook_raising_BaseException..rrrrDrrr)rrrrs @r (test_sysexcepthook_raising_BaseException?TestInteractiveConsole.test_sysexcepthook_raising_BaseExceptions#()Z*AU"V   #!+   '9b14;;3K3KA3NO`1I1I`` 0%8 ]3Q7 /7 (%0r#cS/URlSnXRlUR [ 5 UR R5 SSS5 g!,(df  g=f)Nrc[er.) SystemExit)rrs r r]TestInteractiveConsole.test_sysexcepthook_raising_SystemExit_gets_through..raise_bases r#)rr8rr assertRaisesrr1r9)rrs r 2test_sysexcepthook_raising_SystemExit_gets_throughITestInteractiveConsole.test_sysexcepthook_raising_SystemExit_gets_throughsI#('  !+    z * LL ! ! #+ * *s A A-c[S5URlURR SS9 UR [ URR5S5 URRSnUR USS0/5 URR5 [S5URlURR SS9 UR [ URR5S 5 g) Nr6Foobannerrr)zFoo rB r7rr8r1r9r:lenrrF reset_mock)r banner_calls r test_banner"TestInteractiveConsole.test_banners"*:"6  U+ T[[556:kk..q1  w B&?@  "*:"6  R( T[[556:r#c[S5URlURR SS9 UR [ URR5S5 URRSnSnUR USU40/5 URR5 [S5URlURR SSS9 UR [ URR5S5 URR5 S n[S5URlURR SUS9 UR [ URR5S5 URRSnUS -nUR USU40/5 g) Nr6rBrrrD"now exiting InteractiveConsole... r)rexitmsgu bye! ζжrsr)rerr_msgexpectedmessages r test_exit_msg$TestInteractiveConsole.test_exit_msgsk"*:"6  R( T[[556:++**1-8 7XK"<=  "*:"6  R4 T[[556:  K #+:"6  R9 T[[556:++**1-T> 7XK"<=r#cS[S5/URlURR 5 SR SUR R55n[S5nURX!5 URURR[5 UR[URR5[5 URURR URRR"5 UR%URR 5 URURR&URR5 g)Nz(raise ValueError('') from AttributeErrorr6rBc3J# UHnSRUS5v M g7frPrQrRs r rT7TestInteractiveConsole.test_cause_tb..rVrWz AttributeError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "", line 1, in ValueError )r7rr8r1r9rGrrFrrr\rr]r}r_r`rbrcassertIsNotNonerdrrfrs r test_cause_tb$TestInteractiveConsole.test_cause_tbs#M$,Z$8#:  Odkk6N6NOO   h' dkk++Z8 d4;;112J? dkk00$++2H2H2V2VW T[[778 dkk**DKK,B,BCr#cS[S5/URlURR 5 SR SUR R55n[S5nURX!5 URURR[5 UR[URR5[5 URURR URRR"5 UR%URR 5 URURR&URR5 g)Nztry: ham except: eggs r6rBc3J# UHnSRUS5v M g7frPrQrRs r rT9TestInteractiveConsole.test_context_tb..rVrWah Traceback (most recent call last): File "", line 1, in NameError: name 'ham' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 2, in NameError: name 'eggs' is not defined )r7rr8r1r9rGrrFrrr\rr] NameErrorr_r`rbrcrrdrs r test_context_tb&TestInteractiveConsole.test_context_tbs#=$,Z$8#:  Odkk6N6NOO    h' dkk++Y7 d4;;112I> dkk00$++2H2H2V2VW T[[778 dkk**DKK,B,BCr#r1)r$r%r&r'maxDiffr3r;r?rJrgrnrwrrrrrrrrrrr(r)r#r r+r+!saG776D(D D$...6& 1 1$ ;>8D*Dr#r+ct\rSrSrSr\R "\RRS5S5r Sr g)TestInteractiveConsoleLocalExiti,cT[RSS9UlUR5 g)NT) local_exitr/r2s r r3%TestInteractiveConsoleLocalExit.setUp.s ..$.?  r#z1exit() isn't defined unless there's a site modulecS/URlURRSS9 UR [ UR R5S5 UR RSnSnUR USU40/5 g)Nzexit()rBrrrDrr)rr8r1r9r:rrrF)rrrs r test_exit)TestInteractiveConsoleLocalExit.test_exit2sx$,*  R( T[[556:++**1-8 7XK"<=r#rN) r$r%r&r'r3unittestskipIfrflagsno_siterr(r)r#r rr,s2__SYY&&([\>]>r#r__main__)__doc__rr~rtextwrapr contextlibrr test.supportrr import_modulerr TestCaser+rr$mainr)r#r rsE  7&""6*& GDX..GD GDT>h&7&7>" z MMOr#