+
    ,i"                     4   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
 ^<tRR lt]! ^R7      R 4       t]! ^R7      R 4       t]P                  P!                  ]P"                  ! 4       R8g  R	R
7      ]P                  P%                  ^R7      ]! ^R7      R 4       4       4       t]P                  P%                  ^R7      ]! ^ R7      R 4       4       t]! ^R7      R 4       t]! ^R7      R 4       t]! ^R7      R 4       t]! ^R7      R 4       tR# )    N)_c_internal_utils)subprocess_run_helperc                
  a a Sf   \         P                  ! \        S 4      # R\        P                  9   d   S# \
        P                  P                  \        P                  P                  R4      '       * RR7      \
        P                  P                  \        P                  R8H  ;'       d    \        P                  ! 4       '       * RR7      \
        P                  P                  R\        P                  9   ;'       g    R\        P                  9   ;'       d6    \        P                  R	8H  ;'       d    \        P                   R
,          R8  RR7      \         P"                  ! S4      VV 3R l4       4       4       4       pV# )z
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
MPL_TEST_ESCAPE_HATCHtkinterzmissing tkinterreasonlinuxz$DISPLAY is unsetTF_BUILDGITHUB_ACTIONdarwin:N   Nz%Tk version mismatch on Azure macOS CIc            	        <a \         P                  ! R 4        \        S\        \	        RRR7      R7      p . ROpV P
                  P                  4        Uau. uFG  o\        ;QJ d    V3R lV 4       F  '       d   K   RM	  RM! V3R lV 4       4      '       g   KE  SNKI  	  up'       d   Q hV P                  P                  R4      S8X  g   Q hR# u upi   \        P                   d    \         P                  ! R	4        R# \        P                   d<   p\         P                  ! R
\        TP
                  4      ,           4        Rp?R# Rp?ii ; i)r   TkAgg1)
MPLBACKENDr   )timeout	extra_envc              3   ,   <"   T F	  qS9  x  K  	  R # 5iN ).0msglines   & B/usr/lib/python3/dist-packages/matplotlib/tests/test_backend_tk.py	<genexpr>7_isolated_tk_test.<locals>.test_func.<locals>.<genexpr>E   s     H-3$-s   FTsuccesszSubprocess timed outz,Subprocess failed to test intended behavior
N)OpenGLz!CFMessagePort: bootstrap_registerz%/usr/include/servers/bootstrap_defs.h)pytestimportorskipr   _test_timeoutdictstderr
splitlinesallstdoutcount
subprocessTimeoutExpiredfailCalledProcessErrorstr)procignored_linesr   efuncsuccess_counts     ` r   	test_func$_isolated_tk_test.<locals>.test_func!   s   " 	I&	A(mt&c8CDDFM)-)?)?)A J)A3H-H333H-HH )A J J J J;;$$Y/=@@@J (( 	0KK./,, 	)KKGahh-( ) )	)s;   C C(C?CC+EEE0EE)      )	functoolspartial_isolated_tk_testosenvironr    markskipif	importlibutil	find_specsysplatformr   xdisplay_is_validxfailversion_infowraps)r2   r1   r3   s   ff r   r9   r9      sA    |  !2MBB"**,[[NN$$Y//    [[MM(9(K(K(M$M"   [[	rzz	!	B	B_

%B 	D 	D 	D 	D%(%5%5b%9G%C6  
 __TA 		A2     )r2   c            	         ^ RI Hp  ^ RIp^ RIp^ RIHpHp V P                  4       w  rVVP                  P                  pVP                  RVP                  R7      pRp	V	 FE  p
 VP                  VP                  P                  4       \        V4      VVP                   RV
4       KG  	  V P'                  V4       VP                  WxR4       R#   \"         d    \%        R4        K  i ; i)r   N)_backend_tk_tkagg)dtyper   )   rL   rL   ))r   r   r   )r   r   r   r   )      r   r   )r   r   rM   r   )r   r   r   r   )r   r   rN   rO   )r   rN   r   r5   )matplotlib.pyplotpyplotnumpy!matplotlib.backends.backend_tkaggmatplotlib.backendsrI   rJ   subplotscanvas_tkphotoonesuint8blittk
interpaddrr-   TK_PHOTO_COMPOSITE_OVERLAY
ValueErrorprintclose)pltnp
matplotlibrI   rJ   figax
photoimagedata	bad_boxesbad_boxs              r   	test_blitrj   K   s    #,7llnGC$$J779BHH7-DI 	KK((*C
OT11<J  IIcNZ|4  	)	s   $ACC('C(c                     aaaa ^ RI p ^ RIHo . oVVV3R lpVV3R loV P                  4       oSP	                  ^ V4       SP                  4        S'       d   \        R4       R# R# )r   Nc                     < SP                  4        SP                  ^^.^^.4       SP                  4        SP                  ^ S 4       R# )rN   N)figureplotr`   after)legitimate_quitra   roots   r   do_plot;test_figuremanager_preserves_host_mainloop.<locals>.do_ploto   s9    

!Q!Q 		

