
    daf@                     B   d dl Z d dlZd dlmZ d dlmZ d dlmZmZm	Z	  ej                  d        G d dee j                        Z G d d	ee j                        Z G d
 dee j                        Z G d dee j                        Zedk(  r e j"                          yy)    N)support)	os_helper)AbstractTkTestAbstractDefaultRootTestrequires_tkguic                       e Zd Zd Zd Zy)MiscTestc                     | j                   j                         }| j                  |t               | j	                  d|       | j	                  d|       y Nphotobitmap)rootimage_typesassertIsInstancetupleassertIn)selfr   s     8/root/Python-3.12.4/Lib/test/test_tkinter/test_images.pytest_image_typeszMiscTest.test_image_types   s@    ii++-k51g{+h,    c                 d    | j                   j                         }| j                  |t               y N)r   image_namesr   r   )r   r   s     r   test_image_nameszMiscTest.test_image_names   s$    ii++-k51r   N)__name__
__module____qualname__r   r    r   r   r
   r
   
   s    -2r   r
   c                   $    e Zd Zd Zd Zd Zd Zy)DefaultRootTestc                    | j                  t        t        j                         t        j                         }t        j                         }| j                  |t               | j                  d|       | j                  d|       |j                          t        j                          | j                  t        t        j                         y r   )
