
    G8c                         d 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	Z	ddl
Zddl
mZ  ej                  e      Zd Zd Zd Zdd	d
Zd Zd Zy)z
Helper functions for testing.
    )Path)TemporaryDirectoryN)_apic                  v    dt         j                  d<   dt         j                  d<   dt         j                  d<   y )NzDejaVu Sanszfont.familynoneztext.hinting   ztext.hinting_factormplrcParams     =/usr/lib/python3/dist-packages/matplotlib/testing/__init__.pyset_font_settings_for_testingr      s-    "/CLL#)CLL *+CLL&'r   c                  *    dt         j                  d<   y )N
matplotlibzsvg.hashsaltr	   r   r   r   set_reproducibility_for_testingr      s    #/CLL r   c                     	 t        j                  t         j                  d       t        j                  d       t        j                         5  t        j                          d d d        t                t                y # t         j                  $ rW 	 t        j                  t         j                  d       n.# t         j                  $ r t        j                  d       Y nw xY wY w xY w# 1 sw Y   xY w)Nzen_US.UTF-8zEnglish_United States.1252zPCould not set locale to English/United States. Some date-related tests may fail.Agg)locale	setlocaleLC_ALLError_logwarningr
   user   'suppress_matplotlib_deprecation_warning
rcdefaultsr   r   r   r   r   setupr      s    56 GGEN		5	5	7 
 "##%! << 5	5V]],HI|| 	5LL45	55 sA   $B C.C+$B:9C+:(C%"C+$C%%C+*C+.C7)	extra_envc                   | j                   }| j                  }t        j                  t        j
                  dd| d| d| dg|i t        j                  ddi|xs i |dt        j                  t        j                  d	      }|S )
a  
    Run a function in a sub-process.

    Parameters
    ----------
    func : function
        The function to be run.  It must be in a module that is importable.
    *args : str
        Any additional command line arguments to be passed in
        the first argument to ``subprocess.run``.
    extra_env : dict[str, str]
        Any additional environment variables to be set for the subprocess.
    z-czfrom z import z; z()SOURCE_DATE_EPOCH0T)envtimeoutcheckstdoutstderruniversal_newlines)	__name__
__module__
subprocessrunsys
executableosenvironPIPE)funcr$   r   argstargetmoduleprocs          r   subprocess_run_helperr7   5   s     ]]F__F>>		6("	5	 	 JrzzI.I	RIt	!D Kr   c                 T   t               5 }t        |d      }|j                  dd       	 t        j                  | dt        |      g|t        j                  t        j                         	 ddd       y	# t        t        j                  f$ r Y ddd       yw xY w# 1 sw Y   yxY w)
z
    Check if a given TeX system + pgf is available

    Parameters
    ----------
    texsystem : str
        The executable name to check
    ztest.texz
            \documentclass{article}
            \usepackage{pgf}
            \begin{document}
            \typeout{pgfversion=\pgfversion}
            \makeatletter
            \@@end
        zutf-8)encodingz-halt-on-error)cwdr&   r'   NFT)	r   r   
write_textr+   
check_callstrDEVNULLOSErrorCalledProcessError)	texsystemtmpdirtex_paths      r   _check_for_pgfrD   R   s     
	 
+   	 		!!,c(m<&!))*2D2DF
 !  667 	 	 s/    BAA7-B7BBBBB'c                 h    	 t         j                  j                  |  d       y# t        $ r Y yw xY w)Nz.styTF)r
   dviread_find_tex_fileFileNotFoundError)packages    r   _has_tex_packagerJ   n   s5    ""gYd#34 s   "% 	11)__doc__pathlibr   tempfiler   r   loggingr/   r+   r-   r   r
   r   	getLoggerr)   r   r   r   r   r7   rD   rJ   r   r   r   <module>rP      s\     '   	  
  w",0&2 ;? :8r   