ó J9•Qc@sƒdZddlZddlZddlZddlmZddlmZddlmZej e ƒZ defd„ƒYZ dS(s_ This plugin captures stdout during test execution. If the test fails or raises an error, the captured output will be appended to the error or failure output. It is enabled by default but can be disabled with the options ``-s`` or ``--nocapture``. :Options: ``--nocapture`` Don't capture stdout (any stdout output will be printed immediately) i˙˙˙˙N(tPlugin(tln(tStringIOtCapturecBs°eZdZeZdZdZdZd„Zd„Z d„Z d„Z d„Z d „Z d „Zd „Zd „Zd „Zd„Zd„Zd„ZeedddƒZRS(s Output capture plugin. Enabled by default. Disable with ``-s`` or ``--nocapture``. This plugin captures stdout during test execution, appending any output captured to the error or failure output, should the test fail or raise an error. tNOSE_NOCAPTUREtcapturei@cCsg|_d|_dS(N(tstdouttNonet_buf(tself((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyt__init__"s c Cs9|jddddd|j|jƒ dddd ƒd S( s%Register commandline options s-ss --nocapturetactiont store_falsetdefaulttdestRthelpsUDon't capture stdout (any stdout output will be printed immediately) [NOSE_NOCAPTURE]N(t add_optiontgettenv_opt(R tparsertenv((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pytoptions&scCs"||_|jst|_ndS(s8Configure plugin. Plugin is enabled by default. N(tconfRtFalsetenabled(R RR((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyt configure/s  cCs|jƒd|_dS(sClear capture buffer. N(tendRR(R ttest((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyt afterTest6s cCs|jƒdS(s0Replace sys.stdout with capture buffer. N(tstart(R ((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pytbegin<scCs|jƒdS(sFlush capture buffer. N(R(R R((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyt beforeTestAscCsK|j|_}d|_|s#|S|\}}}||j||ƒ|fS(s-Add captured output to error report. N(tbuffertcapturedOutputRRtaddCaptureToErr(R Rterrtoutputtectevttb((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyt formatErrorFs  cCs|j||ƒS(s/Add captured output to failure report. (R((R RR#((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyt formatFailureSsc Cst|tƒrˇt|dƒr-t|ƒ}qŐt|dƒsat|jƒrX|jdp[d}n |j}t|tƒržt|tƒ rž|jddƒ}nd|j j |f}nt|tƒsŐt |ƒ}nt|tƒsů|jddƒ}ndj |t d ƒ|t d ƒgƒS( Nt __unicode__tmessageittutf8treplaceu%s: %su u>> begin captured stdout <> end captured stdout <<(t isinstancet BaseExceptionthasattrtunicodetlentargsR+t basestringtdecodet __class__t__name__treprtjoinR(R R&R$tmsg((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyR"Xs % cCs/|jjtjƒtƒ|_|jt_dS(N(RtappendtsysRR(R ((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyRos cCs"|jr|jjƒt_ndS(N(RtpopR=(R ((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyRts cCsx|jr|jƒqWdS(sRestore stdout. N(RR(R tresult((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pytfinalizexs cCs |jdk r|jjƒSdS(N(RRtgetvalue(R ((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyt _get_buffer~ssCaptured stdout output.N(R8t __module__t__doc__tTrueRRtnametscoreR RRRRRR(R)R"RRR@RBtpropertyRR (((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyRs(            ( RDtloggingtosR=tnose.plugins.baseRt nose.utilRRt getLoggerR8tlogR(((s8/sys/lib/python2.7/site-packages/nose/plugins/capture.pyt s