U
    \	a	                     @   sV   d Z ddlZddlZddlmZ ddlmZmZ ddlZddl	Z	e	
d dd ZdS )z2Tests for tinypages build using sphinx extensions.    N)Path)PopenPIPEZsphinxc              
      s  t | }|d  |d }tjdddddt|tt tjd t g	}t|ttdtj	d	d
id}|
 \}}|jdkstd| d| d|rtd|    st fddfddtddD \}}}	t|dstt|	dstt|dstt|ds.tt|dsDtt|	dsZt d  }
d|
ksttt|	 d stt| d  std!|
kstd"|
kstd#|
kstd$|
kst|
d%d&kstd S )'NhtmlZdoctreesz-msphinxz-Wz-bz-dZ	tinypagesTZ
MPLBACKEND )stdoutstderruniversal_newlinesenvr   z!sphinx build failed with stdout:
z	
stderr:

z-sphinx build emitted the following warnings:
c                    s    d|  d S )Nzsome_plots-z.png )num)html_dirr   C/tmp/pip-unpacked-wheel-wjyw_3jo/matplotlib/tests/test_sphinxext.py	plot_file"   s    z!test_tinypages.<locals>.plot_filec                    s   g | ]} |qS r   r   ).0i)r   r   r   
<listcomp>%   s     z"test_tinypages.<locals>.<listcomp>               Z12_00Z12_01   zsome_plots.htmls   # Only a commentz
range4.pngz
range6.pngs    This is the caption for plot 15.s    Plot 17 uses the caption option.s    This is the caption for plot 18.s&   plot-directive my-class my-other-classs#   This caption applies to both plots.   )r   sys
executablestr__file__parentr   r   osenvironcommunicate
returncodeAssertionErrorpytestZfailis_dirrangefilecmpcmp
read_bytescount)ZtmpdirZtmp_pathZdoctree_dircmdprocouterrZrange_10Zrange_6Zrange_4Zhtml_contentsr   )r   r   r   test_tinypages   sH      
r0   )__doc__r(   r    pathlibr   
subprocessr   r   r   r%   Zimportorskipr0   r   r   r   r   <module>   s   
