3
$ßL]Ô  ã               @   s¾  d dl Z d dl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Z	d dl
jZd dlmZmZ d dlmZ d dlmZmZ ejƒ �B ejdƒ ejjde	jjjkdd	�Zejje	jd
ƒ dd	�ZW dQ R X ejjdd�ejjdddi fej ddddied�ej dddd
ieegd�ddi fdd
dd
ifej dddd
ieegd�gddddddgd�dd„ ƒƒZ!dd„ Z"eedd „ ƒƒZ#d!d"„ Z$d#d$„ Z%eed%d&„ ƒƒZ&ed'gdgd(�d)d*„ ƒZ'ed+d,„ ƒZ(dS )-é    N)ÚPath)ÚcbookÚpatheffects)Úimage_comparison)Ú_determinism_source_date_epochÚ_determinism_checkÚignoreZepsz*This test needs a ghostscript installation)ÚreasonTz"This test needs a TeX installationé   )Zrerunszformat, use_log, rcParamsÚpsFzps.usedistillerZghostscript)Zmarksztext.usetexz	ps.useafmzps with distillerzps with usetexzeps afmzeps with usetex)Úidsc       	      C   sÌ   t jj|ƒ tjƒ \}}tjƒ �¢}tjƒ �Ž}|r:|jdƒ |j	ddgddgƒ |j
dƒ |j|| d� |j|| d� |jƒ jdƒ}|jƒ }dd„ ||gD ƒ\}}||jd	d
ƒks´t‚W d Q R X W d Q R X d S )NÚlogé   é   u	   DÃ©jÃ  vu)ÚformatÚasciic             S   s   g | ]}t jd d|ƒ‘qS )s   %%.*?
ó    )ÚreÚsub)Ú.0Úx© r   úH/tmp/pip-install-edjban26/matplotlib/matplotlib/tests/test_backend_ps.pyú
<listcomp>D   s    z,test_savefig_to_stringio.<locals>.<listcomp>s   
ó   
)ÚmplÚrcParamsÚupdateÚpltÚsubplotsÚioÚStringIOÚBytesIOZ
set_yscaleÚplotÚ	set_titleÚsavefigÚgetvalueÚencodeÚreplaceÚAssertionError)	r   Zuse_logr   ÚfigÚaxZs_bufZb_bufZs_valZb_valr   r   r   Útest_savefig_to_stringio   s    

r,   c              C   sl   t jƒ �Z tjddd�gt jd< tjƒ \} }|jdddgƒ tj	ƒ �}| j
|dd	� W d Q R X W d Q R X d S )
Né   Úw)Z	linewidthZ
foregroundzpath.effectsr   r   r
   r   )r   )r   Z
rc_contextr   Z
withStroker   r   r   r#   r    r"   r%   )r*   r+   r   r   r   r   Útest_patheffectsI   s    

r/   c             C   s‚   t t| ƒdƒ}|jƒ  tjtt|ƒd��P tjddd� tjdddd	gƒ tj	d
ƒ t
jjt|ƒdƒ}tj|dd� W d Q R X d S )Nzshort-1)ÚtempdirÚtextT)Úusetexr   r   r
   r-   z\textbf{time} (s)ztex_demo.epsr   )r   )r   ÚstrÚmkdirr   Z_setattr_cmÚtempfiler   Úrcr#   ÚxlabelÚosÚpathÚjoinr%   )ÚtmpdirZbase_tempdirZ
output_epsr   r   r   Útest_tilde_in_tempfilenameS   s    
r<   c               C   s   t ddƒ dS )z,Test SOURCE_DATE_EPOCH support for PS outputr   s(   %%CreationDate: Sat Jan 01 00:00:00 2000N)r   r   r   r   r   Útest_source_date_epochg   s    r=   c               C   s   t dd� dS )zTest for reproducible PS outputr   )r   N)r   r   r   r   r   Útest_determinism_allq   s    r>   c               C   s   t ddd� dS )z#Test for reproducible PS/tex outputr   T)r   r2   N)r   r   r   r   r   Útest_determinism_all_texv   s    r?   Úempty)Zbaseline_imagesÚ
extensionsc              C   s@   t jƒ \} }|jƒ  |jddgddd� |jdddddd� d S )Nr   r   Úr)ÚcolorÚalphag      à?Zfoo)r   r   Zset_axis_offr#   r1   )r*   r+   r   r   r   Útest_transparency}   s    rE   c          	   C   sF   t | jdƒƒ}dtjd< tjdƒ tjtƒ� tj	|ƒ W dQ R X dS )z"Test failing latex subprocess callztmpoutput.psTztext.usetexz$22_2_2$N)
r3   r:   r   r   r   r7   ÚpytestZraisesÚRuntimeErrorr%   )r;   r9   r   r   r   Útest_failing_latex…   s
    

rH   ))r    r8   Zpathlibr   r   r5   ÚwarningsrF   Z
matplotlibr   Zmatplotlib.pyplotZpyplotr   r   r   Zmatplotlib.testing.decoratorsr   Zmatplotlib.testing.determinismr   r   Úcatch_warningsÚsimplefilterÚmarkZskipifZtestingÚcompareÚ	converterZneeds_ghostscriptZcheckdep_usetexZneeds_usetexZflakyZparametrizeÚparamr,   r/   r<   r=   r>   r?   rE   rH   r   r   r   r   Ú<module>   sZ   






