o
    g$                     @   sn   d Z ddlZddlZddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZ eeZG dd deZdS )	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                   @   s   e Zd ZdZdZdZdZdZdd Zdd	 Z	d
d Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zeed d d!Zd 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.
    TNOSE_NOCAPTUREcapturei@  c                 C   s   g | _ d | _d S N)stdout_bufself r   R/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/nose/plugins/capture.py__init__#   s   
zCapture.__init__c                 C   s$   |j ddd|| j ddd dS )z%Register commandline options
        z-sz--nocapturestore_falser	   zUDon't capture stdout (any stdout output will be printed immediately) [NOSE_NOCAPTURE])actiondefaultdesthelpN)
add_optiongetenv_opt)r   parserenvr   r   r   options'   s
   
zCapture.optionsc                 C   s   || _ |jsd| _dS dS )z8Configure plugin. Plugin is enabled by default.
        FN)confr	   enabled)r   r   r   r   r   r   	configure0   s   
zCapture.configurec                 C   s   |    d| _dS )zClear capture buffer.
        N)endr   r   testr   r   r   	afterTest7   s   
zCapture.afterTestc                 C      |    dS )z0Replace sys.stdout with capture buffer.
        Nstartr   r   r   r   begin=      zCapture.beginc                 C   r$   )zFlush capture buffer.
        Nr%   r!   r   r   r   
beforeTestB   r(   zCapture.beforeTestc                 C   s6   | j  |_}d| _|s|S |\}}}|| |||fS )z-Add captured output to error report.
        N)buffercapturedOutputr   addCaptureToErr)r   r"   erroutputecevtbr   r   r   formatErrorG   s   
zCapture.formatErrorc                 C   s   |  ||S )z/Add captured output to failure report.
        )r2   )r   r"   r-   r   r   r   formatFailureT   r(   zCapture.formatFailurec                 C   s*   t |}t|}d|td|tdgS )N
z>> begin captured stdout <<z>> end captured stdout <<)r   r   joinr   )r   r0   r.   r   r   r   r,   Y   s
   zCapture.addCaptureToErrc                 C   s"   | j tj  t | _| jt_ d S r
   )r   appendsysr   r   r   r   r   r   r&   _   s   zCapture.startc                 C   s   | j r| j  t_ d S d S r
   )r   popr7   r   r   r   r   r    d   s   zCapture.endc                 C   s   | j r|   | j sdS dS )zRestore stdout.
        N)r   r    )r   resultr   r   r   finalizeh   s   zCapture.finalizec                 C   s   | j d ur
| j  S d S r
   )r   getvaluer   r   r   r   _get_buffern   s   

zCapture._get_bufferNzCaptured stdout output.)__name__
__module____qualname____doc__r   r   namescorer   r   r   r#   r'   r)   r2   r3   r,   r&   r    r:   r<   propertyr*   r   r   r   r   r      s,    	r   )r@   loggingosr7   nose.plugins.baser   nose.pyversionr   r   	nose.utilr   ior   	getLoggerr=   logr   r   r   r   r   <module>   s    
