U e$ @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|_dSN)stdout_bufselfrB/opt/hc_python/lib/python3.8/site-packages/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 parserenvrrroptions's zCapture.optionscCs||_|jsd|_dS)z8Configure plugin. Plugin is enabled by default. FN)confrenabled)r rrrrr configure0szCapture.configurecCs|d|_dS)zClear capture buffer. N)endr r testrrr afterTest7szCapture.afterTestcCs |dS)z0Replace sys.stdout with capture buffer. Nstartr rrrbegin=sz Capture.begincCs |dS)zFlush capture buffer. Nr#r rrr beforeTestBszCapture.beforeTestcCs6|j|_}d|_|s|S|\}}}|||||fS)z-Add captured output to error report. N)bufferZcapturedOutputr addCaptureToErr)r r!erroutputecevtbrrr formatErrorGs   zCapture.formatErrorcCs |||S)z/Add captured output to failure report. )r.)r r!r)rrr formatFailureTszCapture.formatFailurecCs*t|}t|}d|td|tdgS)N z>> begin captured stdout <> end captured stdout <<)rrjoinr)r r,r*rrrr(Ys  zCapture.addCaptureToErrcCs"|jtjt|_|jt_dSr )r appendsysrr r rrrr$_sz Capture.startcCs|jr|jt_dSr )r popr3r rrrrdsz Capture.endcCs|jr|qdS)zRestore stdout. N)r r)r resultrrrfinalizehszCapture.finalizecCs|jdk r|jSdSr )r getvaluer rrr _get_bufferns zCapture._get_bufferNzCaptured stdout output.)__name__ __module__ __qualname____doc__rrnameZscorerrrr"r%r&r.r/r(r$rr6r8propertyr'rrrrrs*  r)r<loggingosr3Znose.plugins.baserZnose.pyversionrrZ nose.utilrior getLoggerr9logrrrrrs