
    EVf%                     <   d Z ddlZddlZddlmZ ddlZddlZddlmZ ddl	Z	 e	j                  dej                  dk  rdnd       dd	Zd
 Zd Ze	j                  j!                  dddg      d        Ze	j                  j!                  dddg      d        Zd Zy)z2Tests for tinypages build using sphinx extensions.    N)Path)subprocess_run_for_testingsphinx)   
   z4.1.3)
minversionc                    |g n|}t         j                  dddddt        |      t        |       t        |      g	|}t        |ddi t        j
                  ddi	      }|j                  }|j                  }|j                  d
k(  sJ d| d| d       |rt        j                  d|        |j                         sJ y )N-msphinx-W-bhtml-dT
MPLBACKEND capture_outputtextenvr   z!sphinx build failed with stdout:
z	
stderr:

z-sphinx build emitted the following warnings:
)sys
executablestrr   osenvironstdoutstderr
returncodepytestfailis_dir)
source_dirdoctree_dirhtml_dir
extra_argscmdprocouterrs           h/var/www/html/software/conda/envs/catlas/lib/python3.12/site-packages/matplotlib/tests/test_sphinxext.pybuild_sphinx_htmlr*      s    !)zJ>>:tT6[!3z?CMPDNPC%Dt,rzz,<,.D ++C
++C??a E
,SESEDE
DSEJK??    c                 p   t        j                  t        t              j                  dz  | d       | dz  dz  }|dz  | dz  t
        j                  dd	d
ddt              t        t        t              j                  dz        t        |      g	}t        |ddi t        j                  dt        j                  d      }|j                  }|j                  }t        | |       fd}fd}t        dd      D cg c]
  } ||       c}\  }	}
}t!        j"                  |
 |d            sJ t!        j"                  | |d            sJ t!        j"                  |	 |d            sJ t!        j"                  |	 |d            sJ t!        j"                  |
 |d            sJ t!        j"                  | |d            sJ |dz  j%                         }d|v sJ t!        j"                  |dz        sJ t!        j"                  |
dz        sJ d|v sJ d|v sJ d|v sJ d |v sJ |j'                  d!      d"k(  sJ t!        j"                  |
 |d#            sJ t!        j"                  |	d$z        sJ | d%z  j%                         }|j)                  d&d'      }| d%z  j+                  |       d(D cg c]"  } ||      j-                         j.                  $ }}t        | |       t!        j"                  | |d#            sJ  |d      j-                         j.                  |d)   k(  sJ  |d"      j-                         j.                  |d   k(  sJ  |d*      j-                         j.                  |d"   k(  sJ t!        j"                  |	 |d            sJ t!        j"                  |
 |d"            sJ t!        j"                  | |d*            sJ  |d      j-                         j.                  |d*   kD  sJ t!        j"                  |
 |d            sJ y c c}w c c}w )+N	tinypagesTdirs_exist_ok_buildr   _imagesdoctreesr
   r   r   r   r   )r   GCOV_ERROR_FILEr   c                     d|  dz  S Nsome_plots-.png )numimg_dirs    r)   	plot_filez!test_tinypages.<locals>.plot_file;   s    ;se4000r+   c                 0    j                   dz  d|  dz  S )Nplot_directiver6   r7   )parent)r9   r"   s    r)   plot_directive_filez+test_tinypages.<locals>.plot_directive_file>   s#    !!$44SE7NNNr+                  12_0012_01   some_plots.htmls   # Only a commentz
range4.pngzrange6_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.      zrange6_range10.pngzincluded_plot_21.rsts   plt.plot(range(6))s   plt.plot(range(4)))r@   rI   r   rB   r   r   )shutilcopytreer   __file__r>   r   r   r   r   r   r   devnullr   r   r*   rangefilecmpcmp
read_bytescountreplacewrite_bytesstatst_mtime)tmp_pathr#   r%   r&   r'   r(   r;   r?   irange_10range_6range_4html_contentscontentsmodification_timesr"   r:   s                  @@r)   test_tinypagesr`   $   s   
OODN))K7"&(("V+H"GZ'K>>:tT6[!tH~$${23S]DC &DtKrzzK

