U
    ÂmœdE  ã                   @   s(  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l	Z	d dl
Zd dl
mZmZ d dlmZmZ dZdZeeiZed3d	d
„ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Z e	j!j"d!d"d#gd$d%gd&�d'd(„ ƒZ#d)d*„ Z$d+d,„ Z%d-d.„ Z&d/d0„ Z'd1d2„ Z(dS )4é    )Úcontextmanager)ÚPath)ÚTemporaryDirectoryN)ÚpyplotÚstyle)ÚUSER_LIBRARY_PATHSÚSTYLE_EXTENSIONz
image.cmapZpinkc              	   c   sz   |st }d| tf }zVtƒ �F}t||ƒjd dd„ | ¡ D ƒ¡dd� t	 
|¡ t ¡  dV  W 5 Q R X W 5 t ¡  X dS )zAContext manager to create a style sheet in a temporary directory.z%s.%sÚ
c                 s   s   | ]\}}d   ||¡V  qdS )z{}: {}N)Úformat)Ú.0ÚkÚv© r   úT/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/matplotlib/tests/test_style.pyÚ	<genexpr>   s     ztemp_style.<locals>.<genexpr>úutf-8©ÚencodingN)ÚDUMMY_SETTINGSr   r   Zreload_libraryr   r   Ú
write_textÚjoinÚitemsr   Úappend)Ú
style_nameÚsettingsÚ	temp_fileÚtmpdirr   r   r   Ú
temp_style   s    
þ
r   c              	   C   sJ   ddi}d}t ||ƒ� W 5 Q R X t| jƒdkrB|| jd  ¡ ksFt‚d S )NZfooÚbarÚbasenameé   r   )r   ÚlenÚrecordsÚ
getMessageÚAssertionError)ZcaplogZSETTINGSr   r   r   r   Ú)test_invalid_rc_warning_includes_filename'   s    
ÿr%   c                	   C   s(   t dtƒ� dtjkst‚W 5 Q R X d S )NZ_test_)r   r   r   Ú	availabler$   r   r   r   r   Útest_available1   s    r'   c                
   C   sL   dt jt< tdtƒ�. t d¡� t jt tks4t‚W 5 Q R X W 5 Q R X d S ©NÚgrayÚtest©	ÚmplÚrcParamsÚPARAMr   r   r   ÚcontextÚVALUEr$   r   r   r   r   Útest_use6   s    
r1   c              
   C   s|   t | dƒ}|jddd� tdtƒ�P dtjdkr4dnd	 | ¡  ¡  }t 	|¡� t
jd
 dksdt‚W 5 Q R X W 5 Q R X d S )NÚfilezaxes.facecolor: adeader   r   r*   zfile:Úwin32z///Ú zaxes.facecolorz#adeade)r   r   r   r   ÚsysÚplatformÚresolveÚas_posixr   r/   r,   r-   r$   )r   ÚpathÚurlr   r   r   Útest_use_url=   s    
ÿ
þr;   c              	   C   st   dt jt< dt› �}t| |ƒ}|jt› dt› �dd� t |¡� t jt tksTt	‚W 5 Q R X t jt dkspt	‚d S )Nr)   ztext.z : r   r   )
r,   r-   r.   r   r   r   r0   r   r/   r$   )r   r   r9   r   r   r   Útest_single_pathH   s    


r<   c                
   C   s^   dt jt< tdtƒ�. t d¡� t jt tks4t‚W 5 Q R X W 5 Q R X t jt dksZt‚d S r(   r+   r   r   r   r   Útest_contextR   s
    
&r=   c               	   C   sT   d} d}| t jt< t t|i¡� t jt |ks4t‚W 5 Q R X t jt | ksPt‚d S )Nr)   Úblue)r,   r-   r.   r   r/   r$   ©Úoriginal_valueÚother_valuer   r   r   Útest_context_with_dict[   s    
rB   c               
   C   sn   d} d}| t jt< tdtƒ�6 t dt|ig¡� t jt |ksDt‚W 5 Q R X W 5 Q R X t jt | ksjt‚d S ©Nr)   r>   r*   )r,   r-   r.   r   r   r   r/   r$   r?   r   r   r   Ú'test_context_with_dict_after_namedstyled   s    
