o
    g	                     @   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PIPEsphinxc              
      s  t | }|d  |d }tjdddddt|tt tjd t g	}t|ttdi tj	d	d
id}|
 \}}|jdksIJ d| d| d|rStd|    sYJ  fddfddtddD \}}}	t|dsxJ t|	dsJ t|dsJ t|dsJ t|dsJ t|	dsJ  d  }
d|
v sJ t|	 d sJ t| d  sJ d!|
v sJ d"|
v sJ d#|
v sJ d$|
v sJ |
d%d&ksJ d S )'Nhtmldoctreesz-msphinxz-Wz-bz-d	tinypagesT
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   ]/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/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>               12_00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pytestfailis_dirrangefilecmpcmp
read_bytescount)tmpdirtmp_pathdoctree_dircmdprocouterrrange_10range_6range_4html_contentsr   )r   r   r   test_tinypages   sD   
r=   )__doc__r.   r&   pathlibr   
subprocessr   r   r!   r*   importorskipr=   r   r   r   r   <module>   s    
