
    iW                         d dl Z d dlZd dlZd ej                         k(  Z	 d dlmZ d dlZd a	d Z
 G d dej                        Zedk(  r ej                          yy# e$ r Y =w xY w)    NPyPy)arrinterc                      t         dz  a y )N   )
quit_count     `/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/pygame/tests/base_test.py	quit_hookr      s    !OJr	   c                   6   e Zd Zd Zd Zd Z G d d      Zd Zd Zd Z	e
j                  rd	d
lmZ d Z ej                   e
j                   d       ej                   ed      d               Z ej                   e
j                   d      d        Z ej                   e
j                   d       ej                   ed      d               Z ej                   exs e
j                   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!y )!BaseModuleTestc                 ,    t        j                          y N)pygamequitselfs    r
   tearDownzBaseModuleTest.tearDown   s    r	   c                     t        j                         }t         j                  t         j                  f}| j	                  ||       y)z"Ensure the SDL byte order is validN)r   get_sdl_byteorder
LIL_ENDIAN
BIG_ENDIANassertIn)r   
byte_orderexpected_optionss      r
   test_get_sdl_byteorderz%BaseModuleTest.test_get_sdl_byteorder   s6    --/
"--v/@/@Aj"23r	   c                 ^    | j                  t        t        j                               d       y)zEnsure the SDL version is valid   N)assertEquallenr   get_sdl_versionr   s    r
   test_get_sdl_versionz#BaseModuleTest.test_get_sdl_version#   s     V3356:r	   c                       e Zd Zd Zy)BaseModuleTest.ExporterBasec                    dd l }t        |      }|| _        t        |      | _        d}|D ]  }||z  }	 ||z  | _        |j                  | j
                        | _        || _        |g|z  }t        |dz
  dd      D ]  }	||	   ||	   z  ||	dz
  <    t        |      | _
        |j                  | j                        df| _        | j                  dk(  rd}
nt        j                  dk(  rd}
nd}
|
|z   t        | j                        z   | _        y )	Nr   r   F|big><)ctypesr    ndimtupleshapesizecreate_string_bufferparentitemsizerangestrides	addressofdatasys	byteorderstrtypestr)r   r.   typecharr2   r+   r,   	array_lendr4   ir8   s              r
   __init__z$BaseModuleTest.ExporterBase.__init__(   s   u:DDIuDJI Q	 9,DI 55dii@DK$DMj4'G4!8Q+ 7!(eAh!6A7 >DL((5u<DI}}!	%'		$x/#dmm2DDDLr	   N)__name__
__module____qualname__r?   r   r	   r
   ExporterBaser$   '   s    	Er	   rC   c                 `   | j                  |j                  |j                         |j                  }| j                  |d   |j                         | j                  |d   |j
                         | j                  |d   |j                         | j                  |d   |j                         y )Nr:   r.   r4   r6   )r   lengthr/   __array_interface__r:   r.   r4   r6   )r   proxyobjifaces       r
   
assertSamezBaseModuleTest.assertSameA   s    sxx0))y)3;;7w3y)3;;7v1r	   c                 0   ddl m}  G d d| j                        g d}t        dt	        |            D ])  } |d| dd      } ||      }| j                  ||       + d}|d| }d	D ]-  }d
D ]&  } |||      } ||      }| j                  ||       ( / dD ]&  } |d|      } ||      }| j                  ||       ( dd ldd l}	 G d dt               G d dt               G fdd      }
 |