&rD   c               
   C   sn   d} d}| t jt< tdtƒ�6 t t|idg¡� t jt tksDt‚W 5 Q R X W 5 Q R X t jt | ksjt‚d S rC   r+   r?   r   r   r   Ú(test_context_with_dict_before_namedstyleo   s    
&rE   c               
   C   s¨   d} d}d}||i}| t jt< | t j|< tdtƒ�D t d|g¡�* t jt tksXt‚t j| |ksjt‚W 5 Q R X W 5 Q R X t jt | ks�t‚t j| | ks¤t‚d S )Nr)   ztext.usetexTr*   r+   )r@   Zother_paramrA   Údr   r   r   Ú.test_context_with_union_of_dict_and_namedstylez   s    
&rG   c                  C   s‚   d} d}t  t|i¡�b tjt |ks*t‚t  t| dd i¡}t t¡� |� W 5 Q R X W 5 Q R X tjt |kstt‚W 5 Q R X d S )Nr)   r>   Zbadparam)	r   r/   r.   r,   r-   r$   ÚpytestZraisesÚKeyError)r@   rA   Úxr   r   r   Útest_context_with_badparamŠ   s    rK   Úequiv_styles)Úmpl20Údefault)Úmpl15ZclassicrM   rO   )Zidsc              
   C   sp   g }| D ]*}t  |¡� | tj ¡ ¡ W 5 Q R X q|d }t| dd … |dd … ƒD ]\}}||ksVt‚qVd S )Nr   r    )r   r/   r   r,   r-   ÚcopyÚzipr$   )rL   Zrc_dictsZstyZrc_baseÚnmÚrcr   r   r   Ú
test_alias–   s    "rT   c                   C   sL   t jd d kst‚t ¡  t jd dks,t‚tj ¡  t jd dksHt‚d S ©Nzpath.sketch)r    éd   é   )r,   r-   r$   ÚpltÚxkcdÚnpÚtestingZbreak_cyclesr   r   r   r   Útest_xkcd_no_cm¥   s
    
r\   c                	   C   sN   t jd d kst‚t ¡ � t jd dks.t‚W 5 Q R X t jd d ksJt‚d S rU   )r,   r-   r$   rX   rY   r   r   r   r   Útest_xkcd_cm­   s    
r]   c               	   C   sŽ   t j d¡� t j ¡ } W 5 Q R X t j| ks0t‚t t jj	¡� t j 
d¡ W 5 Q R X t j| ksdt‚t t jj	¡� t jjd  W 5 Q R X d S )Nzseaborn-v0_8-brightzseaborn-bright)r,   r   r/   r-   rP   r$   rH   ZwarnsZ_apiZMatplotlibDeprecationWarningÚuseZlibrary)Zseaborn_brightr   r   r   Útest_deprecated_seaborn_styles´   s    r_   c                   C   s   t jjjt jj™kst‚d S )N)r,   r   ÚcoreZSTYLE_BLACKLISTZrcsetupZ_validatorsr$   r   r   r   r   Útest_up_to_date_blacklist¿   s    ra   c                 C   s¨   |  | ¡ | | ¡ | d }| ¡  |d jddd� | d¡jddd� tj d¡ tjd	 d
ksht	‚tj d¡ tjd	 dks†t	‚tj d¡ tjd	 dks¤t	‚d S )NZmpl_test_style_pkgztest_style.mplstylezlines.linewidth: 42r   r   z	.mplstylezlines.linewidth: 84zmpl_test_style_pkg.test_stylezlines.linewidthé*   zmpl_test_style_pkg.mplstyleéT   z./mpl_test_style_pkg.mplstyle)
Zsyspath_prependÚchdirÚmkdirr   Úwith_suffixr,   r   r^   r-   r$   )Ztmp_pathZmonkeypatchZpkg_pathr   r   r   Útest_style_from_moduleÃ   s$    

 ÿ
 ÿrg   )N))Ú
contextlibr   Úpathlibr   Útempfiler   r5   ÚnumpyrZ   rH   Z
matplotlibr,   r   rX   r   Zmatplotlib.style.corer   r   r.   r0   r   r   r%   r'   r1   r;   r<   r=   rB   rD   rE   rG   rK   ÚmarkZparametrizerT   r\   r]   r_   ra   rg   r   r   r   r   Ú<module>   sH   

		ÿý
