
    [j                       d Z ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 ddlm
Z
 ddlmZ dd	lmZ dd
lmZ ddlmZ ddlZ eee                              ZddZ ej        d          dd            ZddZd dZd!dZdS )"zASubmit failure or test session information to a pastebin service.    )annotations)StringION)IO)Config)create_terminal_writer)Parser)PASTEBIN)StashKey)TerminalReporterparserr   returnNonec           	     l    |                      d          }|                    ddddd ddgd	           d S )
Nzterminal reportingz
--pastebinmodestorepastebinfailedallz3Send failed|all info to bpaste.net pastebin service)metavaractiondestdefaultchoiceshelp)getgroup	addoption)r   groups     T/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/_pytest/pastebin.pypytest_addoptionr      sS    OO011E	OO5!B          T)trylastconfigr   c                6     j         j        r                     t          d            j         j        dk    r] j                            d          }|Ct          j        d           j        t          <   |j
        j         fd}||j
        _        d S d S d S )N   r   terminalreporterzw+bc                     | fi | t          | t                    r|                     d          } j        t                                       |            d S )Nutf-8)
isinstancestrencodestashpastebinfile_keywrite)skwargsr"   oldwrites     r   	tee_writez#pytest_configure.<locals>.tee_write2   s`    %%f%%%a%% *))A-.44Q77777r    )optionr   issue_config_time_warningr	   pluginmanager	getplugintempfileTemporaryFiler+   r,   _twr-   )r"   trr1   r0   s   `  @r   pytest_configurer:   #   s    } 6((1555}&&!++,>?? >-5-CE-J-JFL)*v|H8 8 8 8 8 8 %BFLLL! '&
 >r    c                   t           | j        v r| j        t                    }|                    d           |                                }|                                 | j        t           = | j                            d          }|j        j        d= |	                    dd           t          |          }|                    d| d           d S d S )Nr   r%   r-   =$Sending information to Paste Servicezpastebin session-log: 
)r,   r+   seekreadcloser4   r5   r8   __dict__	write_sepcreate_new_paste
write_line)r"   pastebinfile
sessionlogr9   pastebinurls        r   pytest_unconfigurerI   ;   s    6<''|$45!!&&((
L)*!++,>??FOG$
S@AAA&z22
>{>>>????? ('r    contentsstr | bytesr)   c                   ddl }ddlm} ddlm} ddlm} | ddd}d	}	  || ||                              d
                                                    	                    d          }nM# |$ r.}|5  d| cddd           cY d}~S # 1 swxY w Y   Y d}~nd}~wt          $ r}d| cY d}~S d}~ww xY w|                    d|          }	|	r| d|	                    d           S d|z   dz   S )zCreate a new paste using the bpaste.net service.

    :contents: Paste contents string.
    :returns: URL to the pasted contents, or an error message.
    r   N)	HTTPError)	urlencode)urlopentext1week)codelexerexpiryzhttps://bpa.stascii)datar'   zbad response: zhref="/raw/(\w+)"z/show/   zbad response: invalid format ('z'))reurllib.errorrM   urllib.parserN   urllib.requestrO   r*   r@   decodeOSErrorsearchr   )
rJ   rX   rM   rN   rO   paramsurlresponseems
             r   rD   rD   L   s    III&&&&&&&&&&&&&&&&&&7CCF
C$GCii//66w??@@@EEGGNNwWW 	  ( ( ( 	( 	('A''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( $ $ $#########$
		&11A C))QWWQZZ)))08;dBBsT   AA/ /B94B6B;BB9B	BB	BB9*B4.B94B9r%   r   c                (   | j         j        j        dk    rd S d| j        v r|                     dd           | j        d         D ]}	 |j        j        j        d         j        }n%# t          $ r | 
                    |          }Y nw xY wt                      }t          | j         |          }|                    |           |                                }t          |          sJ t!          |          }|                     | d|            d S d S )Nr   r<   r=   z --> )r"   r2   r   statsrC   longreprreprtracebackreprentriesreprfilelocAttributeError_getfailureheadliner   r   
toterminalgetvaluelenrD   rE   )r%   repmsgfiletwr.   rH   s          r   pytest_terminal_summaryrt   i   s=   %.(::#)))""3(NOOO#)(3 	D 	DC@l0<R@L! @ @ @&::3??@::D'(8(?FFBNN2Aq66MMM*1--K''3(B(B[(B(BCCCC *)	D 	Ds   A$$BB)r   r   r   r   )r"   r   r   r   )rJ   rK   r   r)   )r%   r   r   r   )__doc__
__future__r   ior   r6   typingr   _pytest.configr   r   _pytest.config.argparsingr   _pytest.deprecatedr	   _pytest.stashr
   _pytest.terminalr   pytestbytesr,   r   hookimplr:   rI   rD   rt    r    r   <module>r      sp   G G " " " " " "              ! ! ! ! ! ! 1 1 1 1 1 1 , , , , , , ' ' ' ' ' ' " " " " " " - - - - - -  '8BuI&(( 
 
 
 
 % % % %.@ @ @ @"C C C C:D D D D D Dr    