Current File : //usr/lib/python2.7/site-packages/nose/plugins/capture.pyo
�
EF�Yc@s�dZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlmZej
e�Zdefd��YZdS(	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(texc_to_unicodet
force_unicode(tln(tStringIOtCapturecBs�eZdZeZdZdZdZd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zdd�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/usr/lib/python2.7/site-packages/nose/plugins/capture.pyt__init__$s	cCs9|jddddd|j|j�dddd	�d
S(s%Register commandline options
        s-ss--nocapturetactiontstore_falsetdefaulttdestRthelpsUDon't capture stdout (any stdout output will be printed immediately) [NOSE_NOCAPTURE]N(t
add_optiontgettenv_opt(Rtparsertenv((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pytoptions(scCs"||_|jst|_ndS(s8Configure plugin. Plugin is enabled by default.
        N(tconfRtFalsetenabled(RRR((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pyt	configure1s		cCs|j�d|_dS(sClear capture buffer.
        N(tendR	R
(Rttest((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pyt	afterTest8s
cCs|j�dS(s0Replace sys.stdout with capture buffer.
        N(tstart(R((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pytbegin>scCs|j�dS(sFlush capture buffer.
        N(R(RR((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pyt
beforeTestCscCs�d|_}d}y|j|_}Wntk
rFtj�}nXd|_|rb|rb|S|\}}}||j||d|�|fS(s-Add captured output to error report.
        ttoutput_exc_infoN(tcapturedOutputR	tbuffertUnicodeErrortsystexc_infoR
taddCaptureToErr(RRterrtoutputR#tectevttb((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pytformatErrorHs

	cCs|j||�S(s/Add captured output to failure report.
        (R/(RRR*((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pyt
formatFailurehscCs�t|�}t|�}|td�|td�g}|ry|jddtd�djtj|��td�g�ndj|�S(	Nu>> begin captured stdout <<u>> end captured stdout <<u,OUTPUT ERROR: Could not get captured output.uSThe test might've printed both 'unicode' strings and non-ASCII 8-bit 'str' strings.u/>> begin captured stdout exception traceback <<uu->> end captured stdout exception traceback <<u
(RRRtextendtjoint	tracebacktformat_exception(RR-R+R#t
error_text((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pyR)ms		cCs/|jjtj�t�|_|jt_dS(N(RtappendR'RR
(R((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pyR~scCs"|jr|jj�t_ndS(N(RtpopR'(R((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pyR�s	cCsx|jr|j�qWdS(sRestore stdout.
        N(RR(Rtresult((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pytfinalize�scCs |jdk	r|jj�SdS(N(R
R	tgetvalue(R((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pyt_get_buffer�ssCaptured stdout output.N(t__name__t
__module__t__doc__tTrueRRtnametscoreRRRRR R!R/R0R	R)RRR9R;tpropertyR%(((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pyRs(								 					(R>tloggingtosR'R3tnose.plugins.baseRtnose.pyversionRRt	nose.utilRRt	getLoggerR<tlogR(((s8/usr/lib/python2.7/site-packages/nose/plugins/capture.pyt<module>s