o
    ĎiF                     @   s   d dl Z d dlZd dlmZ d dlZd dlmZ d dlZd dl	m
Z d dlmZ dZdd Zejjdd	d
dd Zdd Zejjdd	d
dd Zejjdd	d
dd Zdd Zejjdd	d
dd Zdd Zejjdd	d
dd ZdS )    N)Path)mock)subprocess_run_helper<   c                  C   sR   t d} | j  | j jd usJ t d} |   | j jd us'J d S )N      )pltfigurecanvasdrawget_renderer	_rendererdraw_without_rendering)fig r   `/home/jeff/fluffinator/venv/lib/python3.10/site-packages/matplotlib/tests/test_backend_macosx.py_test_cached_renderer   s   


r   macosxT)skip_on_importerrorc                   C      t ttddid d S N
MPLBACKENDr   timeout	extra_env)r   r   _test_timeoutr   r   r   r   test_cached_renderer      
r   c               	      s   t tjd   fdd} t }td| L td i, |j	j
    d|j	  }tj|s8J tjd   dksDJ W d    n1 sNw   Y  W d    d S W d    d S 1 sfw   Y  d S )NTEST_SAVEFIG_PATHc                    s.   |t  ksJ t| d | d| S )N/test/test/)strosmakedirs)title	directoryfilenametmp_pathr   r   new_choose_save_file%   s   z3_test_savefig_rcparam.<locals>.new_choose_save_file,matplotlib.backends._macosx.choose_save_filezsavefig.directoryr    r   )r   r"   environr   r	   r   patchmpl
rc_contextr
   toolbarsave_figureget_default_filenamepathexistsrcParams)r)   r   	save_filer   r'   r   _test_savefig_rcparam"   s   Pr6   c                 C   s   t ttd| dd d S )Nr   )r   r   r   )r   r6   r   r'   r   r   r   test_savefig_rcparam:   s   
r7   c                  C   s    ddl m}  | dddd d S )Nr   ipython_in_subprocessosxr   MacOSX))      )   r   )matplotlib.testingr9   r8   r   r   r   test_ipythonA   s   r@   c                  C   s   t  \} }|dgg d}tj|dd | jjj }t	
d |dks)J W d    n1 s3w   Y  tj|d d | jjj }|d u sMJ W d    d S 1 sXw   Y  d S )Nr   r*   z
foobar.png)return_value)r   subplotsimshowr   r,   r
   managerr/   r0   r"   remove)r   axpropfnamer   r   r   _test_save_figure_returnG   s   
"rI   c                   C   r   r   )r   rI   r   r   r   r   r   test_save_figure_returnT   r   rJ   c                  C   s(   dd } t j| d}|  |  d S )Nc               	   S   s   d} d}t jt| d, t jt|d t  W d    n1 s"w   Y  W d    d S W d    d S 1 s:w   Y  d S )Nz;Matplotlib GUI outside of the main thread will likely fail.z9Cannot create a GUI FigureManager outside the main thread)match)pytestwarnsUserWarningraisesRuntimeErrorr   gcf)warn_msgerr_msgr   r   r   create_figure[   s   
"zA_test_create_figure_on_worker_thread_fails.<locals>.create_figure)target)	threadingThreadstartjoin)rT   workerr   r   r   *_test_create_figure_on_worker_thread_failsZ   s   r[   c                   C   r   r   )r   r[   r   r   r   r   r   )test_create_figure_on_worker_thread_failsg   s
   
r\   )r"   rV   pathlibr   rL   unittestr   
matplotlibr-   matplotlib.pyplotpyplotr   r?   r   r   r   markbackendr   r6   r7   r@   rI   rJ   r[   r\   r   r   r   r   <module>   s.    



