B
    ܇\                 @   sd   d Z ddlmZ ddlmZ ddlmZ ddlZddlZdd Zdd	 Zd
d Z	G dd de
ZdS )zM log machine-parseable test session result information in a plain
text file.
    )absolute_import)division)print_functionNc             C   s&   |  dd}|jddddd dd d S )	Nzterminal reportingzresultlog plugin optionsz--resultlogz--result-logZstorepathz0DEPRECATED path for machine-readable result log.)actionmetavardefaulthelp)ZgetgroupZ	addoption)parsergroup r   0lib/python3.7/site-packages/_pytest/resultlog.pypytest_addoption   s    r   c             C   s   | j j}|rt| dstjtj|}tj|s@t| t	|dd}t
| || _| j| j ddlm} ddlm} ||| jdd d S )	NZ
slaveinputw   r   )
RESULT_LOG)_issue_warning_captured   )
stacklevel)Zoption	resultloghasattrosr   dirnameabspathisdirmakedirsopen	ResultLog
_resultlogpluginmanagerregisterZ_pytest.deprecatedr   Z_pytest.warningsr   hook)configr   r   logfiler   r   r   r   r   pytest_configure   s    
r$   c             C   s.   t | dd }|r*|j  | `| j| d S )Nr   )getattrr#   closer   r   Z
unregister)r"   r   r   r   r   pytest_unconfigure*   s
    
r'   c               @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )r   c             C   s   || _ || _d S )N)r"   r#   )selfr"   r#   r   r   r   __init__3   s    zResultLog.__init__c             C   s>   t d||f | jd x"| D ]}t d| | jd q W d S )Nz%s %s)filez %s)printr#   
splitlines)r(   testpath
lettercodelongreprliner   r   r   write_log_entry7   s    zResultLog.write_log_entryc             C   s,   t |dd }|d kr|j}| ||| d S )NZnodeid)r%   fspathr1   )r(   reportr.   r/   r-   r   r   r   log_outcome<   s    zResultLog.log_outcomec             C   s   |j dkr|jrd S | jjj|| jd}|d }|dkrDt|j}n@|dkrRd}n2|jr^d}n&|jrpt|j}n|jrt|jd }| 	||| d S )NZcall)r3   r"   r   xX r   )
Zwhenpassedr"   r!   Zpytest_report_teststatusstrr/   failedskippedr4   )r(   r3   Zrescoder/   r   r   r   pytest_runtest_logreportB   s     z"ResultLog.pytest_runtest_logreportc             C   sF   |j sB|jrd}t|j}n|js&td}d|j }| ||| d S )NFSz	%s:%d: %s)r8   r:   r9   r/   r;   AssertionErrorr4   )r(   r3   r<   r/   r   r   r   pytest_collectreportU   s    

zResultLog.pytest_collectreportc             C   sD   t |dd }t |dd }|d kr.dtj  }| |dt| d S )N	reprcrashr   zcwd:%s!)r%   pyr   Zlocalr1   r9   )r(   ZexcreprrB   r   r   r   r   pytest_internalerror`   s
    zResultLog.pytest_internalerrorN)	__name__
__module____qualname__r)   r1   r4   r=   rA   rE   r   r   r   r   r   2   s   r   )__doc__Z
__future__r   r   r   r   rD   r   r$   r'   objectr   r   r   r   r   <module>   s   