assertRaisesRuntimeErrortkinterr   Tkr   r   r   destroyNoDefaultRoot)r   r   r   s      r   r   z DefaultRootTest.test_image_types   s    ,(;(;<zz|))+k51g{+h,,(;(;<r   c                 X   | j                  t        t        j                         t        j                         }t        j                         }| j                  |t               |j                          t        j                          | j                  t        t        j                         y r   )	r#   r$   r%   r   r&   r   r   r'   r(   )r   r   r   s      r   r   z DefaultRootTest.test_image_names$   sl    ,(;(;<zz|))+k51,(;(;<r   c                    | j                  t        t        j                         t        j                         }t        j                         }| j                  |j                  t        j                                |j                          t        j                          | j                  t        t        j                         y r   )
r#   r$   r%   BitmapImager&   r   namer   r'   r(   r   r   images      r   test_image_create_bitmapz(DefaultRootTest.test_image_create_bitmap-   sw    ,(;(;<zz|##%ejj'"5"5"78,(;(;<r   c                    | j                  t        t        j                         t        j                         }t        j                         }| j                  |j                  t        j                                |j                          t        j                          | j                  t        t        j                         y r   )
r#   r$   r%   
PhotoImager&   r   r,   r   r'   r(   r-   s      r   test_image_create_photoz'DefaultRootTest.test_image_create_photo6   sw    ,(:(:;zz|""$ejj'"5"5"78,(:(:;r   N)r   r   r   r   r   r/   r2   r   r   r   r!   r!      s    	===<r   r!   c                   L    e Zd Zed        Zd Zd Zd Zd Zd Z	d Z
d Zd	 Zy
)BitmapImageTestc                 z    t         j                  j                  |        t        j                  dd      | _        y )Nz
python.xbm
imghdrdatasubdirr   
setUpClass__func__r   findfiletestfileclss    r   r:   zBitmapImageTest.setUpClassB   *    !!**3/''\Jr   c                 (   t        j                  d| j                  dd| j                        }| j	                  t        |      d       | j	                  |j                         d       | j	                  |j                         d       | j	                  |j                         d       | j                  d| j                  j                                ~t        j                          | j                  d| j                  j                                y )N::img::testyellowblue)master
foreground
backgroundfiler      )r%   r+   r   r=   assertEqualstrtypewidthheightr   r   r   
gc_collectassertNotInr   r.   s     r   test_create_from_filez%BitmapImageTest.test_create_from_fileG   s    ##M$))/7F)-8 	U]3x0+,mTYY%:%:%<=		(=(=(?@r   c                    t        | j                  d      5 }|j                         }d d d        t        j                  d| j
                  dd      }| j                  t        |      d       | j                  |j                         d       | j                  |j                         d       | j                  |j                         d       | j                  d| j
                  j                                ~t        j                          | j                  d| j
                  j                                y # 1 sw Y   xY w)NrbrB   rC   rD   )rE   rF   rG   datar   rI   )openr=   readr%   r+   r   rJ   rK   rL   rM   rN   r   r   r   rO   rP   )r   frU   r.   s       r   test_create_from_dataz%BitmapImageTest.test_create_from_dataT   s    $--& 	!668D	##M$))/7F)-/ 	U]3x0+,mTYY%:%:%<=		(=(=(?@	 	s   D99Ec                     | j                  |t               | j                  | j                  j	                  |      |       y r   )r   rK   rJ   r   	splitlist)r   actualexpecteds      r   assertEqualStrListz"BitmapImageTest.assertEqualStrListc   s1    fc*,,V4h?r   c           
      |   t        j                  d| j                        }| j                  |d   d       t	        | j
                  d      5 }|j                         }d d d        |j                         | j                  |d   dddd|j                  d	      f       | j                  |j                         d
       | j                  |j                         d
       | j                  |d   d       |j                  |       | j                  |d   dddd|j                  d	      f       y # 1 sw Y   xY w)NrB   rE   rU   z-data {} {} {} {}rT   rU   z-data asciirI   maskdataz-maskdata {} {} {} {})rd   z	-maskdata)r%   r+   r   rJ   rV   r=   rW   	configurer^   decoderM   rN   r   r.   rX   rU   s       r   test_configure_dataz#BitmapImageTest.test_configure_datag   s   ##M$))Dv(;<$--& 	!668D	T"f!("b"dkk'6J K	M+,z*,CD&j 1!,b"b$++g:N O	Q	 	s   D22D;c                    t        j                  d| j                        }| j                  |d   d       |j	                  | j
                         | j                  |d   dddd| j
                  f       | j                  |j                         d       | j                  |j                         d       | j                  |d	   d
       |j	                  | j
                         | j                  |d	   dddd| j
                  f       y )NrB   r`   rH   z-file {} {} {} {}rH   z-filerb   rI   maskfilez-maskfile {} {} {} {})rk   z	-maskfile)	r%   r+   r   rJ   re   r=   r^   rM   rN   rQ   s     r   test_configure_filez#BitmapImageTest.test_configure_filew   s    ##M$))Dv(;<T]]+f!("b"T]] C	E+,z*,CD/j 1!,b"b$-- H	Jr   c                     t        j                  d| j                        }| j                  |d   d       |j	                  d       | j                  |d   d       y )NrB   r`   rG   z-background {} {} {} {}rD   )rG   z-background {} {} {} bluer%   r+   r   rJ   re   rQ   s     r   test_configure_backgroundz)BitmapImageTest.test_configure_background   sR    ##M$))D|,.GH6*|,.IJr   c                     t        j                  d| j                        }| j                  |d   d       |j	                  d       | j                  |d   d       y )NrB   r`   rF   z!-foreground {} {} #000000 #000000rC   )rF   z -foreground {} {} #000000 yellowrn   rQ   s     r   test_configure_foregroundz)BitmapImageTest.test_configure_foreground   sV    ##M$))D|,<	>8,|,;	=r   c                    | j                  t        j                        5  t        j                  d| j                  t
               d d d        t        j                  d| j                        }| j                  t        j                        5  |j                  t
               d d d        y # 1 sw Y   ixY w# 1 sw Y   y xY wNrB   )rE   spamr`   )rt   )r#   r%   TclErrorr+   r   printre   rQ   s     r   test_bug_100814zBitmapImageTest.test_bug_100814   s    w//0 	MdiieL	M##M$))Dw//0 	(OOO'	( 	(	M 	M	( 	(   'B/B;/B8;CN)r   r   r   classmethodr:   rR   rY   r^   rh   rl   ro   rq   rw   r   r   r   r4   r4   @   sD    K KAA@Q JK=(r   r4   c                       e Zd Zed        Zd Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Z edd      d        Z edd      d        Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z y) PhotoImageTestc                 z    t         j                  j                  |        t        j                  dd      | _        y )Nz
