a
    ëÝEb°  ã                   @   s0  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZdZddd„Z	ej
jddd�e	dd	�d
d„ ƒƒZej
jddd�e	dd	�dd„ ƒƒZej
je ¡ dkdd�ej
jddd�ej
jdd�e	dd	�dd„ ƒƒƒƒZej
jddd�ej
jdd�e	d d	�dd„ ƒƒƒZej
jddd�e	dd	�dd„ ƒƒZdS )é    Né<   c                    sJ   ˆ du rt  tˆ¡S t dt ˆ ¡¡ d¡‰t  ˆ ¡‡ ‡‡fdd„ƒ}|S )aý  
    A decorator to run *func* in a subprocess and assert that it prints
    "success" *success_count* times and nothing on stderr.

    TkAgg tests seem to have interactions between tests, so isolate each test
    in a subprocess. See GH#18261

    The decorated function must be fully self-contained, and thus perform
    all the imports it needs.  Because its source is extracted and run by
    itself, coverage will consider it as not being run, so it should be marked
    with ``# pragma: no cover``
    Nz(?ms)^def .*r   c               	      s°   zDt jtjdˆ› dˆ j› d�gi tj¥ddi¥tt jt jddd�} W n: t j	yb   t
 d¡ Y nJ t jy~   t
 d	¡ Y n.0 d
d„ | j ¡ D ƒr˜J ‚| j d¡ˆks¬J ‚d S )Nz-cÚ
z()Z
MPLBACKENDÚTkAggT)ÚenvÚtimeoutÚstdoutÚstderrÚcheckÚuniversal_newlineszSubprocess timed outz+Subprocess failed to test intended behaviorc                 S   s   g | ]}d |vr|‘qS )ZOpenGL© )Ú.0Úliner   r   ú`/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/matplotlib/tests/test_backend_tk.pyÚ
<listcomp>7   s   ÿz8_isolated_tk_test.<locals>.test_func.<locals>.<listcomp>Úsuccess)Ú
subprocessÚrunÚsysÚ
executableÚ__name__ÚosÚenvironÚ_test_timeoutÚPIPEÚTimeoutExpiredÚpytestZfailÚCalledProcessErrorr   Ú
splitlinesr   Úcount)Úproc©ÚfuncÚsourceÚsuccess_countr   r   Ú	test_func"   s     ù
	z$_isolated_tk_test.<locals>.test_func)	Ú	functoolsÚpartialÚ_isolated_tk_testÚreÚsearchÚinspectÚ	getsourceÚgroupÚwraps)r#   r!   r$   r   r    r   r'      s    r'   r   T)Zskip_on_importerroré   )r#   c               	   C   s®   dd l m}  dd l}ddlm} |  ¡ \}}|jj}| d¡}|j	d d… \}}|||j
jf}	d}
|
D ]B}z"| |j ¡ t|ƒ|	dd|¡ W qf ty¦   tdƒ Y qf0 qfd S )Nr   )Ú_tkagg)é   r0   r0   é   ))éÿÿÿÿr1   r   r1   )r1   r   r   r1   )é   r.   r   r1   )r   r1   r2   r1   )r   r1   r1   r   )r   r1   r3   r.   )r   r3   r1   é   r   )Úmatplotlib.pyplotÚpyplotÚnumpyZmatplotlib.backendsr/   ZsubplotsÚcanvasZ_tkphotoZonesÚshapeÚctypesÚdataZblitÚtkZ
interpaddrÚstrÚ
ValueErrorÚprint)ÚpltÚnpr/   ÚfigÚaxZ
photoimager;   ÚheightÚwidthZdataptrZ	bad_boxesZbad_boxr   r   r   Ú	test_blit>   s"    
þrF   r3   c                     sb   dd l } dd lm‰ g ‰‡ ‡‡fdd„}‡‡fdd„‰ |  ¡ ‰ˆ d|¡ ˆ ¡  ˆr^tdƒ d S )Nr   c                      s4   ˆ  ¡  ˆ ddgddg¡ ˆ ¡  ˆ dˆ ¡ d S )Nr3   r1   r4   é   r   )ÚfigureÚplotÚcloseÚafterr   )Úlegitimate_quitr@   Úrootr   r   Údo_plota   s    z;test_figuremanager_preserves_host_mainloop.<locals>.do_plotc                      s   ˆ   ¡  ˆ d¡ d S )NT)ÚquitÚappendr   )rM   r   r   r   rL   g   s    zCtest_figuremanager_preserves_host_mainloop.<locals>.legitimate_quitr   )Útkinterr5   r6   ÚTkrK   Zmainloopr?   )rQ   rN   r   )rL   r@   rM   r   r   Ú*test_figuremanager_preserves_host_mainloopZ   s    rS   ÚCPythonzZPyPy does not support Tkinter threading: https://foss.heptapod.net/pypy/pypy/-/issues/1929)Úreasonr4   )Zrerunsc                     sœ   dd l } dd l‰dd lm‰ dd l}ddlm‰  |  ¡ }ˆ g d¢g d¢¡ ‡ ‡‡‡fdd„}| 	¡ ‰|j
|dd�}| ¡  ˆjdd	� ˆ ¡  | ¡  d S )
Nr   )Ú"_get_running_interactive_framework)r3   r1   r4   )r3   r1   rG   c                      s2   dˆ ƒ ksˆ  d¡ q ˆ ¡  ˆ ¡ r.tdƒ d S )Nr<   g{®Gáz„?r   )ÚsleeprJ   Úwaitr?   r   ©rV   r@   Zshow_finished_eventÚtimer   r   Útargetƒ   s
    
z6test_figuremanager_cleans_own_mainloop.<locals>.targetT)r[   Údaemon©Úblock)rQ   rZ   r5   r6   Ú	threadingZmatplotlib.cbookrV   rR   rI   ÚEventÚThreadÚstartÚshowÚsetÚjoin)rQ   r_   rM   r[   Úthreadr   rY   r   Ú&test_figuremanager_cleans_own_mainloops   s    rg   c                  C   s`   dd l } | j`| j`dd lm} | ¡ }|jdd� | ¡  |j	j
 ¡  | d¡ | |¡ d S )Nr   Fr]   gš™™™™™¹?)rQ   ZMiscÚupdateZupdate_idletasksr5   r6   rH   rc   Zdrawr8   ZtoolbarZconfigure_subplotsÚpauserJ   )rQ   r@   rB   r   r   r   Útest_never_update’   s    
rj   r1   c                     sZ   dd l m}  ddlm‰  G ‡ fdd„dˆ ƒ}|  ¡ }tdƒ ||j|jjjƒ tdƒ d S )Nr   ©ÚNavigationToolbar2Tkc                       s   e Zd Zdd„ ” jD ƒZdS )z)test_missing_back_button.<locals>.Toolbarc                 S   s   g | ]}|d  dv r|‘qS )r   )ZHomeÚPanZZoomr   )r   Útr   r   r   r   µ   s   ÿz4test_missing_back_button.<locals>.Toolbar.<listcomp>N)r   Ú
__module__Ú__qualname__Z	toolitemsr   rk   r   r   ÚToolbar³   s   rq   r   )	r5   r6   Z!matplotlib.backends.backend_tkaggrl   rH   r?   r8   ÚmanagerZwindow)r@   rq   rB   r   rk   r   Útest_missing_back_button­   s    rs   )N)r%   r*   r   Úplatformr(   r   r   r   r   r'   ÚmarkÚbackendrF   rS   ZskipifÚpython_implementationZflakyrg   rj   rs   r   r   r   r   Ú<module>   s:   
0ÿ