o
    Ďi(                     @   s   d dl 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 ej	
dg ddd Zej	jejdkd	d
ej	jejdkoDe  d kdd
dd Zdd Zdd Zdd Zeddd ZdS )    N)patch)subprocess_run_for_testingzversion_str, version_tuple))z3.5.0)      r   finalr   )z3.5.0rc2)r   r   r   	candidate   )z3.5.0.dev820+g6768ef8c4c)r   r   r   alpha4  )z3.5.0.post820+g6768ef8c4c)r   r      r	   r
   c                 C   s   t | |ks	J d S )N)
matplotlib_parse_to_version_info)version_strversion_tuple r   \/home/jeff/fluffinator/venv/lib/python3.10/site-packages/matplotlib/tests/test_matplotlib.pytest_parse_to_version_info   s   r   win32z%chmod() doesn't work as is on Windows)reasonzchmod() doesn't work as rootc              
   C   sv   t | j}z-t | d ttjddgi t jdt| it	j
ddd}d|jv s+J W t | | dS t | | w )	zETest that a warning is emitted if a temporary configdir must be used.r   -czimport matplotlibMPLCONFIGDIRT)envstderrtextcheckzset the MPLCONFIGDIRN)osstatst_modechmodr   sys
executableenvironstr
subprocessPIPEr   )tmp_pathmodeprocr   r   r   test_tmpconfigdir_warning   s   
r(   c                 C   s,   t tjddgi tjdt| idd d S )Nr   zOimport pathlib; pathlib.Path.home = lambda *args: 1/0; import matplotlib.pyplotr   Tr   r   )r   r   r    r   r!   r"   )r%   r   r   r   test_importable_with_no_home(   s   
r*   c                  C   s\   dd } ddl m}m} t| dt||jksJ t| dt||jks,J dS )z
    Test that the standard backends mentioned in the docstring of
    matplotlib.use() are the same as in matplotlib.rcsetup.
    c                 S   sL   g }t jj| d dD ]}| s |S |dd |dD 7 }q|S )Nr   
c                 S   s   g | ]
}|r|   qS r   )striplower).0er   r   r   
<listcomp>:   s    zAtest_use_doc_standard_backends.<locals>.parse.<locals>.<listcomp>,)r   use__doc__splitr,   )keybackendsliner   r   r   parse5   s   z-test_use_doc_standard_backends.<locals>.parser   )BackendFilterbackend_registryz- interactive backends:
z- non-interactive backends:
N)matplotlib.backendsr9   r:   setlist_builtinINTERACTIVENON_INTERACTIVE)r8   r9   r:   r   r   r   test_use_doc_standard_backends0   s   

r@   c                  C   s.   d} t tjdd| gi tjddidd dS )	z
    When using -OO or export PYTHONOPTIMIZE=2, docstrings are discarded,
    this simple test may prevent something like issue #17970.
    zimport matplotlib as mpl; import matplotlib.pyplot as plt; import matplotlib.cbook as cbook; import matplotlib.patches as mpatchesz-OOr   
MPLBACKEND Tr)   N)r   r   r    r   r!   )programr   r   r   test_importable_with__OOE   s   
rD   z"matplotlib.subprocess.check_outputc                 C   sT   t jdgdd| _tjtjdd tjd W d   dS 1 s#w   Y  dS )ze
    Test that _get_executable_info raises ExecutableNotFoundError if the
    command times out.
    mock   )cmdtimeoutz	Timed out)matchinkscapeN)	r#   TimeoutExpiredside_effectpytestraisesr   ExecutableNotFoundError_get_executable_info__wrapped__)mock_check_outputr   r   r    test_get_executable_info_timeoutV   s   "rS   )r   r#   r   unittest.mockr   rM   r   matplotlib.testingr   markparametrizer   skipifplatformgeteuidr(   r*   r@   rD   rS   r   r   r   r   <module>   s*    
