U
    \	a                     @   sl   d dl Z d dlZd dlZd dlmZ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)_apicbookc                 C   s:   dD ]\}}|  || qtjddd dt_t  d S )N))markersz*flaky: (Provided by pytest-rerunfailures.))r   z&timeout: (Provided by pytest-timeout.))r   z6backend: Set alternate Matplotlib backend temporarily.)r   z2style: Set alternate Matplotlib style temporarily.)r   z3baseline_images: Compare output against references.)r   z.pytz: Tests that require pytz to be installed.)r   z-network: Tests that reach out to the network.)filterwarningserrorZaggT)force)Zaddinivalue_line
matplotlibuse_called_from_pytestZ_init_tests)configkeyvalue r   ?/tmp/pip-unpacked-wheel-wjyw_3jo/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                 c   sr  ddl m} | T d }| jd}|d k	rft|jdksFtd|j\}|jdd}t	
 }| drtd	d
 dD rtd zdd l}W nD ttfk
r   zdd l}W n tk
r   td Y nX Y nX n| drftdd
 dD rtd zdd l}W nH ttfk
rd   zdd l}	W n  tk
r^   td Y nX Y nX ddg}
| jd}|d k	rt|jdkstd|j\}
t	j  t  |d k	r,dd lm} z|| W nN tk
r* } z.d| ks|rtd|| n W 5 d }~X Y nX t	j|
 W 5 Q R X z
d V  W 5 |d k	rb|| X W 5 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 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 {} ({}).) 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!   sv    

 





 

r6   c              	   c   sR   | j dj\}|d kr"| d}| j}tj|j||fd d V  W 5 Q R X d S )Nbaseline_images)
parameters)r#   r$   r&   Zgetfixturevaluefunctionr   Z_setattr_cm__wrapped__)r4   	extensionr7   funcr   r   r   mpl_image_comparison_parametersi   s    

r=   c                  C   s:   t d} z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)r.   ZimportorskipZpandas.plottingr>   r0   )pdZ
deregisterr   r   r   r?      s    

r?   )r.   r   r   r   r   r   r   Zfixturer6   r=   r?   r   r   r   r   <module>   s   

G