python.gifr6   r7   r9   r>   s    r   r:   zPhotoImageTest.setUpClass   r@   r   c                 Z    t        j                  d| j                  | j                        S )NrB   rE   rH   )r%   r1   r   r=   r   s    r   createzPhotoImageTest.create   s$    !!-		'+}}6 	6r   c                 n    t         j                  dk\  r| j                  r|S t        j                  |      S )N333333!@)r%   	TkVersionwantobjects_join)r   argss     r   	colorlistzPhotoImageTest.colorlist   s,    #(8(8K==&&r   c                    t        j                  d|z   d      }t        j                  d| j                  |      }| j                  t        |      d       | j                  |j                         d       | j                  |j                         d       | j                  |j                         d       | j                  |d   d	       | j                  |d
   |       | j                  d| j                  j                                ~t        j                          | j                  d| j                  j                                y )Npython.r6   r7   rB   r~   r   rI   rU   rb   rH   )r   r<   r%   r1   r   rJ   rK   rL   rM   rN   r   r   rO   rP   )r   extr=   r.   s       r   check_create_from_filez%PhotoImageTest.check_create_from_file   s    ##IOLI""=(02U]3w/+,v+v1mTYY%:%:%<=		(=(=(?@r   c                 6   t        j                  d|z   d      }t        |d      5 }|j                         }d d d        t	        j
                  d| j                        }| j                  t        |      d       | j                  |j                         d       | j                  |j                         d       | j                  |j                         d       | j                  |d	   | j                  r|n|j                  d
             | j                  |d   d       | j                  d| j                  j                                ~t        j                           | j#                  d| j                  j                                y # 1 sw Y   XxY w)Nr   r6   r7   rT   rB   )rE   rU   r   rI   rU   latin1rH   rb   )r   r<   rV   rW   r%   r1   r   rJ   rK   rL   rM   rN   r   rf   r   r   rO   rP   )r   r   r=   rX   rU   r.   s         r   check_create_from_dataz%PhotoImageTest.check_create_from_data   s;   ##IOLI(D! 	Q668D	""=(,.U]3w/+,v0@0@-1[[-B	Dv+mTYY%:%:%<=		(=(=(?@	 	s   FFc                 &    | j                  d       y Nppmr   r   s    r   test_create_from_ppm_filez(PhotoImageTest.test_create_from_ppm_file       ##E*r   c                 &    | j                  d       y r   r   r   s    r   test_create_from_ppm_dataz(PhotoImageTest.test_create_from_ppm_data   r   r   c                 &    | j                  d       y Npgmr   r   s    r   test_create_from_pgm_filez(PhotoImageTest.test_create_from_pgm_file   r   r   c                 &    | j                  d       y r   r   r   s    r   test_create_from_pgm_dataz(PhotoImageTest.test_create_from_pgm_data   r   r   c                 &    | j                  d       y Ngifr   r   s    r   test_create_from_gif_filez(PhotoImageTest.test_create_from_gif_file   r   r   c                 &    | j                  d       y r   r   r   s    r   test_create_from_gif_dataz(PhotoImageTest.test_create_from_gif_data   r   r         c                 &    | j                  d       y Npngr   r   s    r   test_create_from_png_filez(PhotoImageTest.test_create_from_png_file       ##E*r   c                 &    | j                  d       y r   r   r   s    r   test_create_from_png_dataz(PhotoImageTest.test_create_from_png_data   r   r   c                    t        j                  d| j                        }| j                  |d   d       t	        | j
                  d      5 }|j                         }d d d        |j                         | j                  |d   | j                  r|n|j                  d             | j                  |j                         d       | j                  |j                         d       y # 1 sw Y   xY w)	NrB   r`   rU   rb   rT   ra   r   rI   )r%   r1   r   rJ   rV   r=   rW   re   r   rf   rM   rN   rg   s       r   rh   z"PhotoImageTest.test_configure_data   s    ""=Cv+$--& 	!668D	T"v0@0@-1[[-B	D+,	 	s   C++C4c                 p   t        j                  d| j                        }| j                  |d   d       |j	                  | j
                  d       | j                  |d   | j                  rdnd       | j                  |j                         d       | j                  |j                         d       y )	NrB   r`   formatrb   r   )rH   r   )r   rI   )	r%   r1   r   rJ   re   r=   r   rM   rN   rQ   s     r   test_configure_formatz$PhotoImageTest.test_configure_format   s    ""=Cx"-T]]59xd6F6F(/4	6+,r   c                 f   t        j                  d| j                        }| j                  |d   d       |j	                  | j
                         | j                  |d   | j
                         | j                  |j                         d       | j                  |j                         d       y )NrB   r`   rH   rb   rj   rI   )r%   r1   r   rJ   re   r=   rM   rN   rQ   s     r   rl   z"PhotoImageTest.test_configure_file   s    ""=Cv+T]]+v6+,r   c                     t        j                  d| j                        }| j                  |d   d       |j	                  d       | j                  |d   d       y )NrB   r`   gammaz1.0g       @)r   z2.0r%   r1   r   rJ   re   rQ   s     r   test_configure_gammaz#PhotoImageTest.test_configure_gamma  sN    ""=Cw/c"w/r   c                    t        j                  d| j                        }| j                  |d   d       | j                  |d   d       |j	                  d       |j	                  d	       | j                  |d   d
       | j                  |d   d       | j                  |j                         d       | j                  |j                         d       y )NrB   r`   rM   0rN      )rM   
   )rN   2010)r%   r1   r   rJ   re   rM   rN   rQ   s     r   test_configure_width_heightz*PhotoImageTest.test_configure_width_height
  s    ""=Cw-x#.b!r"w.x$/+,r   c                    t        j                  d| j                        }| j                  |d   d       |j	                  d       | j                  |d   d       |j	                  d       | j                  |d   d       y )	NrB   r`   paletterb      )r   256z3/4/2r   rQ   s     r   test_configure_palettez%PhotoImageTest.test_configure_palette  ss    ""=Cy)2.$y)51(y)73r   c                    | j                  t        j                        5  t        j                  d| j                  t
               d d d        t        j                  d| j                        }| j                  t        j                        5  |j                  t
               d d d        y # 1 sw Y   ixY w# 1 sw Y   y xY wrs   )r#   r%   ru   r1   r   rv   re   rQ   s     r   rw   zPhotoImageTest.test_bug_100814  s    w//0 	L}TYYUK	L""=Cw//0 	(OOO'	( 	(	L 	L	( 	(rx   c                 *   | j                         }|j                          | j                  |j                         d       | j                  |j	                         d       | j                  |j                  dd      | j                  ddd             y )NrI      r   r   )r   blankrJ   rM   rN   getr   rQ   s     r   
