rL idZddlmZddlmZddlZddlZddlZddlZddl Z ddl Z ddl m Z ejeZdZdZdZ dd Zdd d Zd Zd ZdZdZy)z Helper functions for testing. )Path)TemporaryDirectoryN)_apicvdtjd<dtjd<dtjd<y)Nz DejaVu Sansz font.familynonez text.hintingztext.hinting_factormplrcParamsa/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/testing/__init__.pyset_font_settings_for_testingrs-"/CLL#)CLL *+CLL&'r c*dtjd<y)N matplotlibz svg.hashsaltr r r rset_reproducibility_for_testingrs#/CLL r c tjtjdt jdtj5t jdddtty#tj$rW tjtjdn.#tj$rtj dYnwxYwYwxYw#1swYxYw)Nz en_US.UTF-8zEnglish_United States.1252zPCould not set locale to English/United States. Some date-related tests may fail.Agg) locale setlocaleLC_ALLError_logwarningr user'suppress_matplotlib_deprecation_warning rcdefaultsrrr r rsetuprs5 6GGEN 5 5 7  "##%! <<5 5   V]],H I|| 5 LL4 5 55sA$BC.C+$B:9C+:(C%"C+$C%%C+*C+.C7c |rtjx}} tj|||||||}|S#t$r*tj dk(rddl} | jdwxYw)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. envtimeoutcheckstdoutstderrtextcygwinrNz Fork failure) subprocessPIPErunBlockingIOErrorsysplatformpytestxfail) commandr!r"r$r%r#r&capture_outputprocr.s rsubprocess_run_for_testingr35sqL$//) ~~ 5&   K  <<8 #  LL ( s 43A') extra_envc ,|j}|j}|jj}t t j dd|d|d|dg|itjddi|xsi|dtjtjd }|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. -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_EPOCH0Tr ) __name__ __module____code__ co_filenamer3r, executableosenvironr(r))funcr"r4argstargetmodulefiler2s rsubprocess_run_helperrEms]]F __F == $ $D % NN >>DZr$Rhb  "   Jrzz I. I R It  D" Kr cTt5}t|d}|jdd tj|dt |g|tj tj  dddy #ttjf$r YdddywxYw#1swYyxYw) z Check if a given TeX system + pgf is available Parameters ---------- texsystem : str The executable name to check ztest.texz \documentclass{article} \usepackage{pgf} \begin{document} \typeout{pgfversion=\pgfversion} \makeatletter \@@end zutf-8)encodingz-halt-on-error)cwdr$r%NFT) rr write_textr( check_callstrDEVNULLOSErrorCalledProcessError) texsystemtmpdirtex_paths r_check_for_pgfrRs   +      ! !,c(m<&!))*2D2D F !667  s/ BAA7-B7BBBBB'ch tjj|dy#t$rYywxYw)Nz.styTF)r dviread find_tex_fileFileNotFoundError)packages r_has_tex_packagerXs5 !!WIT"23 s "% 11cddl}|jd}tjdk(r|j d|j dddk(r|dk(r|j d|j D]\}}|j dd |k\s|}nd }td d d |d|gdd}|jjjddsJy)NrIPythonwin32z>Cannot change backend running IPython in subprocess on Windows)rrosxz:Bug using macosx backend in IPython 8.24.0 fixed in 8.24.1zpimport matplotlib as mpl, matplotlib.pyplot as plt;fig, ax=plt.subplots(); ax.plot([1, 3, 2]); mpl.get_backend()ipythonz--no-simple-promptz --matplotlib=r6T)r#r1') r. importorskipr,r-skip version_infoitemsr3r$stripendswith) "requested_backend_or_gui_frameworkall_expected_backendsr.rZ min_versionbackendexpected_backendcoder2s ripython_in_subprocessrns!!),G ||w TURa J. .% 7 PQ!6 ; ; = W    #{ 2&    LD %  >? @ $   D ;;    ' '!,<+=Q(? @@ @r cHgd}|D]}tj|syy)N)CICONTINUOUS_INTEGRATIONTRAVISCIRCLECIJENKINS GITLAB_CIGITHUB_ACTIONSTEAMCITY_VERSIONTF)r>getenv)ci_environment_variablesenv_vars ris_ci_environmentr{s/ , 99W  r )N<NNFTF)__doc__pathlibrtempfilerrloggingr>r(r,rr r getLoggerr9rrrrr3rErRrXrnr{r r rrs|'   w", 0&2FJ>B.35p;?"J8ADr