1o&rG   c                  J   < S P                  4        SP                  R 4       R# TN)quitappend)rq   r   s   r   rp   Ctest_figuremanager_preserves_host_mainloop.<locals>.legitimate_quitu   s    		trG   r   )r   rP   rQ   Tkro   mainloopr_   )r   rr   rp   ra   rq   r   s     @@@@r   *test_figuremanager_preserves_host_mainloopr{   i   sL    #G' ::<DJJq'MMOi rG   CPythonzZPyPy does not support Tkinter threading: https://foss.heptapod.net/pypy/pypy/-/issues/1929r   )rerunsc                  f  aaaa ^ RI p ^ RIo^ RIHo ^ RIp^ RIHo V P                  4       pSP                  . RO. RO4       VVVV3R lpVP                  4       oVP                  VRR7      pVP                  4        SP                  RR7       SP                  4        VP                  4        R# )	r   N)"_get_running_interactive_frameworkc                     < R S ! 4       8X  g   SP                  R4       K  SP                  4        SP                  4       '       d   \        R4       R# R# )r[   g{Gz?r   N)sleepr`   waitr_   )r   ra   show_finished_eventtimes   r   target6test_figuremanager_cleans_own_mainloop.<locals>.target   s?    <>>JJsO		##%%) &rG   T)r   daemonblockrN   r   r5   )rN   r      )r   r   rP   rQ   	threadingmatplotlib.cbookr   ry   rn   EventThreadstartshowsetjoin)	r   r   rq   r   threadr   ra   r   r   s	        @@@@r   &test_figuremanager_cleans_own_mainloopr      s     #C::<DHHY	"  $//+VD9F
LLNHH4H
KKMrG   c                     ^ RI p V P                  =V P                  =^ RIHp VP                  4       pVP                  RR7       VP                  4        VP                  P                  P                  4        VP                  P                  4       P                  ^dVP                  V4       VP                  RR7       R# )r   NFr   T)r   Miscupdateupdate_idletasksrP   rQ   rm   r   drawrV   toolbarconfigure_subplotsget_tk_widgetro   r`   )r   ra   rd   s      r   test_never_updater      s     %#
**,CHH5HHHJJJ))+JJ$$S#))S9 HH4HrG   c                     a ^ RI Hp  ^ RIHo  ! V3R lRS4      pV P	                  4       p\        R4       V! VP                  VP                  P                  P                  4       \        R4       R# )r   N)NavigationToolbar2Tkc                   |   < ] tR t^t ZP                   U u. uF  p V ^ ,          R9   g   K  V NK  	  up tRtR# u up i ))test_missing_back_button.<locals>.Toolbarr   N)HomePanZoom)__name__
__module____qualname____firstlineno__	toolitems__static_attributes__)tr   s   0r   Toolbarr      s:     4 > > 6 >1qT44 Q > 6	 6s   99r   r   )	rP   rQ   rS   r   rm   r_   rV   managerwindow)ra   r   rd   r   s      @r   test_missing_back_buttonr      sQ    #F6& 6
 **,C	)CJJ

**112	)rG   c                  N   ^ RI Hp  ^ RIHp V P	                  4       pRpVP                  VRR7      ;_uu_ 4        VP                  P                  P                  P                  4       p\        P                  ! R4       VR8X  g   Q h\        R4       RRR4       VP                  VRR7      ;_uu_ 4        VP                  P                  P                  P                  4       pVe   Q h\        R4       RRR4       R#   + '       g   i     Lu; i  + '       g   i     R# ; i)r   N)mockz$tkinter.filedialog.asksaveasfilenamez
foobar.png)return_valuer    )rP   rQ   unittestr   rm   patchrV   r   r   save_figurer:   remover_   )ra   r   rd   propfnames        r   test_save_figure_returnr      s    #
**,C1D	D|	4	4

""**668
		,$$$i	 
5
 
Dr	*	*

""**668}}i 
+	* 
5	4
 
+	*	*s   AD 6A D D	D$	c                  D  aaaa ^ RI p ^ RIHo . oVVVV3R lpV P                  4       oSP	                  4       oSP                  . RO4       SP                  ^ SP                  4       SP                  ^dV4       SP                  4        S'       d   \        R4       R# R# )r   Nc                    < SP                   P                  4       p V P                  4       '       g   V P                  4        V P	                  4       V 8X  d   SP                  R 4       SP                  4        SP                  4        R# ru   )rV   r   winfo_viewablewait_visibilityfocus_lastforrw   r`   destroy)tkcanvasrd   ra   rq   r   s    r   check_focus&test_canvas_focus.<locals>.check_focus   sa    ::++-&&(($$& !!#x/NN4 		rG   r   r   )
r   rP   rQ   ry   rm   rn   ro   r   rz   r_   )r[   r   rd   ra   rq   r   s     @@@@r   test_canvas_focusr      su    #G
 
 557D
**,CHHYJJq#((JJsK MMOi rG   c                     aaaa ^ RI p ^ RIHoHo ^ RIHo ^ RIHo V P                  4       pVVVV3R lpV! V4       \        R4       VP                  RRR	R
7       V! V4       \        R4       R# )r   N)FigureCanvasTkAggr   )key_press_handler)Figurec                   < S! 4       pVP                  4       pVP                  . R
O4       S! WR7      pVP                  4        VP                  RS4       VP	                  4       P                  RRR7       S! W0RR7      pVP                  RRR7       VP	                  4       P                  4        VP                  4        R	# )rN   )masterkey_press_eventTboth)expandfillF)pack_toolbarxNr   )add_subplotrn   r   mpl_connectr   packforget)	r   rd   re   rV   r   r   r   r   r   s	   &    r   test_figure#test_embedding.<locals>.test_figure   s    h__
	"36,.?@##4f#=&vEJDs+%%'rG   r   zsky bluezmidnight bluewhite)
backgroundselectColor
foreground)r   rS   r   r   matplotlib.backend_basesr   matplotlib.figurer   ry   r_   tk_setPalette)r[   rq   r   r   r   r   r   s      @@@@r   test_embeddingr      sd    1:(557D   	)
 	*/")  +	)rG   r   )r7   r>   r:   rB   r)   rA   r    rc   r   matplotlib.testingr   r"   r9   rj   r{   r<   r=   python_implementationflakyr   r   r   r   r   r   r   rG   r   <module>r      s_     	   
  ( 4 7t #5 $5: # $. H224	AO  P !# $ P
2 !# $ , # $ # $  # $8 #" $"rG   