ddd      } ||      }| j                  |j                         |j                  }| j                  |j                                |j                          |	j                          | j!                  |j                                y )Nr   BufferProxyc                   4    e Zd Zd Z ee      Z ed       Zy)HBaseModuleTest.test_PgObject_GetBuffer_array_interface.<locals>.Exporterc                 b    d| j                   | j                  | j                  | j                  dS )Nr   )versionr:   r.   r4   r6   r:   r.   r4   r6   r   s    r
   get__array_interface__z_BaseModuleTest.test_PgObject_GetBuffer_array_interface.<locals>.Exporter.get__array_interface__M   s+     #||!ZZ#|| II r	   c                      y r   r   r   s    r
   <lambda>zQBaseModuleTest.test_PgObject_GetBuffer_array_interface.<locals>.Exporter.<lambda>X       r	   N)r@   rA   rB   rS   propertyrF   __array_struct__r   r	   r
   ExporterrO   L   s!     #++A"B'(9:r	   rY      r            r   r>   r[   r>   ur   r[         rb   rc   fc                       e Zd Zy)KBaseModuleTest.test_PgObject_GetBuffer_array_interface.<locals>.NoDictErrorN)r@   rA   rB   r   r	   r
   NoDictErrorrg   x   s    r	   rh   c                       e Zd ZdZy)FBaseModuleTest.test_PgObject_GetBuffer_array_interface.<locals>.WRDictzWeak referenceable dictN)r@   rA   rB   __doc__r   r	   r
   WRDictrj   {   s    )r	   rl   c                   <    e Zd Z fdZ ee      Zd ZfdZy)IBaseModuleTest.test_PgObject_GetBuffer_array_interface.<locals>.Exporter2c                      j                  |             | _        j                  | j                        | _        | j                  S r   )rS   r=   refdict_ref)r   rY   rl   weakrefs    r
   get__array_interface__2zaBaseModuleTest.test_PgObject_GetBuffer_array_interface.<locals>.Exporter2.get__array_interface__2   s7     ? ? EF 'DFF 3vvr	   c                     d | _         y r   )r=   r   s    r
   	free_dictzSBaseModuleTest.test_PgObject_GetBuffer_array_interface.<locals>.Exporter2.free_dict   s	    r	   c                 T    	 | j                         d uS # t        $ r	  d      w xY w)Nz__array_interface__ is unread)rq   AttributeError)r   rh   s    r
   is_dict_alivezWBaseModuleTest.test_PgObject_GetBuffer_array_interface.<locals>.Exporter2.is_dict_alive   s7    G==?$66% G%&EFFGs    'N)r@   rA   rB   rs   rW   rF   ru   rx   )rY   rh   rl   rr   s   r
   	Exporter2rn      s!    
 #++B"CGr	   ry   )r[   rb   r`   rb   )pygame.bufferproxyrM   rC   r3   r    rJ   rr   gcRuntimeErrordictassertRaisesrx   rE   
assertTrueru   collectassertFalse)r   rM   _shaper,   ovr.   r;   r2   r{   ry   rE   rY   rh   rl   rr   s               @@@@r
   'test_PgObject_GetBuffer_array_interfacez6BaseModuleTest.test_PgObject_GetBuffer_array_interfaceI   s   2	;t(( 	; "!S[) 	"D$a0AAAOOAq!	" q" 	&H( &UHh7N1%&	&
  	"HX.AAAOOAq!	"  		, 		T 	
	G 	G 	G" fc1%N+q7)*	


*+r	   c                   
 ddl m
  G 
fdd| j                        }g d}t        dt	        |            D ])  } ||d| dd      } 
|      }| j                  ||       + d}|d| }d	D ]-  }d
D ]&  } ||||      } 
|      }| j                  ||       ( / dD ]&  } ||d|      } 
|      }| j                  ||       ( 	 ddlm}	  ||      }| j                   |	|j                        d       y # t        $ r Y y w xY w)Nr   rL   c                   J     e Zd Z fdZd Z ee      Z ed       Z xZS ):BaseModuleTest.test_GetView_array_struct.<locals>.Exporterc                 V    t         |   |||        | j                        | _        y r   )superr?   __dict__view)r   r.   r;   r2   rM   	__class__s       r
   r?   zCBaseModuleTest.test_GetView_array_struct.<locals>.Exporter.__init__   s$     (;'6	r	   c                 .    | j                   j                  S r   )r   rX   r   s    r
   get__array_struct__zNBaseModuleTest.test_GetView_array_struct.<locals>.Exporter.get__array_struct__   s    yy111r	   c                      y r   r   r   s    r
   rU   zCBaseModuleTest.test_GetView_array_struct.<locals>.Exporter.<lambda>   rV   r	   )	r@   rA   rB   r?   r   rW   rX   rF   __classcell__)r   rM   s   @r
   rY   r      s'    72  ((;<"*+<"=r	   rY   rZ   r   r>   r[   r_   ra   rd   re   )getrefcount)rz   rM   rC   r3   r    rJ   r7   r   r   rX   ImportError)r   rY   r   r,   r   r   r.   r;   r2   r   rM   s             @r
   test_GetView_array_structz(BaseModuleTest.test_GetView_array_struct   s7   2
	>t(( 
	> "!S[) 	"D$a0AAAOOAq!	" q" 	&H( &UHh7N1%&	&
  	"HX.AAAOOAq!	"	A'
 (3A[););<a@  		s   	C< <	DDr   )buftoolsc                    | j                   }|j                  }| j                  |j                  |j                          |||j
                        }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  d u        y r   )r   Importerr   rE   r    PyBUF_RECORDS_ROreadonlyformatr2   r,   r.   r4   r   
