o
    h                     @   s   d dl Z d dlZd dlmZ d dlZd dlmZ zd dl	m
Z
 W n ey0   ejddd Y nw ejddd	 Zejdd
d Zejddd Zejddd ZdS )    N)mock)_macosxzThese are mac only testsT)allow_module_levelmacosxc                  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   x/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/matplotlib/tests/test_backend_macosx.pytest_cached_renderer   s   


r   c                    s    fdd}|  td| t }td i- |jj    d|j	  }t
j|s1J tjd   dks=J W d    d S 1 sHw   Y  d S )Nc                    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   z2test_savefig_rcparam.<locals>.new_choose_save_filechoose_save_filezsavefig.directoryr   r   )setattrr   r   r	   mpl
rc_contextr
   toolbarsave_figureget_default_filenamer   pathexistsrcParams)monkeypatchr   r   r   	save_filer   r   r   test_savefig_rcparam   s   "r*   c                  C   s    ddl m}  | dddd d S )Nr   ipython_in_subprocessosxr   MacOSX))      )   r   )matplotlib.testingr,   r+   r   r   r   test_ipython2   s   r3   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   z,matplotlib.backends._macosx.choose_save_filez
foobar.png)return_value)r   subplotsimshowr   patchr
   managerr"   r#   r   remove)r   axpropfnamer   r   r   test_save_figure_return8   s   
"r=   )r   pytestunittestr   
matplotlibr    matplotlib.pyplotpyplotr   matplotlib.backendsr   ImportErrorskipmarkbackendr   r*   r3   r=   r   r   r   r   <module>   s$    






