
    h                         S r SSKJr  SSKJr  SSKrSSKrSSKrSSKrSSK	r	SSK
rSSK
Jr  \R                  " \5      rS rS rS r   SS	 jrSS
.S jrS rS rS rS rg)z
Helper functions for testing.
    )Path)TemporaryDirectoryN)_apic                  v    S[         R                  S'   S[         R                  S'   S[         R                  S'   g )NzDejaVu Sanszfont.familynoneztext.hinting   ztext.hinting_factormplrcParams     M/var/www/html/env/lib/python3.13/site-packages/matplotlib/testing/__init__.pyset_font_settings_for_testingr      s-    "/CLL#)CLL *+CLL&'r   c                  *    S[         R                  S'   g )N
matplotlibzsvg.hashsaltr	   r   r   r   set_reproducibility_for_testingr      s    #/CLL r   c                      [         R                  " [         R                  S5        [        R                  " S5        [        R                  " 5          [        R                  " 5         S S S 5        [        5         [        5         g ! [         R                   aY     [         R                  " [         R                  S5         N! [         R                   a    [        R                  S5          Nf = ff = f! , (       d  f       N= f)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 
8
 "##%! << 5	5V]],HI|| 	5LL45	55 
8	7s5   %B C5C2%C)C.*C2-C..C25
Dc           
          U(       a  [         R                  =p4 [         R                  " XX%X4US9nU$ ! [         a+    [        R
                  S:X  a  SSKn	U	R                  S5        e f = f)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   si    L $//)~~	
 K  <<8#LL(s	   3 5A()	extra_envc                4   U R                   nU R                  nU R                  R                  n[	        [
        R                  SSU< SU< SU S3/UQ0 [        R                  ESS0EU=(       d    0 EUS[        R                  [        R                  SS	9nU$ )
ag  
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.
-czEimport importlib.util;_spec = importlib.util.spec_from_file_location(z, z]);_module = importlib.util.module_from_spec(_spec);_spec.loader.exec_module(_module);_module.z()SOURCE_DATE_EPOCH0Tr    )__name__
__module____code__co_filenamer3   r,   
executableosenvironr(   r)   )funcr"   r4   argstargetmodulefiler2   s           r   subprocess_run_helperrE   m   s     ]]F__F==$$D%NN>>DZr$ R hb	"		
 		
 JrzzI.I	RItD" Kr   c                 V   [        5        n[        US5      nUR                  SSS9   [        R                  " U S[        U5      /U[        R                  [        R                  S9   SSS5        g	! [        [        R                  4 a     SSS5        gf = f! , (       d  f       g= f)
zx
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_pgfrR      s     
	
+   	 		!!,c(m<&!))*2D2DF
 ! 
	 667 	 
		 
	s.   B?A2(B2BBBB
B(c                 j     [         R                  R                  U  S35        g! [         a     gf = f)Nz.styTF)r
   dvireadfind_tex_fileFileNotFoundError)packages    r   _has_tex_packagerX      s5    !!WIT"23 s   "% 
22c                    SS K nUR                  S5      n[        R                  S:X  a  UR	                  S5        UR
                  S S S:X  a  U S:X  a  UR	                  S5        UR                  5        H  u  pEUR
                  S S	 U:  d  M  Un  O   S
n[        SSSU  3SU/SSS9nUR                  R                  5       R                  SW S35      (       d   eg )Nr   IPythonwin32z>Cannot change backend running IPython in subprocess on Windows   )r      r   osxz:Bug using macosx backend in IPython 8.24.0 fixed in 8.24.1   zpimport matplotlib as mpl, matplotlib.pyplot as plt;fig, ax=plt.subplots(); ax.plot([1, 3, 2]); mpl.get_backend()ipythonz--no-simple-promptz--matplotlib=r6   T)r#   r1   ')r.   importorskipr,   r-   skipversion_infoitemsr3   r$   stripendswith)	"requested_backend_or_gui_frameworkall_expected_backendsr.   rZ   min_versionbackendexpected_backendcoder2   s	            r   ipython_in_subprocessrn      s    !!),G
||wTURa J..%7PQ !6 ; ; =#{2& !>
LD% >?@$		
 	D ;;''!,<+=Q(?@@@@r   c                  X    / SQn U  H   n[         R                  " U5      (       d  M     g   g)N)CICONTINUOUS_INTEGRATIONTRAVISCIRCLECIJENKINS	GITLAB_CIGITHUB_ACTIONSTEAMCITY_VERSIONTF)r>   getenv)ci_environment_variablesenv_vars     r   is_ci_environmentr{      s-    
  ,99W , r   )N<   NNFTF)__doc__pathlibr   tempfiler   r   loggingr>   r(   r,   r   r
   r   	getLoggerr9   r   r   r   r   r3   rE   rR   rX   rn   r{   r   r   r   <module>r      sz     '   	  
  ",0&2 FJ>B.35p ;? "J8ADr   