suboffsets)r   rG   expr   r   imps         r
   NEWBUF_assertSamez BaseModuleTest.NEWBUF_assertSame   s    ==$$sww/uh778s||4SZZ0s||4388,CII.ckk2$./r	   znewbuf not implementedzpypy no likeyc                 &   ddl m} | j                  j                  }g d}t	        dt        |            D ](  } ||d| d      } ||      }| j                  ||       * d}|d| }dD ]%  } |||      } ||      }| j                  ||       ' y )Nr   rL   rZ   r   =hr[   )bBr   z=Hz=iz=Iz=qz=Qre   r=   1hz=1hx1x2x3x4x5x6x7x8x9x)rz   rM   r   rY   r3   r    r   )	r   rM   rY   r   r,   r   r   r.   r   s	            r
   test_newbufzBaseModuleTest.test_newbuf   s     	3==))!!S[) 	)D$.AAA""1a(	) q
 	)F0 'AAA""1a(5	)r	   c                     ddl m} ddlm} ddlm}m} | j                  }|j                  }|j                  }|j                  }dD ]-  }	 |d|	d      }
 ||
      }| j                  t        |||       / y )	Nr   rL   )BufferMixin)r0   r5   ) =1 2hz=2h0x11xz=!zh z hhh?)r   r[   )r2   )rz   rM   pygame.newbufferr   r+   r0   r5   r   rY   r   PyBUF_FORMATr~   
ValueError)r   rM   r   r0   r5   r   rY   r   r   r   r   r   s               r
   test_bad_formatzBaseModuleTest.test_bad_format   sv    20:==$$$$,,
 	EF 4!4CC Aj(A|D#	Er	   zfails on pypyc                 p   ddl m} t        j                         t        j                  k(  }|rdnd\  }}| j
                  }|j                  } |dddd      } |||j                        }| j                  |j                  d       | j                  |j                  d u        | j                  |j                  |j                         | j                  |j                  d	       | j                  |j                  d u        | j                  |j                   d u        | j                  |j"                  d u        | j%                  |j&                         | j                  |j(                  d
        |||j*                        }| j                  |j                  d       | j                  |j                  d u        | j                  |j                  |j                         | j                  |j                  d	       | j                  |j                  d u        | j                  |j                   d u        | j                  |j"                  d u        | j%                  |j&                         | j                  |j(                  d
        |||j,                        }| j                  |j                  d       | j                  |j                  d u        | j                  |j                  |j                         | j                  |j                  d	       | j                  |j                  d       | j                  |j                   d u        | j                  |j"                  d u        | j%                  |j&                         | j                  |j(                  d
        ||dz   dddd      } |||j.                        }| j                  |j                  d       | j                  |j                  d u        | j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                   d       | j                  |j"                  d u        | j%                  |j&                         | j                  |j(                  d        |||j0                        }| j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                   d       | j                  |j"                  d u        | j%                  |j&                         | j                  |j(                  d       | j3                  t4        |||j                         | j3                  t4        |||j,                         | j3                  t4        |||j6                         | j3                  t4        |||j8                         | j3                  t4        |||j:                         | j3                  t4        |||j<                         | j3                  t4        |||j                         | j3                  t4        |||j,                         | j3                  t4        |||j6                         | j3                  t4        |||j8                         | j3                  t4        |||j:                         | j3                  t4        |||j<                          ||dz   dddd      } |||j0                        }| j                  |j                  d       | j                  |j                  |dz          | j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                   d       | j                  |j"                  d u        | j                  |j&                         | j                  |j(                  d       | j3                  t4        |||j>                         y )Nr   rL   r*   r)   r)   r*   z|u4
   r[   )	   F)r:   r.   r6   rb   r   r[   i2r\   r      r[   )*   FrR   d   r   r   r   r\   r   x   r   r[   )@B Tr   hi,  r   ) rz   rM   r   r   r   r   r   PyBUF_SIMPLEr   r,   r   r   r    rE   r2   r.   r4   r   r   r   bufPyBUF_WRITABLEPyBUF_NDPyBUF_STRIDESPyBUF_FULL_ROr~   BufferErrorPyBUF_C_CONTIGUOUSPyBUF_F_CONTIGUOUSPyBUF_ANY_CONTIGUOUSPyBUF_CONTIG
PyBUF_FULL)	r   rM   is_lil_endianfsysfrevr   r   ar   s	            r
    test_PgDict_AsBuffer_PyBUF_flagsz/BaseModuleTest.test_PgDict_AsBuffer_PyBUF_flags  s    	3002f6G6GG#0Zj