test_blankzPhotoImageTest.test_blank%  si    +,1a$..Aq*ABr   c                 (   | j                         }|j                         }| j                  |j                         d       | j                  |j	                         d       | j                  |j                  dd      |j                  dd             y )NrI   r   r   )r   copyrJ   rM   rN   r   r   r.   image2s      r   	test_copyzPhotoImageTest.test_copy,  sh    ,"-1a%))Aq/:r   c                 2   | j                         }|j                  dd      }| j                  |j                         d       | j                  |j	                         d       | j                  |j                  dd      |j                  dd             |j                  d      }| j                  |j                         d       | j                  |j	                         d       | j                  |j                  dd      |j                  dd             y )N      r   r   r   )r   	subsamplerJ   rM   rN   r   r   s      r   test_subsamplezPhotoImageTest.test_subsample3  s    A&+!,Aq)599Q?;#+!,Aq)599Q?;r   c                    | j                         }|j                  dd      }| j                  |j                         d       | j                  |j	                         d       | j                  |j                  dd      |j                  dd             | j                  |j                  d	d
      |j                  dd             |j                  d      }| j                  |j                         d       | j                  |j	                         d       | j                  |j                  dd      |j                  dd             | j                  |j                  d	d      |j                  dd             y )Nr   r       0   r      r   r   	   r         )r   zoomrJ   rM   rN   r   r   s      r   	test_zoomzPhotoImageTest.test_zoom?  s   Aq!,"-Ar*EIIaO<Ar*EIIaO<A,"-Ar*EIIaO<Ar*EIIaO<r   c                    | j                         }|j                  dd       | j                  |j                  dd      | j	                  ddd             | j                  |j                  dd      | j	                  dt
        j                  d	k\  rd
