B t `$ @sndZddlZddlZddlZddlmZddlmZmZddl m Z ddl m Z e eZGdddeZdS) a_ 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) N)Plugin)exc_to_unicode force_unicode)ln)StringIOc@seZdZdZdZdZdZdZddZdd Z d d Z d d Z ddZ ddZ ddZddZddZddZddZddZddZeed d d!Zd S)"Capturea 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. TZNOSE_NOCAPTUREcapturei@cCsg|_d|_dS)N)stdout_buf)selfr 8/tmp/pip-unpacked-wheel-cjhnoqsi/nose/plugins/capture.py__init__#szCapture.__init__cCs$|jddd||j ddddS)z%Register commandline options z-sz --nocapture store_falserzUDon't capture stdout (any stdout output will be printed immediately) [NOSE_NOCAPTURE])actiondefaultdesthelpN) add_optiongetenv_opt)r parserenvr r r options'szCapture.optionscCs||_|jsd|_dS)z8Configure plugin. Plugin is enabled by default. FN)confrenabled)r rrr r r configure0szCapture.configurecCs|d|_dS)zClear capture buffer. N)endr )r testr r r afterTest7szCapture.afterTestcCs |dS)z0Replace sys.stdout with capture buffer. N)start)r r r r begin=sz Capture.begincCs |dS)zFlush capture buffer. N)r )r rr r r beforeTestBszCapture.beforeTestcCs6|j|_}d|_|s|S|\}}}|||||fS)z-Add captured output to error report. N)bufferZcapturedOutputr addCaptureToErr)r rerroutputZecevtbr r r formatErrorGs   zCapture.formatErrorcCs |||S)z/Add captured output to failure report. )r))r rr%r r r formatFailureTszCapture.formatFailurecCs*t|}t|}d|td|tdgS)N z>> begin captured stdout <> end captured stdout <<)rrjoinr)r r'r&r r r r$Ys zCapture.addCaptureToErrcCs"|jtjt|_|jt_dS)N)r appendsysrr )r r r r r _sz Capture.startcCs|jr|jt_dS)N)r popr.)r r r r rdsz Capture.endcCsx|jr|qWdS)zRestore stdout. N)r r)r resultr r r finalizehszCapture.finalizecCs|jdk r|jSdS)N)r getvalue)r r r r _get_bufferns zCapture._get_bufferNzCaptured stdout output.)__name__ __module__ __qualname____doc__rrnameZscorerrrrr!r"r)r*r$r rr1r3propertyr#r r r r rs(  r)r7loggingosr.Znose.plugins.baserZnose.pyversionrrZ nose.utilrior getLoggerr4logrr r r r  s