d==$$D
 Q--.#D())Q'4(		T)*,-$"Q//0#D())Q'4(		T)*,-$"Q))*#D())Q''*		T)*,-$"$; "#	
 Q../#D()$Q''*G,,-$#Q../#4($Q''*G,,-$#+xH4I4IJ+xH4E4EF+xH4O4OP+xH4O4OP+xH4Q4QR+xH4I4IJ+xH4I4IJ+xH4E4EF+xH4O4OP+xH4O4OP+xH4Q4QR+xH4I4IJ$;#''	
 Q../#4#:.$Q'*-L1,-

#(+xH4G4GHr	   znewbuf with ctypesc                    ddl m} dd l}t        j                         t        j
                  k(  }|rdnd\  }}| j                  }|j                  }t        j                  dd|j                  |j                              } ||      }	 ||	|j                        }
| j                  |
j                  d       | j                  |
j                   d u        | j                  |
j"                  |j"                         | j                  |
j$                  |j$                         | j                  |
j&                  d u        | j                  |
j(                  d u        | j                  |
j*                  d u        | j-                  |
j.                         | j                  |
j0                  |j2                          ||	|j4                        }
| j                  |
j                  d       | j                  |
j                   d u        | j                  |
j"                  |j"                         | j                  |
j$                  |j$                         | j                  |
j&                  d u        | j                  |
j(                  d u        | j                  |
j*                  d u        | j-                  |
j.                         | j                  |
j0                  |j2                          ||	|j6                        }
| j                  |
j                  |j8                         | j                  |
j                   d u        | j                  |
j"                  |	j:                         | j                  |
j$                  |j$                         | j                  |
j&                  |j&                         | j                  |
j(                  d u        | j                  |
j*                  d u        | j-                  |
j.                         | j                  |
j0                  |j2                         t        j                  dd	d
d      } ||      }	 ||	|j<                        }
| j                  |
j                  |j8                         | j                  |
j                   d u        | j                  |
j"                  |j"                         | j                  |
j$                  |j$                         | j                  |
j&                  |j&                         | j                  |
j(                  |j(                         | j                  |
j*                  d u        | j-                  |
j.                         | j                  |
j0                  |j2                          ||	|j>                        }
| j                  |
j                  |j8                         | j                  |
j                   d       | j                  |
j"                  |j"                         | j                  |
j$                  |j$                         | j                  |
j&                  |j&                         | j                  |
j(                  |j(                         | j                  |
j*                  d u        | j-                  |
j.                         | j                  |
j0                  |j2                         | jA                  tB        ||	|j                         | jA                  tB        ||	|j4                         | jA                  tB        ||	|j4                         | jA                  tB        ||	|j6                         | jA                  tB        ||	|jD                         | jA                  tB        ||	|jF                         | jA                  tB        ||	|jH                         | jA                  tB        ||	|jJ                         | jA                  tB        ||	|j                         | jA                  tB        ||	|j6                         | jA                  tB        ||	|jD                         | jA                  tB        ||	|jF                         | jA                  tB        ||	|jH                         | jA                  tB        ||	|jJ                         t        j                  dd	d
dt        jL                        } ||      }	 ||	|j>                        }
| j                  |
j                  |j8                         | j                  |
j                   |dz          | j                  |
j"                  |j"                         | j                  |
j$                  |j$                         | j                  |
j&                  |j&                         | j                  |
j(                  |j(                         | j                  |
j*                  d u        | j                  |
j.                         | j                  |
j0                  |j2                         | jA                  tB        ||	|jN                         y )Nr   rL   r   r   r   re   )typekindr2   r   r>   r[   r   )r   r2   r4   r   r   r   )r   r2   r4   flagsr   )(rz   rM   r+   r   r   r   r   r   r   rY   sizeofc_doubler   r   r,   r   r   r    r2   r.   r4   r   r   r   r   r6   r   r   ndrE   r   r   r~   r   r   r   r   r   PAI_ALIGNEDr   )r   rM   r+   r   r   r   r   r   er   r   s              r
   "test_PgObject_AsBuffer_PyBUF_flagsz1BaseModuleTest.test_PgObject_AsBuffer_PyBUF_flags  sa   2002f6G6GG#0Zj
d==$$cFMM&//,J
 NQ--.#D()&QZZ04(		T)*,-$'Q//0#D()&QZZ04(		T)*,-$'Q))*&D())QZZ0!''*		T)*,-$'gaQNQ../&D()&QZZ0!''*AII.,-$'Q../&4(&QZZ0!''*AII.,-$'+xH4I4IJ+xH4K4KL+xH4K4KL+xH4E4EF+xH4O4OP+xH4O4OP+xH4Q4QR+xH4I4IJ+xH4I4IJ+xH4E4EF+xH4O4OP+xH4O4OP+xH4Q4QR+xH4I4IJ &&
 NQ../&4#:.&QZZ0!''*AII.,-