ndd             | j                  |j                  dd      | j	                  ddd             | j                  |j                  dd      | j	                  ddd             |j                  d       | j                  |j                  dd      | j	                  ddd             | j                  |j                  dd      | j	                  ddd             | j                  |j                  dd      | j	                  ddd             | j                  |j                  dd      | j	                  ddd             y )Nz{red green} {blue yellow})r   r   )tor   r      r      r         ))z#f00z#00ff00)z
#000000fffz#ffffffff0000   )r   putrJ   r   r   r%   r   rQ   s     r   test_putzPhotoImageTest.test_putM  sz   		-&	91a$..a*CD1a'2C2Cs2J303Q8	9 	1a$..As*CD1a$..c1*EF		HI1a$..a*CD1a$..C*CD1a$..As*CD1a$..c1*EFr   c                    | j                         }| j                  |j                  dd      | j                  ddd             | j                  |j                  dd      | j                  ddd             | j                  |j                  dd      | j                  ddd             | j	                  t
        j                  |j                  dd       | j	                  t
        j                  |j                  dd       | j	                  t
        j                  |j                  d	d       | j	                  t
        j                  |j                  dd	       y )
Nr   r   >   t      r      rI   )r   rJ   r   r   r#   r%   ru   rQ   s     r   test_getzPhotoImageTest.test_get]  s    1a$..S#*FG1a$..Aq*AB2r*DNN1a,CD'**EIIr1='**EIIq"='**EIIr2>'**EIIr2>r   c                 $   t         j                  }dd l}|j                         d   t         j                  }| j                         }| j                  t         j                  |       |j                  |       t        j                  d| j                  d|      }| j                  t        |      d       | j                  |j                         d       | j                  |j                         d       | j                  |j!                         d       | j                  |j#                  dd      |j#                  dd             | j                  |j#                  dd      |j#                  dd             |j                  |d	d
       t        j                  d| j                  d	|      }| j                  t        |      d       | j                  |j                         d       | j                  |j                         d       | j                  |j!                         d       | j                  |j#                  dd      |j#                  dd             | j                  |j#                  dd      |j#                  dd             y )Nr   z::img::test2r   )rE   r   rH   r   rI   r   r   r   )r   r   r   r   )r   from_coordsz::img::test3r   r   r   r   r   r   )r   TESTFNlocale	getlocaleTESTFN_ASCIIr   
addCleanupunlinkwriter%   r1   r   rJ   rK   rL   rM   rN   r   )r   filenamer   r.   r   image3s         r   
test_writezPhotoImageTest.test_writeg  s   ##a ( --H	(((3H##N499+0)13 	Vn50,"-Aq)599Q?;B*EIIb!,<=HUE##N499+0)13 	Vn50+!,Aq)599Q?;Aq)599Q?;r   c                    | j                         }| j                  |j                  dd      d       | j                  |j                  dd      d       |j                  ddd       | j                  |j                  dd      d       |j                  ddd       | j                  |j                  dd      d       y )Nr   Tr   r   F)r   rJ   transparency_gettransparency_setrQ   s     r   test_transparencyz PhotoImageTest.test_transparency  s    //15t<//15u=q!T*//15t<q!U+//15u=r   N)!r   r   r   ry   r:   r   r   r   r   r   r   r   r   r   r   r   r   r   rh   r   rl   r   r   r   rw   r   r   r   r   r   r   r   r   r   r   r   r{   r{      s    K K6'AA$++++++ A+ + A+ +	---0	-4(C;
<=G ?<>>r   r{   __main__)unittestr%   testr   test.supportr   test.test_tkinter.supportr   r   r   requiresTestCaser
   r!   r4   r{   r   mainr   r   r   <module>r     s       " Z Z    
2~x00 
2&<-x/@/@ &<RY(nh&7&7 Y(xq>^X%6%6 q>h zHMMO r   