3
ƽh                 @   sh   d dl Z d dlZd dlZd dlmZ dd Zdd Ze jddd	d
 Ze jdd Ze jdd Z	dS )    N)cbookc          	   C   s>   xdD ]\}}| j || qW tjddd dt_tj  d S )Nmarkers*flaky: (Provided by pytest-rerunfailures.)&timeout: (Provided by pytest-timeout.)6backend: Set alternate Matplotlib backend temporarily.2style: Set alternate Matplotlib style temporarily.3baseline_images: Compare output against references..pytz: Tests that require pytz to be installed.-network: Tests that reach out to the network.filterwarningserrorZaggT)forcer   r   r   r   r   r   r   r   r   r   r   r	   r   r
   r   r   )r   r   r   r   r   r   r   r   )Zaddinivalue_line
matplotlibuse_called_from_pytestZ_init_tests)configkeyvalue r   A/tmp/pip-build-7iwl8md4/matplotlib/matplotlib/testing/conftest.pypytest_configure   s           r   c             C   s
   dt _d S )NF)r   r   )r   r   r   r   pytest_unconfigure   s    r   T)Zautousec          5   c   sp  ddl m} | R d }| jjd}|d k	rft|jdksFtd|j\}|jjdd}t	j
 }|j jdrtd	d
 dD rtjd ydd l}W nD ttfk
r   ydd l}W n tk
r   tjd Y nX Y nX n|j jdrftdd
 dD rtjd ydd l}W nH ttfk
rd   ydd l}	W n  tk
r^   tjd Y nX Y nX ddg}
| jjd}|d k	rt|jdkstd|j\}
t	jj  tj  |d k	r*dd lj}y|j| W nN tk
r( } z0d|j ks|rtjdj|| n W Y d d }~X nX t	jj|
 W d Q R X z
d V  W d |d k	r`|j| X W d Q R X d S )Nr   )_cleanup_cmbackend   z(Marker 'backend' must specify 1 backend.skip_on_importerrorFZqt4c             s   s   | ]}|t jkV  qd S )N)sysmodules).0kr   r   r   	<genexpr>3   s    z$mpl_test_settings.<locals>.<genexpr>PyQt5PySide2zQt5 binding already importedzFailed to import a Qt4 binding.Zqt5c             s   s   | ]}|t jkV  qd S )N)r$   r%   )r&   r'   r   r   r   r(   >   s    PyQt4PySidezQt4 binding already importedzFailed to import a Qt5 binding.ZclassicZ_classic_test_patchstylez$Marker 'style' must specify 1 style.Zcairoz$Failed to switch to backend {} ({}).)r)   r*   )r+   r,   ) Zmatplotlib.testing.decoratorsr    nodeget_closest_markerlenargsAssertionErrorkwargsgetr   get_backendlower
startswithanypytestskipr+   ImportErrorRuntimeErrorr,   r)   r*   Ztestingsetupr   Z(_suppress_matplotlib_deprecation_warningZmatplotlib.pyplotZpyplotZswitch_backendformatr-   r   )requestr    r!   Zbackend_markerr#   Zprev_backendr+   r,   r)   r*   r-   Zstyle_markerZpltexcr   r   r   mpl_test_settings!   sj    










rA   c          	   c   sR   | j jdj\}|d kr"| jd}| j}tj|j||fd d V  W d Q R X d S )Nbaseline_images)
parameters)r.   r/   r1   Zgetfixturevaluefunctionr   Z_setattr_cm__wrapped__)r?   	extensionrB   funcr   r   r   mpl_image_comparison_parametersi   s    

rH   c              C   s:   t jd} yddlm} |  W n tk
r4   Y nX | S )z'Fixture to import and configure pandas.Zpandasr   ) deregister_matplotlib_converters)r9   ZimportorskipZpandas.plottingrI   r;   )pdZ
deregisterr   r   r   rJ      s    

rJ   )
r9   r$   r   r   r   r   ZfixturerA   rH   rJ   r   r   r   r   <module>   s   H