
    (?e                         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ZdddZd Zd ZdS )z
Helper functions for testing.
    )Path)TemporaryDirectoryN)_apic                  `    dt           j        d<   dt           j        d<   dt           j        d<   d S )NzDejaVu Sanszfont.familynoneztext.hinting   ztext.hinting_factormplrcParams     ;lib/python3.11/site-packages/matplotlib/testing/__init__.pyset_font_settings_for_testingr      s-    "/CL#)CL *+CL&'''r   c                  $    dt           j        d<   d S )N
matplotlibzsvg.hashsaltr	   r   r   r   set_reproducibility_for_testingr      s    #/CL   r   c                     	 t          j        t           j        d           ne# t           j        $ rS 	 t          j        t           j        d           n/# t           j        $ r t                              d           Y nw xY wY nw xY wt          j        d           t          j	                    5  t          j
                     d d d            n# 1 swxY w Y   t                       t                       d S )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666< 5 5 5	5V],HIIII| 	5 	5 	5LL45 5 5 5 5	55 GENNN		5	7	7                
 "####%%%%%sD   " BAB)A>;B=A>>BB.CCCFTc           	          |rt           j        x}}	 t          j        | ||||||          }n8# t          $ r+ t          j        dk    rddl}	|	                    d            w xY w|S )a  
    Create and run a subprocess.

    Thin wrapper around `subprocess.run`, intended for testing.  Will
    mark fork() failures on Cygwin as expected failures: not a
    success, but not indicating a problem with the code either.

    Parameters
    ----------
    args : list of str
    env : dict[str, str]
    timeout : float
    stdout, stderr
    check : bool
    text : bool
        Also called ``universal_newlines`` in subprocess.  I chose this
        name since the main effect is returning bytes (`False`) vs. str
        (`True`), though it also tries to normalize newlines across
        platforms.
    capture_output : bool
        Set stdout and stderr to subprocess.PIPE

    Returns
    -------
    proc : subprocess.Popen

    See Also
    --------
    subprocess.run

    Raises
    ------
    pytest.xfail
        If platform is Cygwin and subprocess reports a fork() failure.
    envtimeoutcheckstdoutstderrtextcygwinr   NzFork failure)
subprocessPIPErunBlockingIOErrorsysplatformpytestxfail)
commandr!   r"   r$   r%   r#   r&   capture_outputprocr.   s
             r   subprocess_run_for_testingr3   5   s    L  *$/)~5&	
 
 
    <8##MMMLL((( Ks	   . 5A#)	extra_envc                    | j         }| j        }t          t          j        dd| d| d| dg|i t
          j        ddi|p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0Tr    )	__name__
__module__r3   r,   
executableosenvironr(   r)   )funcr"   r4   argstargetmoduler2   s          r   subprocess_run_helperrA   m   s     ]F_F%N8F88F88f888	
 		
 JrzI.II	RIt  D Kr   c                 p   t                      5 }t          |d          }|                    dd           	 t          j        | dt          |          g|t          j        t          j                   n(# t          t          j        f$ r Y ddd           dS w xY w	 ddd           d	S # 1 swxY w Y   dS )
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_pgfrN      sA    
		 
++   	 	 	 		!,c(mm<&!)*2DF F F F F 67 	 	 	       	!                 s4   (B+<A54B+5BB+BB++B/2B/c                 n    	 t           j                            |  d           dS # t          $ r Y dS w xY w)Nz.styTF)r
   dvireadfind_tex_fileFileNotFoundError)packages    r   _has_tex_packagerT      sM    !!W"2"2"2333t   uus   "& 
44)NNNNFTF)__doc__pathlibr   tempfiler   r   loggingr;   r(   r,   r   r
   r   	getLoggerr8   r   r   r   r   r3   rA   rN   rT   r   r   r   <module>rZ      s+          ' ' ' ' ' '   				     



          w"", , ,0 0 0& & &2 HL>B.35 5 5 5p ;?     @  8    r   