KD ++C
++C hX61O 9>a!D1)A,!DHgw;;w	!---;;w	!---;;x2///;;x7!3444;;w	' 2333;;w	"... 11==?M-///;;w, 6777;;w*= =>>>.-???.-???.-???4EEEEF!KKK ;;w	"...;;x+?!?@@@ 11==?H 57LMH&&33H= $01 .a0557@@ 1 1hX6;;w	"... q!&&(115G5JJJJq!&&(115G5JJJJq!&&(115G5JJJJ;;x1...;;w	!---;;w	!--- q!&&(114Fq4IIII;;w	!---q "EP1s   P.'P3c                    t        t              j                  }t        j                  |dz  | dz         t        j
                  |dz  | dz         | dz  }| dz  j                  d       | dz  d	z  }t        | ||       t        t        |j                  d
                  dk(  sJ | dz  dz  }t        | ||ddg       t        t        |j                  d
                  dk(  sJ y )Ntinypages/conf.pyconf.pytinypages/_static_staticr2   	index.rstz#
.. plot::

    plt.plot(range(2))
r0   html1**/index-1.pyr@   html2-Dzplot_html_show_source_link=0r$   r   r   rM   r>   rK   copyfilerL   
write_textr*   lenlistglob)rX   r>   r"   	html_dir1	html_dir2s        r)   test_plot_html_show_source_linkrt   }   s    (^""F
OOF00(Y2FG
OOF00(Y2FGZ'K'' )  8#g-IhY7tINN?345::: 8#g-IhY"&(F!GItINN?345:::r+   plot_html_show_source_linkr@   c                 `   t        t              j                  }t        j                  |dz  | dz         t        j
                  |dz  | dz         | dz  }| dz  j                  d       | dz  d	z  }t        | ||d
d| g       t        t        |j                  d                  dk(  sJ y )Nrb   rc   rd   re   r2   rf   z?
.. plot::
    :show-source-link: true

    plt.plot(range(2))
r0   r   rj   plot_html_show_source_link=rk   rh   r@   rl   rX   ru   r>   r"   r#   s        r)   test_show_source_link_truery           (^""F
OOF00(Y2FG
OOF00(Y2FGZ'K'' )  ("V+HhX+,F+GHCJ KtHMM/234999r+   c                 `   t        t              j                  }t        j                  |dz  | dz         t        j
                  |dz  | dz         | dz  }| dz  j                  d       | dz  d	z  }t        | ||d
d| g       t        t        |j                  d                  dk(  sJ y )Nrb   rc   rd   re   r2   rf   z@
.. plot::
    :show-source-link: false

    plt.plot(range(2))
r0   r   rj   rw   rk   rh   r   rl   rx   s        r)   test_show_source_link_falser|      rz   r+   c                    t        j                  t        t              j                  dz  | d       | dz  dz  }|dz  | dz  }t        | ||dd	g
       dfd	}dD ]4  } ||      j                         sJ  ||d      j                         r4J  dz  j                         sJ dz  j                         sJ dz  j                         sJ dz  j                         sJ dz  j                         sJ dz  j                         sJ dz  j                         sJ dz  j                         sJ d|dz  j                  d      v sJ d}||dz  j                  d      v sJ d}||dz  j                  d      v sJ y ) Nr-   Tr.   r0   r   r1   r2   rj   zplot_srcset=2xrk   c                     d|  | dz  S r5   r8   )r9   suffr:   s     r)   r;   z&test_srcset_version.<locals>.plot_file   s    ;seD6666r+   )	r@   rI   r   rB   rC   rD   rG      rJ   z.2x)r   znestedpage-index-1.pngznestedpage-index-1.2x.pngznestedpage-index-2.pngznestedpage-index-2.2x.pngznestedpage2-index-1.pngznestedpage2-index-1.2x.pngznestedpage2-index-2.pngznestedpage2-index-2.2x.pngzDsrcset="_images/some_plots-1.png, _images/some_plots-1.2x.png 2.00x"rH   zutf-8)encodingzVsrcset="../_images/nestedpage-index-1.png, ../_images/nestedpage-index-1.2x.png 2.00x"znestedpage/index.htmlzXsrcset="../_images/nestedpage2-index-2.png, ../_images/nestedpage2-index-2.2x.png 2.00x"znestedpage2/index.html)r   )rK   rL   r   rM   r>   r*   exists	read_text)rX   r#   r"   r;   indstr:   s         @r)   test_srcset_versionr      s   
OODN))K7"&(("V+H"GZ'KhXC  !7 / 3~$$&&&5)002223 ..668881199;;;..668881199;;;//7799922::<<<//7799922::<<< S,,777IJ K J8B(44???QQQQ9B(55@@'@RRRRr+   )N)__doc__rP   r   pathlibr   rK   r   matplotlib.testingr   r   importorskipversion_infor*   r`   rt   markparametrizery   r|   r   r8   r+   r)   <module>r      s    8  	   
 9    H'*'7'7''AtwP&V.r;, 51v>: ?:& 51v>: ?:&&Sr+   