a
    7ñ»j~  ã                   @   s²   d dl Z d dl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„ Zdd„ Zdd„ Zdd„ Zejddd�dd„ ƒZdS )é    N)ÚPath)Úextras)Úextras_stash_key)ÚReport)Ú
ReportData)ÚSelfContainedReport)Ú_process_css)Ú_read_templatec                 C   s   ddl m} |  |¡ d S )Nr   )Úhooks)Úpytest_htmlr
   Zadd_hookspecs)Úpluginmanagerr
   © r   ú8E:\soccer\ml_env\Lib\site-packages\pytest_html/plugin.pyÚpytest_addhooks   s    r   c                 C   sŒ   |   d¡}|jddddd dd� |jdd	d
d� |jdddg dd� | jddddd� | jdddd� | jdddd� | jddddd� d S ) Nzterminal reportingz--htmlÚstoreÚhtmlpathÚpathz&create html report file at given path.)ÚactionÚdestÚmetavarÚdefaultÚhelpz--self-contained-htmlÚ
store_truezìcreate a self-contained html file containing all necessary styles, scripts, and images - this means that the report may not render or function where CSP restrictions are in place (see https://developer.mozilla.org/docs/Web/Security/CSP))r   r   z--cssÚappendz3append given css file content to report style file.)r   r   r   r   Zrender_collapsedÚstringZpassedz#row(s) to render collapsed on open.)Útyper   r   Zmax_asset_filename_lengthéÿ   zGset the maximum filename length for assets attached to the html report.)r   r   Zenvironment_table_redact_listZlinelistzna list of regexes corresponding to environment table variables whose values should be redacted from the report)r   r   Zinitial_sortÚresultzcolumn to initially sort on.)ZgetgroupZ	addoptionZaddini)ÚparserÚgroupr   r   r   Úpytest_addoption   sV    
úý	ûüýýür    c                 C   sô   |   d¡}|rðdd„ |   d¡D ƒ}g }|D ]}| ¡ s*| t|ƒ¡ q*|rxdt|ƒdkr\dnd› d	d
 |¡› �}t|ƒ‚t| dƒsðtt	ƒj
 d¡}t|dƒ}t|gƒ}t||ƒ}	t| ƒ}
|   d¡rÔt|| |
||	ƒ}nt|| |
||	ƒ}| j |¡ d S )Nr   c                 S   s    g | ]}t tj |¡ƒ ¡ ‘qS r   )r   Úosr   Ú
expandvarsÚ
expanduser)Ú.0Úcssr   r   r   Ú
<listcomp>P   s   ÿz$pytest_configure.<locals>.<listcomp>r%   zMissing CSS fileé   ÚsÚ z: z, ZworkerinputÚ	resourcesz	style.cssZself_contained_html)Z	getoptionÚexistsr   ÚstrÚlenÚjoinÚOSErrorÚhasattrr   Ú__file__ÚparentÚjoinpathr	   r   r   r   r   r   Úregister)ÚconfigZ	html_pathZ	extra_cssZmissing_css_filesZcss_pathZos_errorZresources_pathZdefault_cssÚtemplateZprocessed_cssZreport_dataÚhtmlr   r   r   Úpytest_configureM   s6    
þÿÿ





ÿr8   c                 C   s    | j  d¡}|r| j  |¡ d S )Nr7   )r   Z	getpluginÚ
unregister)r5   r7   r   r   r   Úpytest_unconfigureq   s    r:   T)ZtryfirstZhookwrapperc                 c   sb   d V }|  ¡ }|jdkr^t|dg ƒ}|r4t dt¡ | jj t	g ¡}t|dg ƒ}|| | |_
d S )NÚcallÚextrazpThe 'report.extra' attribute is deprecated and will be removed in a future release, use 'report.extras' instead.r   )Z
get_resultÚwhenÚgetattrÚwarningsÚwarnÚDeprecationWarningr5   ÚstashÚgetr   r   )Úitemr;   ÚoutcomeÚreportZdeprecated_extraZfixture_extrasZplugin_extrasr   r   r   Úpytest_runtest_makereportw   s    
ýrG   )r!   r?   Úpathlibr   Zpytestr   r   Zpytest_html.fixturesr   Zpytest_html.reportr   Zpytest_html.report_datar   Z pytest_html.selfcontained_reportr   Zpytest_html.utilr   r	   r   r    r8   r:   ZhookimplrG   r   r   r   r   Ú<module>   s    4$