#'+xH4G4GHr	   c                 X    ddl m}  |d      }| j                  t        t        |d       y )Nr   rL   r   rE   )rz   rM   r~   r   getattr)r   rM   bps      r
   !test_PgObject_GetBuffer_exceptionz0BaseModuleTest.test_PgObject_GetBuffer_exception  s"    2^*gr8<r	   c                    | j                  t        j                         d       | j                  t        j                  j                         d       dt        j
                  v r.| j                  t        j                  j                         d       dt        j
                  v r.| j                  t        j                  j                         d       dd l} |j                         j                  d      ry 	 | j                  t        j                  t        j                  j                         y # t        $ r Y y w xY w)	Nzpygame shouldn't be initializedz display shouldn't be initializedpygame.mixerzmixer shouldn't be initializedpygame.fontzinit shouldn't be initializedr   Darwin)r   r   get_initdisplayr7   modulesmixerfontplatformsystem
startswithr~   errorscrapgetNotImplementedError)r   r   s     r
   not_init_assertionsz"BaseModuleTest.not_init_assertions  s    *,MN0024VWS[[(V\\2246VWCKK'V[[1135TU 	8??''1	fllFLL,<,<=" 		s   98D2 2	D>=D>c                    | j                  t        j                                | j                  t        j                  j                                dt        j
                  v r-| j                  t        j                  j                                dt        j
                  v r.| j                  t        j                  j                                y y )Nr   r   )r   r   r   r   r7   r   r   r   r   s    r
   init_assertionszBaseModuleTest.init_assertions  s}    )*//12S[[(OOFLL1134CKK'OOFKK0023 (r	   c                     | j                          t        j                          | j                          t        j                          | j                          y r   )r   r   initr   r   r   s    r
   test_quit__and_initz"BaseModuleTest.test_quit__and_init  sB     	  " 	 	 	 	  "r	   c                     | j                  t        d       t        j                          t        j                  t
               t        j                          | j                  t        d       y)z5Ensure that a registered function is called on quit()r   r   N)r   r   r   r  register_quitr   r   r   s    r
   test_register_quitz!BaseModuleTest.test_register_quit#  sB    Q'Y'Q'r	   c                    t        j                         }t        j                  d       | j                  t        j                         d       t        j                  d       | j                  t        j                         d       y Nhir   r   	get_error	set_errorr   r   r   s     r
   test_get_errorzBaseModuleTest.test_get_error-  s`     ))+T2))+R0r	   c                    t        j                         }t        j                  d       | j                  t        j                         d       t        j                  d       | j                  t        j                         d       y r  r	  r  s     r
   test_set_errorzBaseModuleTest.test_set_error?  s^    ))+T2))+R0r	   c                 v    t        j                  d       | j                  dt        j                                y )Nu   你好)r   r  r   r
  r   s    r
   test_unicode_errorz!BaseModuleTest.test_unicode_errorG  s)    "6#3#3#56r	   c                     | j                          d}d}t        j                         \  }}| j                          | j	                  ||       | j                  ||       y)zEnsures init() works properly.r[   r   N)r   r   r  r   assertGreaterEqualr   )r   expected_min_passesexpected_failspassesfailss        r
   	test_initzBaseModuleTest.test_initK  s[     	  "   (;</r	   c                 J    | j                  t        j                                y r   )r   r   r   r   s    r
   test_get_initzBaseModuleTest.test_get_init\  s    *+r	   c                 r    t        j                          | j                  t        j                                y r   )r   r  r   r   r   s    r
   test_get_init__after_initz(BaseModuleTest.test_get_init__after_init`  s    )*r	   c                     t        j                          t        j                          | j                  t        j                                y r   )r   r  r   r   r   r   s    r
   test_get_init__after_quitz(BaseModuleTest.test_get_init__after_quitf  s)    *+r	   N)"r@   rA   rB   r   r   r"   rC   rJ   r   r   r   HAVE_NEWBUFpygame.tests.test_utilsr   r   unittestskipIfIS_PYPYr   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r   r	   r
   r   r      sk   4;E E42O,b(AT 40 X__+++-EFX__Wo.%) / G%)N X__+++-EFE GE: X__+++-EFX__Wo.bI / GbIH X__W8V%7%7!7:NO`I P`ID=24#*(1$170",+,r	   r   __main__)r7   r!  r   python_implementationr#  r   r   	NameErrorr   r   r   TestCaser   r@   mainr   r	   r
   <module>r)     s    
  
2H224
4	0  

T	,X&& T	,n zHMMO I  		s   A A&%A&