U
    +ifS                     @   s   d dl Z d dlZd dlZd dlZd dlm  mZ d dlZe	dZ
ee
ddd  ejjZejdd Zdd	 Zd
d Zdd Zejdd Zdd Zejdd Zdd ZdS )    Npandas_dummy_backendplotc                  O   s   dS )N
used_dummy argskwargsr   r   U/home/mars/bis/venv/lib/python3.8/site-packages/pandas/tests/plotting/test_backend.py<lambda>       r
   c                   c   s"   t dd dV  t dd dS )z*Restore the plotting backend to matplotlibplotting.backend
matplotlibN)pandas
set_optionr   r   r   r	   restore_backend   s    r   c               	   C   s@   d} t jt| d tdd W 5 Q R X tjjjdks<td S )Nz9Could not find plotting backend 'not_an_existing_module'.matchr   Znot_an_existing_moduler   )	pytestraises
ValueErrorr   r   optionsplottingbackendAssertionErrormsgr   r   r	   test_backend_is_not_module   s    r   c                 C   sH   |  tjdt tdd tddks.ttjj	
dtksDtd S )Nr   r   )setitemsysmodulesdummy_backendr   r   
get_optionr   r   _core_get_plot_backend)monkeypatchr   r   r   r	   test_backend_is_correct"   s
    r%   c                 C   sJ   |  tjdt tdddg}tddks2t|jdddksFtd S )	Nr            r   r   )r   r   )	r   r   r   r    r   	DataFramer!   r   r   r$   r   Zdfr   r   r	   $test_backend_can_be_set_in_plot_call,   s    r+   c              	   C   s   t d}|jtjkr td td}dd |_	t 
d}t jd|j|d}||d d< |tjd< tjjd}||ksttd	d tjj }W 5 Q R X ||kstd S )
Nr   zTesting a non-installed pandasZ
my_backendc                  _   s   dS )Nr&   r   r   r   r   r	   r
   =   r   z*test_register_entrypoint.<locals>.<lambda>Zpandas_plotting_backend)distZpandas_plotting_backendsr   )pkg_resourcesget_distributionmodule_pathr   __file__r   skiptypes
ModuleTyper   get_entry_map
EntryPoint__name__r   r   r   r"   r#   r   Zoption_context)r   r,   modbackendsZmy_entrypointresultr   r   r	   test_register_entrypoint4   s$    




  
r:   c               	   C   sb   t d} | tjd< tjjjdks&tt	j
tdd tdd W 5 Q R X tjjjdks^td S )NZpandas_plot_backendr   z6Could not find plotting backend 'pandas_plot_backend'.r   r   )r2   r3   r   r   r   r   r   r   r   r   r   r   r   )moduler   r   r	   (test_setting_backend_without_plot_raisesR   s    

 r<   c               	   C   s0   d} t jt| d tjjd W 5 Q R X d S )NzVmatplotlib is required for plotting when the default backend "matplotlib" is selected.r   r   )r   r   ImportErrorr   r   r"   r#   r   r   r   r	   test_no_matplotlib_ok`   s    r>   c                 C   s@   |  tjdt tdd tddddgi}|jdd d S )	Nr   r   Ar&   r'   r(   znot a real kind)kind)r   r   r   r    r   r   r)   r   r*   r   r   r	   test_extra_kinds_okj   s    rA   )r   r2   r-   r   Zpandas.util._test_decoratorsutilZ_test_decoratorstdr   r3   r    setattrmarkZslowZ
pytestmarkZfixturer   r   r%   r+   Zskip_if_no_mplr:   r<   Zskip_if_mplr>   rA   r   r   r   r	   <module>   s&   




	