
    i                        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mZ d dlmZ d dl	Z	d dl	m
Z
 d ej                         k(  Zg dZg dZdd	gZd
gZeD  cg c]  } eD ]  }eD ]  }| ||d
   c}}} Zddd	d dZ G d d      Z G d dej(                        Z G d dej(                        Z G d dej(                        Z G d dej(                        Z G d dej(                        Z G d dej(                        Z G d dej(                        Z G d d ej(                        Zed!k(  r ej<                          yyc c}}} w )"    Narray)example_path)mixerPyPy)i+  "V  D  i  )            i  )	frequencysizechannelsr	       )r   r   r   allowedchangesc                       e Zd ZdZdZy)InvalidBoolz!To help test invalid bool values.N)__name__
__module____qualname____doc____bool__     a/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/pygame/tests/mixer_test.pyr   r   &   s
    +Hr   r   c                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Z ej                  ej                  j!                  d
      d       ej                  ed      d               Zd Z ej                  ej*                  j-                  d      dk(  d      d        Zd Zd Zd Z ej                  ej8                   d       ej                  ed      d               Z ej                  ej8                   d       ej                  ed      d               Zd Zd Z d Z!ejD                  d        Z#d Z$d Z%d  Z&d! Z'd" Z(d# Z)d$ Z*y%)&MixerModuleTestc                 \    t        j                          t        j                  dddd       y )Nr   )r   quitpre_initselfs    r   tearDownzMixerModuleTest.tearDown0   s    

q!Q"r   c                 *   t        j                  di t         t        j                         }| j	                  |d   t        d          | j	                  t        |d         t        t        d                | j                  |d   t        d          y Nr   r   r   r   r   r   r   )r   initCONFIGget_initassertEqualabsassertGreaterEqualr%   
mixer_confs     r   test_init__keyword_argsz'MixerModuleTest.test_init__keyword_args4   sq    

V^^%
A{(;<Z]+S-@A
1vj/ABr   c                 R   t        j                  di t         t        j                          t        j                         }| j                  |d   t        d          | j                  t        |d         t        t        d                | j                  |d   t        d          y r(   )r   r#   r*   r)   r+   r,   r-   r.   r/   s     r   test_pre_init__keyword_argsz+MixerModuleTest.test_pre_init__keyword_args>   sz      

^^%
A{(;<Z]+S-@A
1vj/ABr   c                 v   t        j                  ddd       t        j                  ddd       t        j                  d       | j                  t        j                         d   d       | j                  t        j                         d   d       | j                  t        j                         d   d       y )	Nr   r   r   r   r   r	   r
   r   )r   r#   r)   r,   r+   r.   r$   s    r   test_pre_init__zero_valuesz*MixerModuleTest.test_pre_init__zero_valuesJ   s     	ub!$q!Q

!$)!,e4)!,c2 0 3Q7r   c                     t        j                  dddd       t        j                  ddd       | j                  t        j                         d       y )Nr	   r   r   r   r5   )r	   r   r   )r   r#   r)   r,   r+   r$   s    r   test_init__zero_valuesz&MixerModuleTest.test_init__zero_valuesT   s=     	ua15

1a)=9r   c                 J    | j                  t        j                                y N)assertIsNoner   r+   r$   s    r   4test_get_init__returns_None_if_mixer_not_initializedzDMixerModuleTest.test_get_init__returns_None_if_mixer_not_initializedn   s    %..*+r   c                 t    t        j                          | j                  t        j                         d       y )Nr   )r   r)   r,   get_num_channelsr$   s    r   0test_get_num_channels__defaults_eight_after_initz@MixerModuleTest.test_get_num_channels__defaults_eight_after_initq   s$    

//115r   c                     t        j                          t        j                         }t        d|dz         D ];  }t        j                  |       | j                  t        j                         |       = y )Nr   )r   r)   r>   rangeset_num_channelsr,   )r%   default_num_channelsis      r   test_set_num_channelsz%MixerModuleTest.test_set_num_channelsu   s]    

$557q.23 	:A""1%U335q9	:r   c                     t        j                          t        j                          | j                  t        j
                  t         j                         y)zXget_num_channels() Should throw pygame.error if uninitialized
        after mixer.quit()N)r   r)   r"   assertRaisespygameerrorr>   r$   s    r   	test_quitzMixerModuleTest.test_quit}   s0     	



&,,(>(>?r   winzSee github issue 892.zrandom errors here with pypyc                     d }t        j                          d}t        t        j                  j                  dd            }t        |      }|j                  t        j                               }t        j                  |      }| j                  |j                         dkD          ||      }| j                  t        |      dkD         | j                   |t        j                  |            |       | j                   |t        j                  |            |       | j                   |t        j                  |            |       d}| j                  t               5 }	t        j                          d d d        | j                  t        	j"                        |       | j                  t               5 }	t        j                  ||	       d d d        | j                  t        |	j"                        |       | j                  t               5 }	t        j                  ||       d d d        | j                  t        |	j"                        |       | j                  t               5 }	t        j                  ||
       d d d        | j                  t        |	j"                        |       | j                  t               5 }	t        j                  |       d d d        | j                  t        |	j"                        d       t        j                  |fi i }| j                   ||      |       t        j                  g i d|i}| j                  t               5 }	t        j                  g        d d d        | j                  t        |	j"                        d       | j                  t               5 }	t        j                  g 	      }d d d        d}
| j                  t        |	j"                        |
       d}| j                  t$        t         j                  |       | j                  t$        t         j                  d       | j                  t               5 }	t        j                  d	       d d d        d}
| j                  t        |	j"                        |
       | j                   |t        j                  |	            |       t'        |      t        k7  r- |t        j                  |            }| j                  ||       | j                   |t        j                  |            |       | j                   |t        j                  |            |       t        j                  |      }| j                  t               5 }	t        j                  ||       d d d        | j                  t        |	j"                        |       | j                  t               5 }	t        j                  ||       d d d        | j                  t        |	j"                        |       t        j                  |      }| j                  |j)                         |j)                                y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   kxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   BxY w# 1 sw Y   xY w# 1 sw Y   \xY w# 1 sw Y   6xY w# 1 sw Y   xY w)Nc                 "    | j                         S r:   )get_raw)snds    r   	get_bytesz2MixerModuleTest.test_sound_args.<locals>.get_bytes   s    ;;= r   s0                           datahouse_lo.wavfile      ?  z5Sound takes either 1 positional or 1 keyword argumentbuffer)rX   rT   )foobarz&Unrecognized keyword argument 'foobar'rT   z!Unrecognized argument (type list)z1Expected object with buffer interface: got a list12345678	somethingz+Unicode object not allowed as buffer objectr   )rX   r   )r   r)   r   ospathjoinstrencodesysgetfilesystemencodingSound
assertTrue
get_lengthlenr,   rG   	TypeError	exceptionIOErrortyperN   )r%   rP   sample	wave_path
uwave_path
bwave_pathrO   	snd_bytesarg_emsgcmemsg
ufake_path	somebytessnd2s                 r   test_sound_argszMixerModuleTest.test_sound_args   s   	! 	

! fn!EF	^
&&s'@'@'BC
kky)(3./cN	I-.5;;y#9:IF5;;J#?@)L5;;z#:;YGJy) 	RKKM	R\\*H5y) 	2RKK	&1	2R\\*H5y) 	0RKKY/	0R\\*H5y) 	7RKKvI6	7R\\*H5y) 	'RKKv&	'R\\*,TUkk)*r*33kk25&)!45y) 	RKKO	R\\*,OPy) 	)R++R(C	)BR\\*D1
'5;;
;'5;;
;y) 	,RKK{+	,<R\\*D15;;f#=>G<3!%++f"56IY/5;;J#?@)L5;;z#:;YGkk)$y) 	.RKK	-	.R\\*H5y) 	2RKKvS1	2R\\*H5{{%7m	 		2 	2	0 	0	7 	7	' 	'	 		) 	)	, 	,	. 	.	2 	2sx   'Y?>ZZ2Z&Z3*[ [)[['5[4?Z	ZZ#&Z03Z= [
[[$'[14[=c                    t        j                          ddl}t        d      }t        j
                  j                  |d      }t        j
                  j                  |d      }|j                  ||       	 t        |d      5 }	 ddd       	 t        j                  |      }~t	        j                  |       y# 1 sw Y   6xY w# t        $ r t        j                  d      w xY w# t	        j                  |       w xY w)ztest non-ASCII unicode pathr   NrQ   u
   你好.wavrR   rbzthe path cannot be opened)r   r)   shutilr   r\   r]   r^   copyopenOSErrorunittestSkipTestrc   remove)r%   ry   ep	temp_fileorg_filefsounds          r   test_sound_unicodez"MixerModuleTest.test_sound_unicode   s    

&!GGLL\2	77<<N3Hi(	Ai& !
	!KK	*EIIi   	A##$?@@	A IIi s0   7C B:C C( :C?C C%(C?SDL_AUDIODRIVERdiskz'this test fails without real sound cardc           	         	 ddl m}m}m}m}m}m}m}m}m	}	 d}
g d}ddg}|D ci c]  }|g  }} ddd	      }|j                        }|j                        }|||fD cg c]  }d|f }}|D ]  }|dkD  s	||   j                  |         |d	d
d      }|j                        }|j                        }|||fD cg c]  }d|f }}|D ]  }|dk  s	||   j                  |         |j                  d   dg|	      }||d d df<   d|z
  |d d df<   |j                  |      }|j                  |      }|||fD cg c]  }d|f }}|D ]  }|dkD  s	||   j                  |         ||j                  d   dg|      }||d d df<   d|z
  |d d df<   |j                  |      }|j                  |      }|||fD cg c]  }d|f } }|D ]  }|dk  s	||   j                  |         |D ]  }|D ]  }!	 t        j                   |
||!       	 t        j&                         \  }"}}#||k7  s|#|!k7  r	 t        j(                          T||   D ]  \  }#}| j+                  |||#|!k(          	 t        j(                            y # t        $ r | j                  d       Y w xY wc c}w c c}w c c}w c c}w c c}w # t"        j$                  $ r Y w xY w# t        j(                          w xY w)Nr   )	r   arangezerosint8uint8int16uint16int32uint32zrequires numpyr   )r   r   r
   r   r   r      i      )numpyr   r   r   r   r   r   r   r   r   ImportErrorskipTestastypeextendshaper   r)   rH   rI   r+   r"   _test_array_argument)$r%   r   r   r   r   r   r   r   r   r   freqformat_listchannels_listr   a_lists	a32u_mono	a16u_monoa8u_monoaau_list_monoformat	a32s_mono	a16s_monoa8s_monoas_list_monoa32u_stereoa16u_stereo
a8u_stereoau_list_stereoa32s_stereoa16s_stereo
a8s_stereoas_list_stereor   __cs$                                       r   test_array_keywordz"MixerModuleTest.test_array_keyword   sv   
	,
 
 
 &A"-.Q1b5..1c1f-	$$V,	##E*)19i(HI1AII! 	5Fz&&|4	5 4a/	$$U+	##D))19i(HI1AII! 	5Fz&&|4	5 Y__Q/3V<%AqD)OAqD!((0 ''.
+5{K*PQQ1a&QQ! 	7Fz&&~6	7 Y__Q/3U;%AqDNAqD!((/ ''-
+5{K*PQQ1a&QQ! 	7Fz&&~6	7 " 	!F) !JJtVX6!$~~/HB1F{a8m  JJL !( L111&!Q(]KL JJL!	!S  	,MM*+	, / J J R R ||  JJLsR   J 
J7&J<KKK	K!"K)#K)J43J4K&%K&)K?c                    ddl m}m} 	 t        j                  |      }|s | j                  d||j                  fz          |      }|j                  |j                        }t        |      d|j                  z  z
  }	|	dk\  r||	z  }| j                   |||k(        d||j                  fz         y # t
        $ r' |sY y | j                  d||j                  fz         Y w xY w)Nr   )r   allr   z&Raised ValueError: Format %i, dtype %sz-Did not raise ValueError: Format %i, dtype %sr   zFormat %i, dtype %s)r   r   r   r   rc   
ValueErrorfaildtyper   r-   itemsizerd   )
r%   r   r   	test_passr   all_rO   a2a3lshifts
             r   r   z$MixerModuleTest._test_array_argument4  s    ,	T++A&C
 II?6177BSS 3ZXXbhhVq1::~-Q;6MBR2X(=@Q(QR  	TII>&!''ARRS	Ts   B5 5C% C%$C%c                 P    | j                  t        t        j                  |       y )Nr   )rG   r   r   rc   )r%   r   s     r   _test_array_interface_failz*MixerModuleTest._test_array_interface_failI  s    *ekk;r   c                    t        j                  dddd       t        j                  d      }|j                  }| j	                  t        |t                     t        j                         t        j                  k(  rd}nd	}| j                  |d
   |       | j                  |d   d       | j                  |d   d       | j                  |d   |j                  df       y )Nr   r
   r   r   r5   s(                       rW   z<i2z>i2typestrr   )   strides)r   rQ   F)r   r)   rc   __array_interface__rd   
isinstancedictrH   get_sdl_byteorder
LIL_ENDIANr,   _samples_address)r%   rO   dr   s       r   test_array_interfacez$MixerModuleTest.test_array_interfaceL  s    

5#q3kk!12##
1d+,##%):)::GG9w/7U+9t,6S%9%95$ABr   znewbuf not implementedzpypy no likeyc                 R    t        j                  ddd       | j                          y )Nr   r
   r   r   r)   _NEWBUF_export_checkr$   s    r   test_newbuf__one_channelz(MixerModuleTest.test_newbuf__one_channelZ        	

5#q!!!#r   c                 R    t        j                  ddd       | j                          y )Nr   r
   r   r   r$   s    r   test_newbuf__twho_channelz)MixerModuleTest.test_newbuf__twho_channel`  r   r   c           	         t        j                         \  }}}|dk(  rdnd}t        |      dz  }dddddd	d
dd}||   }ddlm} |j
                  }	|j                  }
t        j                         t        j                  k(  }|rdnd\  }}d|fd | }||z  |fd|z
  d  } |	||dz         }t        j                  |      }t        |      |z  |z  } |
||j                        }| j                  |j                  d       | j                  |j                   d u        | j                  |j                  |       | j                  |j"                  |       | j                  |j$                  d u        | j                  |j&                  d u        | j                  |j(                  d u        | j+                  |j,                         | j                  |j.                  |j0                          |
||j2                        }| j                  |j                  d       | j                  |j                   d u        | j                  |j                  |       | j                  |j"                  |       | j                  |j$                  d u        | j                  |j&                  d u        | j                  |j(                  d u        | j+                  |j,                         | j                  |j.                  |j0                          |
||j4                        }| j                  |j                  d       | j                  |j                   |       | j                  |j                  |       | j                  |j"                  |       | j                  |j$                  d u        | j                  |j&                  d u        | j                  |j(                  d u        | j+                  |j,                         | j                  |j.                  |j0                          |
||j6                        }| j                  |j                  |       | j                  |j                   d u        | j                  |j                  |       | j                  |j"                  |       | j                  |j$                  |       | j                  |j&                  d u        | j                  |j(                  d u        | j+                  |j,                         | j                  |j.                  |j0                          |
||j8                        }| j                  |j                  |       | j                  |j                   d u        | j                  |j                  |       | j                  |j"                  |       | j                  |j$                  |       | j                  |j&                  |       | j                  |j(                  d u        | j+                  |j,                         | j                  |j.                  |j0                          |
||j:                        }| j                  |j                  |       | j                  |j                   |       | j                  |j                  |       | j                  |j"                  d       | j                  |j$                  |       | j                  |j&                  |       | j                  |j(                  d u        | j+                  |j,                         | j                  |j.                  |j0                          |
||j:                        }| j                  |j                  |       | j                  |j                   |       | j                  |j                  |       | j                  |j"                  |       | j                  |j$                  |j$                         | j                  |j&                  |       | j                  |j(                  d u        | j+                  |j,                         | j                  |j.                  |j0                          |
||j<                        }| j                  |j                  |       | j                  |j                   d u        | j                  |j&                  |        |
||j>                        }| j                  |j                  |       | j                  |j                   d u        | j                  |j&                  |       |dk(  ri |
||j@                        }| j                  |j                  d       | j                  |j                   d u        | j                  |j&                  |       y | jC                  tD        |
||j@                         y )Nr   r   r   Bbz=Hz=hz=Iz=iz=Qz=q)r   r   r   r
   r   i@   ir   )buftools)<>)r   r   
   rD   )r   r   )#r   r+   r-   pygame.tests.test_utilsr   ExporterImporterrH   r   r   rc   rf   PyBUF_SIMPLEr,   ndimrd   r   r   r   r   
suboffsetsassertFalsereadonlybufr   PyBUF_WRITABLEPyBUF_FORMATPyBUF_NDPyBUF_STRIDESPyBUF_FULL_ROPyBUF_C_CONTIGUOUSPyBUF_ANY_CONTIGUOUSPyBUF_F_CONTIGUOUSrG   BufferError)r%   r   fmtr   r   r   formatsr   r   r   r   is_lil_endianfsysfrevr   r   exprO   buflenimps                       r   r   z$MixerModuleTest._NEWBUF_export_checkf  s   #nn.c8]qs8q=	
 4$$$$002f6G6GG#0Zj
dXu%h&1!d(*=uTCZ0kk$SH$x/sH1121%

d*+&)x0		T)*t+,$./&#"6"67sH3341%

d*+&)x0		T)*t+,$./&#"6"67sH1121%V,&)x0		T)*t+,$./&#"6"67sH--.4(

d*+&)x0E*t+,$./&#"6"67sH2234(

d*+&)x0E*g.$./&#"6"67sH2234(V,&)q)E*g.$./&#"6"67sH2234(V,&)x0CII.g.$./&#"6"67sH7784(

d*+g.sH99:4(

d*+g.193 ; ;<CSXXq)OOCJJ$./S[['2k8S(:U:UVr   c                    t        j                         t        j                          t        j                   j	                  t        d            }t        j                   j                         }|j                  |       d}|j                  |       t        j                  j                  |dz          | j                  |j                                y)zHEnsure pygame.mixer.fadeout() stops playback after fading out the sound.Ndata/house_lo.wav      )r   r+   r)   rH   rc   r   find_channelplayfadeouttimewaitr   get_busy)r%   r   channelfadeout_times       r   test_fadeoutzMixerModuleTest.test_fadeout  s    >>#JJL""<0C#DE,,++-U%*+ 	))+,r   c                    t        j                          t        t        j                  j                  dd            }t        j                  |      }t        j                         }|dkD  rt        j                         }| j                  |       g }t        d|      D ]9  }t        j                  |      }|j                  |       |j                  |       ; t        j                         }| j                  |       t        j                  d      }| j                  |       t        j                  d      }| j                  |       |D ]  }|j                           t        j                         }| j                  |       y y )NrQ   rR   rS   r   T)force)r   r)   r   r\   r]   r^   rc   r>   r   assertIsNotNonerA   Channelr   appendr;   stop)r%   filenamer   num_channelsfound_channelr   
channel_idr  s           r   test_find_channelz!MixerModuleTest.test_find_channel  s@   
 	

V^ DE*--/!!..0M  / H#A|4 )
--
3U#() "..0Mm, "..t4M  / "..T:M  /# !..0M  /5 r   c                    t        j                         t        j                          t        j                  t	        d            }t        j
                         }|j                  |       t        j                          | j                  |j                                t        j                          | j                  |j                                y)zMEnsure pygame.mixer.pause() temporarily stops playback of all sound channels.Nr   )r   r+   r)   rc   r   r   r   pauser   r   unpauserd   r%   r   r  s      r   
test_pausezMixerModuleTest.test_pause  s     >>#JJLL)<=>$$&U 	))+, 	((*+r   c                    t        j                          t        j                         }t        j                  |      }| j	                  ||       t        j                  |dz         }| j	                  ||       t        j                  d      }| j	                  |d       t        j                  t        |dz              }| j	                  |t        |dz               y)zIEnsure pygame.mixer.set_reserved() reserves the given number of channels.r   r   r   N)r   r)   r>   set_reservedr,   int)r%   rC   results      r   test_set_reservedz!MixerModuleTest.test_set_reserved   s     	

$557 ##$89!56 ##$81$<=!56 ##A&# ##C(<q(@$AB%9A%=!>?r   c                    t        j                         t        j                          t        j                   j	                  t        d            }t        j                   j                  d      }|j                  |       t        j                   j                          t        t        j                   j                               D ]>  }| j                  t        j                   j                  |      j                                @ y)z,Stops playback of all active sound channels.Nr   r   )r   r+   r)   rH   rc   r   r  r   r	  rA   r>   r   r   )r%   r   r  rD   s       r   	test_stopzMixerModuleTest.test_stop:  s    >>#JJL""<0C#DE,,&&q)Uv||4467 	AAV\\11!4==?@	Ar   c                     d}t         }t        }t        j                  j	                         }| j                  ||       | j                  t        |      |       |D ]  }| j                  ||        y)z;Ensures get_sdl_mixer_version works correctly with no args.   Ntupler  rH   r   get_sdl_mixer_versionassertIsInstancer,   rf   )r%   expected_lengthexpected_typeexpected_item_typeversionitems         r   test_get_sdl_mixer_versionz*MixerModuleTest.test_get_sdl_mixer_versionE  sh     ,,446g}5W7 	<D!!$(:;	<r   c                     d}t         }t        }dD ]g  }t        j                  j	                  |      }| j                  ||       | j                  t        |      |       |D ]  }| j                  ||        i y)z9Ensures get_sdl_mixer_version works correctly using args.r  TFNr  r%   r!  r"  r#  valuer$  r%  s          r    test_get_sdl_mixer_version__argsz0MixerModuleTest.test_get_sdl_mixer_version__argsS  s}     " 	@Ell88?G!!'=9S\?; @%%d,>?@	@r   c                     d}t         }t        }dD ]h  }t        j                  j	                  |      }| j                  ||       | j                  t        |      |       |D ]  }| j                  ||        j y)z;Ensures get_sdl_mixer_version works correctly using kwargs.r  r(  linkedNr  r)  s          r   "test_get_sdl_mixer_version__kwargsz2MixerModuleTest.test_get_sdl_mixer_version__kwargsb  s     " 	@Ell888FG!!'=9S\?; @%%d,>?@	@r   c                 >   t               }| j                  t              5  t        j                  j                  |      }ddd       | j                  t              5  t        j                  j                  |      }ddd       y# 1 sw Y   HxY w# 1 sw Y   yxY w)z>Ensures get_sdl_mixer_version handles invalid args and kwargs.Nr-  )r   rG   rg   rH   r   r  )r%   invalid_boolr$  s      r   /test_get_sdl_mixer_version__invalid_args_kwargsz?MixerModuleTest.test_get_sdl_mixer_version__invalid_args_kwargsq  s    "}y) 	Gll88FG	G y) 	Nll888MG	N 	N	G 	G	N 	Ns    B!BBBc                     t         j                  j                  d      }t         j                  j                  d      }| j                  ||       y)zCEnsures get_sdl_mixer_version's linked/compiled versions are equal.Tr-  FN)rH   r   r  assertTupleEqual)r%   linked_versioncomplied_versions      r   2test_get_sdl_mixer_version__linked_equals_compiledzBMixerModuleTest.test_get_sdl_mixer_version__linked_equals_compiled{  sB    ;;4;H!<<==U=Kn.>?r   N)+r   r   r   r&   r1   r3   r6   r8   r<   r?   rE   rJ   r}   skipIfra   platform
startswithIS_PYPYrv   r   r\   environgetr   r   r   r   rH   HAVE_NEWBUFr   r   r   r  r  expectedFailurer  r  r  r&  r+  r/  r2  r7  r   r   r   r    r    /   s   #C
C8:4,6:@ X__S\\,,U35LMX__W<=K8 > NK8Z!* X__


()V31E!	E!NS*<C X__+++-EFX__Wo.$ / G$ X__+++-EFX__Wo.$ / G$nW`-&0P , ,&@4	A<@@N@r   r    c                       e Zd Ze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d Zd Zd Zd Zd Zd Zy)ChannelTypeTestc                 ,    t        j                          y r:   )r   r)   clss    r   
setUpClasszChannelTypeTest.setUpClass  s     	

r   c                 ,    t        j                          y r:   r   r"   rC  s    r   tearDownClasszChannelTypeTest.tearDownClass      

r   c                 V    t        j                         t        j                          y y r:   r   r+   r)   rC  s    r   setUpzChannelTypeTest.setUp       >>#JJL $r   c                     t        j                  d      }| j                  |t         j                         | j	                  |j
                  j                  d       y)z Ensure Channel() creation works.r   r  N)r   r  r   ChannelTyper,   	__class__r   r%   r  s     r   test_channelzChannelTypeTest.test_channel  sB    --"gu'8'89**33Y?r   c                     | j                  t              5  t        j                          ddd       y# 1 sw Y   yxY w)z9Ensure exception for Channel() creation with no argument.N)rG   rg   r   r  r$   s    r   test_channel__without_argz)ChannelTypeTest.test_channel__without_arg  s.    y) 	MMO	 	 	   4=c                     | j                  t              5  t        j                  d       ddd       y# 1 sw Y   yxY w)z;Ensure exception for Channel() creation with an invalid id.r   N)rG   
IndexErrorr   r  r$   s    r   test_channel__invalid_idz(ChannelTypeTest.test_channel__invalid_id  s1    z* 	MM"	 	 	s   5>c                     t        j                          | j                  t        j                  d      5  t        j
                  d       ddd       y# 1 sw Y   yxY w)z<Ensure exception for Channel() creation with non-init mixer.mixer not initializedr   N)r   r"   assertRaisesRegexrH   rI   r  r$   s    r   test_channel__before_initz)ChannelTypeTest.test_channel__before_init  sA    

##FLL2IJ 	MM!	 	 	s   AAc                 4   t        j                  d      }t        j                  t        d            }|j	                  |       d}|j                  |       t        j                  j                  |dz          | j                  |j                                y)z9Ensure Channel.fadeout() stops playback after fading out.r   r   rV   d   N)r   r  rc   r   r   r   rH   r   r   r   r   )r%   r  r   r  s       r   r  zChannelTypeTest.test_fadeout  sq    --"L)<=>U% 	+,))+,r   c                 v    d}t        j                  d      }|j                         }| j                  ||       y)z/Ensure an idle channel's busy state is correct.Fr   N)r   r  r   r,   )r%   expected_busyr  busys       r   test_get_busyzChannelTypeTest.test_get_busy  s3    --"!}-r   c                     t        j                  d      }t        j                  t        d            }|j	                  |       | j                  |j                                y)z1Ensure an active channel's busy state is correct.r   r   N)r   r  rc   r   r   rd   r   r%   r  r   s      r   test_get_busy__activez%ChannelTypeTest.test_get_busy__active  sE    --"L)<=>U((*+r   c                 $    | j                          y r:   r   r$   s    r   todo_test_get_endeventz&ChannelTypeTest.todo_test_get_endevent  s     			r   c                 n   t        j                  d      }t        j                         \  }}}d}d}t        |dz  |z  t	        |      dz  z        }t        j
                  dt        ||z        z        }t        j
                  dt        ||z        z        }	|j                  |       |j                  |	       | j                  |j                         j                         |	j                                t        j                  j                  |dz          | j                  |j                                | j                  |j                         j                         |	j                                t        j                  j                  |dz          | j                  |j                                y)	z4Ensure Channel.get_queue() returns any queued Sound.r   r     rV   r       r^  N)r   r  r+   r  r-   rc   r   queuer,   	get_queuere   rH   r   r   r;   	get_sound)
r%   r  r   r   r   sound_length_in_mssound_length_in_ms_2bytes_per_mssound1sound2s
             r   test_get_queuezChannelTypeTest.test_get_queue  s_   --"&+nn&6#	68 "I,8CK1<LMNWs+=+L'MMNW,@<,O(PQRVf 	**,7796;L;L;NO+c12'++-. 	**,7796;L;L;NO.#56 	'++-.r   c                 2   t        j                  d      }t        j                  t        d            }|j	                  |       |j                         }| j                  ||       |j                          |j                         }| j                  |       y)z?Ensure Channel.get_sound() returns the currently playing Sound.r   r   N)	r   r  rc   r   r   rn  r,   r	  r;   )r%   r  r   	got_sounds       r   test_get_soundzChannelTypeTest.test_get_sound  sw    --"L)<=>U %%'	E* 	%%'	)$r   c                 v    d}t        j                  d      }|j                         }| j                  ||       y)z+Ensure a channel's volume can be retrieved.      ?r   N)r   r  
get_volumeassertAlmostEqual)r%   expected_volumer  volumes       r   test_get_volumezChannelTypeTest.test_get_volume  s3    --"##%v7r   c                    t        j                         t        j                          t        j                   j	                  t        d            }|j                         }|j                          | j                  |j                         d       |j                          | j                  |j                         d       |j                          y)zA
        Test if the Channel can be paused and unpaused.
        Nr   z&Channel should be paused but it's not.)msgz(Channel should be unpaused but it's not.)r   r+   r)   rH   rc   r   r   r  rd   r   r  r	  r  s      r   test_pause_unpausez"ChannelTypeTest.test_pause_unpause  s     >>#JJL""<0C#DE**,$L 	 	
 	$N 	 	
 	

r   c                    t        j                  t        d            }|j                         }t        j                          | j                  t        j                  d      5  |j                          ddd       | j                  t        j                  d      5  |j                          ddd       y# 1 sw Y   CxY w# 1 sw Y   yxY w)zK
        Ensure exception for Channel.pause() with non-init mixer.
        r   rZ  N)
r   rc   r   r   r"   r[  rH   rI   r  r  r  s      r   test_pause_unpause__before_initz/ChannelTypeTest.test_pause_unpause__before_init  s     L)<=>**,

##FLL2IJ 	MMO	 ##FLL2IJ 	OO	 		 		 	s   #B6C6B?Cc                 @   t         j                  j                  d      dk(  r| j                  d       t	        j
                  d      }t	        j                         \  }}}d}d}d}t        |dz  |z  t        |      d	z  z        }t	        j                  d
t        ||z        z        }	t	        j                  d
t        ||z        z        }
t	        j                  d
t        ||z        z        }|j                  |	       |j                  |
       t        j                  j                  |dz          | j                  |j!                                | j#                  |j%                         |
       | j'                  |j)                                t        j                  j                  |dz          |j                  |	       | j                  |j!                                | j#                  |j%                         |	       t        j                  j                  |dz          |j                  |	       |j                  |
       |j                  |       | j'                  |j)                                t        j                  j                  |dz          | j+                  |j!                                |j                  |	       |j                  |
       |j-                          | j'                  |j)                                | j+                  |j!                                |j                  |	       |j                  |
       |j                  |       | j#                  |j%                         |	       | j#                  |j)                         |       y)z<
        Ensure the Channel.queue() works correctly
        PYGAME_MSYS21zSkip test on MSYS2r   r   rj  ,  rV   r   rk  r^  N)r\   r<  r=  r   r   r  r+   r  r-   rc   r   rl  rH   r   r   rd   r   r,   rn  r;   rm  r   r	  )r%   r  r   r   r   ro  rp  sound_length_in_ms_3rq  rr  rs  sound3s               r   
test_queuezChannelTypeTest.test_queue,  s    ::>>.)S0MM./ --"&+nn&6#	68 ""I,8CK1<LMNWs+=+L'MMNW,@<,O(PQRW,@<,O(PQR 	Vf+c12((*+**,f5'++-.-34 	f((*+**,f5+c12 	VfV'++-.-34))+, 	Vf'++-.))+, 	Vff**,f5**,f5r   c                    t        j                  d      }t        j                  t        d            }|j	                  |       |j                          | j                  |j                                |j                  |       |j                          | j                  |j                                |j	                  |       | j                  |j                                y )Nr   r   )
r   r  rc   r   r   r	  r   r   rl  rd   rd  s      r   r  zChannelTypeTest.test_stopf  s     --"L)<=> 	U))+,e))+,U((*+r   N)r   r   r   classmethodrE  rH  rL  rR  rT  rX  r\  r  rb  re  rh  rt  rw  r~  r  r  r  r  r   r   r   rA  rA    sz       @

-.,/4%8$86t,r   rA  c                   B    e Zd Zd Zd Zd Zej                  d        Zy)ChannelSetVolumeTestc                     t        j                          t        j                   j                  d      | _        t        j                   j                  t        d            | _        y )Nr   zdata/boom.wav)r   r)   rH   r  r  rc   r   r   r$   s    r   rL  zChannelSetVolumeTest.setUp  s<    

||++A.\\''_(EF
r   c                 ,    t        j                          y r:   rG  r$   s    r   r&   zChannelSetVolumeTest.tearDown      

r   c                     | j                   j                  | j                         | j                   j                  d       | j	                  | j                   j                         d       y )NrU   r  r   r   
set_volumer,   rz  r$   s    r   !test_set_volume_with_one_argumentz6ChannelSetVolumeTest.test_set_volume_with_one_argument  sG    $**%$002C8r   c                     | j                   j                  | j                         | j                   j                  dd       | j	                  | j                   j                         d       y )N333333?ffffff?)r  r  r  r$   s    r   "test_set_volume_with_two_argumentsz7ChannelSetVolumeTest.test_set_volume_with_two_arguments  sK     	$**%S)002J?r   N)	r   r   r   rL  r&   r  r}   r?  r  r   r   r   r  r    s.    G
9
 @ @r   r  c                       e Zd Zd Zd Zd Zy)ChannelEndEventTestc                     t         j                  j                          t         j                  j                  d       t	        j
                         t	        j                          y y )N)(   r  )rH   displayr)   set_moder   r+   r$   s    r   rL  zChannelEndEventTest.setUp  s?    )>>#JJL $r   c                 h    t         j                  j                          t        j                          y r:   )rH   r  r"   r   r$   s    r   r&   zChannelEndEventTest.tearDown  s    

r   c                 0   t        j                  d      }t        j                  t        d            }|j	                  |       t
        j                  dz   }|j                  |       |j                         }| j                  ||       |j                          |j                         r0t
        j                  j                  d       |j                         r0t
        j                  j                  |      }| j!                  t#        |      dkD         y)z=Ensure Channel.get_endevent() returns the correct event type.r   r   r   r   N)r   r  rc   r   r   rH   	USEREVENTset_endeventget_endeventr,   r	  r   r   r   eventr=  rd   rf   )r%   r  r   	END_EVENTgot_end_eventeventss         r   test_get_endeventz%ChannelEndEventTest.test_get_endevent  s    --"L)<=>U $$q(	Y',,.	2 	 KKR    !!-0Fa(r   N)r   r   r   rL  r&   r  r   r   r   r  r    s    )r   r  c                   H    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)TestSoundPlayc                     t        j                          t        t        j                  j                  dd            | _        t        j                  | j                        | _        y )NrQ   rR   rS   )	r   r)   r   r\   r]   r^   r
  rc   r   r$   s    r   rL  zTestSoundPlay.setUp  s:    

$RWW\\&.%IJ[[dmm4
r   c                 ,    t        j                          y r:   rG  r$   s    r   r&   zTestSoundPlay.tearDown  r  r   c                     | j                   j                         }| j                  |t        j                  j
                         | j                  |j                                y)zTest playing a sound once.N)r   r   r   rH   r   r  rd   r   rQ  s     r   test_play_oncezTestSoundPlay.test_play_once  sA    **//#gv||';';<((*+r   c                    t        j                         \  }}}d}t        |dz  |z  t        |      dz  z        }t        j                  dt        ||z        z        }| j                  |j                         |dz  d       d}|j                  |	      }| j                  |t        j                   j                         t        j                  j                  ||z  dz
         | j                  |j                                t        j                  j                  |d
z          | j                  |j                                y)z$Test playing a sound multiple times.r^  rV   r   rk  g     @@r   )places   loopsr   N)r   r+   r  r-   rc   r{  re   r   r   rH   r  r   r   rd   r   r   )	r%   r   r   r   ro  rq  r   	num_loopsr  s	            r   test_play_multiple_timesz&TestSoundPlay.test_play_multiple_times  s    ',nn&6#	68 I,8CK1<LMNGc*<|*K&LLM 2V ;A 	 	
 	**9*-gv||';';< 	,y8C?@((*+ 	+c12))+,r   c                    t        j                         \  }}}d}t        |dz  |z  t        |      dz  z        }t        j                  dt        ||z        z        }|j                  d      }| j                  |t        j                   j                         t        d      D ]@  }| j                  |j                                t        j                  j                  |       B y)	z"Test playing a sound indefinitely.r^  rV   r   rk  r   r  r   N)r   r+   r  r-   rc   r   r   rH   r  rA   rd   r   r   r   )	r%   r   r   r   ro  rq  r   r  _s	            r   test_play_indefinitelyz$TestSoundPlay.test_play_indefinitely  s    &+nn&6#	68 I,8CK1<LMNGc*<|*K&LLM**2*&gv||';';< q 	1AOOG,,./KK/0	1r   c                 J   | j                   j                  d      }| j                  |t        j                  j
                         | j                  |j                                t        j                  j                  d       | j                  |j                                y)z"Test playing a sound with maxtime.r   maxtime   N)r   r   r   rH   r   r  rd   r   r   r   r   rQ  s     r   test_play_with_maxtimez$TestSoundPlay.test_play_with_maxtime  sn    **//#/.gv||';';<((*+"))+,r   c                 
   | j                   j                  d      }| j                  |t        j                  j
                         | j                  |j                                t        j                  j                  d       | j                  |j                         d       | j                  |j                         d       t        j                  j                  d       | j                  |j                         d       y)	z"Test playing a sound with fade_ms.i  fade_msr  r  g?r  ry  N)r   r   r   rH   r   r  rd   r   r   r   assertGreaterrz  
assertLessr,   rQ  s     r   test_play_with_fade_msz$TestSoundPlay.test_play_with_fade_ms  s    **//#/.gv||';';<((*+7--/5**,d3++-s3r   c                     | j                  t              5  | j                  j                  d       ddd       y# 1 sw Y   yxY w)z(Test playing a sound with invalid loops.invalidr  NrG   rg   r   r   r$   s    r   test_play_with_invalid_loopsz*TestSoundPlay.test_play_with_invalid_loops  s7    y) 	-JJOO)O,	- 	- 	-	   <Ac                     | j                  t              5  | j                  j                  d       ddd       y# 1 sw Y   yxY w)z*Test playing a sound with invalid maxtime.r  r  Nr  r$   s    r   test_play_with_invalid_maxtimez,TestSoundPlay.test_play_with_invalid_maxtime  7    y) 	/JJOOIO.	/ 	/ 	/r  c                     | j                  t              5  | j                  j                  d       ddd       y# 1 sw Y   yxY w)z*Test playing a sound with invalid fade_ms.r  r  Nr  r$   s    r   test_play_with_invalid_fade_msz,TestSoundPlay.test_play_with_invalid_fade_ms  r  r  N)r   r   r   rL  r&   r  r  r  r  r  r  r  r  r   r   r   r  r    s4    5
,-21-4-
/
/r   r  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 ej                  e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y)SoundTypeTestc                 ,    t        j                          y r:   rG  rC  s    r   rH  zSoundTypeTest.tearDownClass  rI  r   c                 V    t        j                         t        j                          y y r:   rK  rC  s    r   rL  zSoundTypeTest.setUp  rM  r   c                 ,   t        t        j                  j                  dd            }t	        j
                  |      }t	        j
                  |      }| j                  |t        j
                         | j                  |t        j
                         y)z.Ensure Sound() creation with a filename works.rQ   rR   rS   Nr   r\   r]   r^   r   rc   r   )r%   r
  rr  rs  s       r   
test_soundzSoundTypeTest.test_sound$  s_    V^ DEX&(+fekk2fekk2r   c                    t        t        j                  j                  dd            }t	        |d      5 }t        j                  |      }| j                  |t
        j                         ddd       y# 1 sw Y   yxY w)z1Ensure Sound() creation with a file object works.rQ   rR   rx   N)r   r\   r]   r^   r{   r   rc   r   )r%   r
  file_objr   s       r   test_sound__from_file_objectz*SoundTypeTest.test_sound__from_file_object-  s`    V^ DE (D! 	6XKK)E!!%5	6 	6 	6s   6A55A>c                     t        t        j                  j                  dd            }t	        j
                  |      }t	        j
                  |      }| j                  |t        j
                         y)z4Ensure Sound() creation with a Sound() object works.rQ   rR   rS   Nr  )r%   r
  	sound_objr   s       r   test_sound__from_sound_objectz+SoundTypeTest.test_sound__from_sound_object7  sK    V^ DEKKX.	I&eU[[1r   c                 R   t        j                  t        t        j                  j                  dd                  }t        j                  |      }t        j                  |      }| j                  |t        j                         | j                  |t        j                         y)z9Ensure Sound() creation with a pathlib.Path object works.rQ   rR   rS   N)	pathlibPathr   r\   r]   r^   r   rc   r   )r%   r]   rr  rs  s       r   test_sound__from_pathlibz&SoundTypeTest.test_sound__from_pathlib@  sh    ||Lfn)MNOT"$'fekk2fekk2r   c                 $    | j                          y)z,Ensure Sound() creation with a buffer works.Nrg  r$   s    r   todo_test_sound__from_bufferz*SoundTypeTest.todo_test_sound__from_bufferH  s    		r   c           	          t        dt        t        j                  j	                  dd                  }t        j                  |      }| j                  |t
        j                         y)z,Ensure Sound() creation with an array works.urQ   rR   N)r   r   r\   r]   r^   r   rc   r   )r%   array1rr  s      r   test_sound__from_arrayz$SoundTypeTest.test_sound__from_arrayL  sD    sLfn)MNOV$fekk2r   c                     | j                  t              5  t        j                          ddd       y# 1 sw Y   yxY w)z>Ensure exception raised for Sound() creation with no argument.N)rG   rg   r   rc   r$   s    r   test_sound__without_argz%SoundTypeTest.test_sound__without_argR  s.    y) 	KKM	 	 	rU  c                    t        j                          t        t        j                  j                  dd            }| j                  t        j                  d      5  t        j                  |       ddd       y# 1 sw Y   yxY w)zAEnsure exception raised for Sound() creation with non-init mixer.rQ   rR   rZ  rS   N)
r   r"   r   r\   r]   r^   r[  rH   rI   rc   )r%   r
  s     r   test_sound__before_initz%SoundTypeTest.test_sound__before_initW  sZ    

V^ DE##FLL2IJ 	'KKX&	' 	' 	's   A>>Bz	pypy skipc                 N   	 ddl m}m}m} |j                  }||_        |g|_        d} ||      }t        j                  |      }| j                  |j                  |       t        j                  j                          | j                  t        j                  d      5  |j                   ddd       y# 1 sw Y   yxY w# t        j                  j                          | j                  t        j                  d      5  j                   ddd       w # 1 sw Y   w xY wxY w)z!Test the _samples_address getter.r   )	pythonapic_void_p	py_object   abcdefghrW   rZ  N)ctypesr  r  r  PyBytes_FromStringrestypeargtypesr   rc   assertNotEqualr   rH   r"   r[  rI   )r%   r  r  r  Bytes_FromStringsamplessample_bytesrO   s           r   test_samples_addressz"SoundTypeTest.test_samples_address_  s    	%==(;;'/$)2%!G+G4L++W-C 4 4lCLL''6MN %$$% % % LL''6MN %$$% % %s0   A!C !B77C ?D$D	D$D!D$c                    	 t         D ]  }t        j                  j                          t        j                  j	                  |       t        t        j                  j                  dd            }t        j                  |      }|j                         }t        j                  j                         \  }}}t        |      dz  }t        t        |            |z  |z  |z  }	| j                  |	|j!                                 	 t        j                  j                          | j#                  t        j$                  d      5  j!                          ddd       y# 1 sw Y   yxY w# t        j                  j                          | j#                  t        j$                  d      5  j!                          ddd       w # 1 sw Y   w xY wxY w)z-Tests if get_length returns a correct length.)r   rQ   	punch.wavrS   r   rZ  N)SIZESrH   r   r"   r)   r   r\   r]   r^   rc   rN   r+   r-   floatrf   r{  re   r[  rI   )
r%   r   r
  r   sound_bytesmix_freqmix_bitsmix_channels	mix_bytesr!  s
             r   test_get_lengthzSoundTypeTest.test_get_lengtht  sd   	# L!!#!!t!,'V[(IJ2 $mmo39<<3H3H3J0(LMA-	#k*+h6B\Q   &&8H8H8JKL  LL''6MN #  "# # # LL''6MN #  "# # #s0   DE, E  E),?G+G<	GG
Gc                 z   	 t        t        j                  j                  dd            }t	        j
                  |      }| j                  |j                         d       |j                          | j                  |j                         d       |j                          | j                  |j                         d       |j                          | j                  |j                         d       t        j                  j                          | j                  t        j                  d      5  |j                          ddd       y# 1 sw Y   yxY w# t        j                  j                          | j                  t        j                  d      5  j                          ddd       w # 1 sw Y   w xY wxY w)	zz
        Tests if Sound.get_num_channels returns the correct number
        of channels playing a specific sound.
        rQ   rR   rS   r   r   r   rZ  N)r   r\   r]   r^   r   rc   r,   r>   r   r	  rH   r"   r[  rI   )r%   r
  r   s      r   test_get_num_channelsz#SoundTypeTest.test_get_num_channels  s;   
	)#BGGLL$HIHKKX.EU335q9JJLU335q9JJLU335q9JJLU335q9LL''6MN )&&() ) ) LL''6MN )&&() ) )s0   C/E /E		E?F:F.%	F:.F73F:c                 b   	 d}t        t        j                  j                  dd            }t	        j
                  |      }|j                         }| j                  ||       t        j                  j                          | j                  t        j                  d      5  |j                          ddd       y# 1 sw Y   yxY w# t        j                  j                          | j                  t        j                  d      5  j                          ddd       w # 1 sw Y   w xY wxY w)z)Ensure a sound's volume can be retrieved.ry  rQ   rR   rS   rZ  N)r   r\   r]   r^   r   rc   rz  r{  rH   r"   r[  rI   r%   r|  r
  r   r}  s        r   r~  zSoundTypeTest.test_get_volume  s    	#!O#BGGLL$HIHKKX.E%%'F""6?;LL''6MN #  "# # # LL''6MN #  "# # #s0   A#C	 #B==C	?D.D"	D."D+'D.c                    	 d}t        t        j                  j                  dd            }t	        j
                  |      }|j                  d       |j                         }| j                  ||       t        j                  j                          | j                  t        j                  d      5  |j                          ddd       y# 1 sw Y   yxY w# t        j                  j                          | j                  t        j                  d      5  j                          ddd       w # 1 sw Y   w xY wxY w)z7Ensure a sound's volume can be retrieved while playing.ry  rQ   rR   rS   r   rZ  N)r   r\   r]   r^   r   rc   r   rz  r{  rH   r"   r[  rI   r  s        r   test_get_volume__while_playingz,SoundTypeTest.test_get_volume__while_playing  s    	#!O#BGGLL$HIHKKX.EJJrN%%'F""6?;LL''6MN #  "# # # LL''6MN #  "# # #s0   A4C 4CC?D?D3*	D?3D<8D?c           
         	 d}t        t        j                  j                  dd            }t	        j
                  |      }|j                         }d|fdddd	d
ddddf
}|D ]8  \  }}|j                  |       | j                  |j                         ||       : 	 t        j                  j                          | j                  t        j                  d      5  |j                  d       ddd       y# 1 sw Y   yxY w# t        j                  j                          | j                  t        j                  d      5  j                  d       ddd       w # 1 sw Y   w xY wxY w)z#Ensure a sound's volume can be set.      ?rQ   rR   rS   r   r   g        {Gz?r  皙?r  rU   rU   ?r  Gz?r  r   ry  皙?ry  g       @ry  deltarZ  r   N)r   r\   r]   r^   r   rc   rz  r  r{  rH   r"   r[  rI   r%   float_deltar
  r   current_volumevolumesvolume_set_valuer|  s           r   test_set_volumezSoundTypeTest.test_set_volume  sJ   	$#K#BGGLL$HIHKKX.E"--/N ^$G 6= 1 /  !12&&$$&{ '  LL''6MN $  #$ $ $ LL''6MN $  #$ $ $s0   BD C88D?E*E	E*E'#E*c           
         	 d}t        t        j                  j                  dd            }t	        j
                  |      }|j                         }d|fdddd	d
ddddf
}|j                  d       |D ]8  \  }}|j                  |       | j                  |j                         ||       : 	 t        j                  j                          | j                  t        j                  d      5  |j                  d       ddd       y# 1 sw Y   yxY w# t        j                  j                          | j                  t        j                  d      5  j                  d       ddd       w # 1 sw Y   w xY wxY w)z1Ensure a sound's volume can be set while playing.r	  rQ   rR   rS   r   r
  r  r  r  r  r  r  r  r  r  r  rZ  r   N)r   r\   r]   r^   r   rc   rz  r   r  r{  rH   r"   r[  rI   r  s           r   test_set_volume__while_playingz,SoundTypeTest.test_set_volume__while_playing  sX   	$#K#BGGLL$HIHKKX.E"--/N ^$G JJRJ 5< 1 /  !12&&$$&{ '  LL''6MN $  #$ $ $ LL''6MN $  #$ $ $s0   B.D /D

D?E<E0'	E<0E95E<c                 ~   	 d}t        t        j                  j                  dd            }t	        j
                  |      }|j                          | j                  |j                         |       t        j                  j                          | j                  t        j                  d      5  |j                          ddd       y# 1 sw Y   yxY w# t        j                  j                          | j                  t        j                  d      5  j                          ddd       w # 1 sw Y   w xY wxY w)z4Ensure stop can be called while not playing a sound.r   rQ   rR   rS   rZ  N)r   r\   r]   r^   r   rc   r	  r,   r>   rH   r"   r[  rI   r%   expected_channelsr
  r   s       r   r  zSoundTypeTest.test_stop  s    	 !#BGGLL$HIHKKX.EJJLU3357HILL''6MN 

   LL''6MN 

  s0   A1C 1CC?D<D0'	D<0D95D<c                    	 d}t        t        j                  j                  dd            }t	        j
                  |      }|j                  d       |j                          | j                  |j                         |       t        j                  j                          | j                  t        j                  d      5  |j                          ddd       y# 1 sw Y   yxY w# t        j                  j                          | j                  t        j                  d      5  j                          ddd       w # 1 sw Y   w xY wxY w)z"Ensure stop stops a playing sound.r   rQ   rR   rS   r   rZ  N)r   r\   r]   r^   r   rc   r   r	  r,   r>   rH   r"   r[  rI   r#  s       r   test_stop__while_playingz&SoundTypeTest.test_stop__while_playing  s    	 !#BGGLL$HIHKKX.EJJrNJJLU3357HILL''6MN 

   LL''6MN 

  s0   BC( CC%(?E'E8	EE
Ec                 <   	 d}t        j                  |      }|j                         }| j                  |t               | j                  ||       t        j                   j                          | j                  t        j                  d      5  |j                          ddd       y# 1 sw Y   yxY w# t        j                   j                          | j                  t        j                  d      5  j                          ddd       w # 1 sw Y   w xY wxY w)z.Ensure get_raw returns the correct bytestring.r  rW   rZ  N)
r   rc   rN   r   bytesr,   rH   r"   r[  rI   )r%   r  rO   raws       r   test_get_rawzSoundTypeTest.test_get_raw!  s    	!G++W-C++-C!!#u-S'*LL''6MN    LL''6MN   s0   AB6 B**B36?D5D	DDDc                      G d dt         j                        }t        t        j                  j                  dd            } ||      }	 |j                          y # t        $ r | j                  d       Y y w xY w)Nc                        e Zd Z fdZ xZS )>SoundTypeTest.test_correct_subclassing.<locals>.CorrectSublassc                 &    t         |   |       y )NrS   )super__init__)r%   rT   rP  s     r   r0  zGSoundTypeTest.test_correct_subclassing.<locals>.CorrectSublass.__init__2  s     d +r   )r   r   r   r0  __classcell__)rP  s   @r   CorrectSublassr-  1  s    , ,r   r2  rQ   rR   z#This should not raise an exception.)	r   rc   r   r\   r]   r^   rz  	Exceptionr   )r%   r2  r
  corrects       r   test_correct_subclassingz&SoundTypeTest.test_correct_subclassing0  sd    	,U[[ 	,  V^ DE *	=  	=II;<	=s   A A:9A:c                      G d dt         j                        } |       }| j                  t        |j                         y )Nc                       e Zd Zd Zy)BSoundTypeTest.test_incorrect_subclassing.<locals>.IncorrectSuclassc                      y r:   r   r$   s    r   r0  zKSoundTypeTest.test_incorrect_subclassing.<locals>.IncorrectSuclass.__init__?  s    r   N)r   r   r   r0  r   r   r   IncorrectSuclassr8  >  s    r   r:  )r   rc   rG   RuntimeErrorrz  )r%   r:  	incorrects      r   test_incorrect_subclassingz(SoundTypeTest.test_incorrect_subclassing=  s2    	u{{ 	 %&	,	(<(<=r   N)r   r   r   r  rH  rL  r  r  r  r  r  r  r  r  r}   r8  r;  r  r  r  r~  r  r  r!  r  r&  r*  r5  r=  r   r   r   r  r    s     36233
' X__Wk*% +%(#.)*## $B $D =>r   r  c                       e Zd Zd Zd Zd Zy)TestSoundFadeoutc                 j    t        j                         t        j                   j                          y y r:   )r   r+   rH   r)   r$   s    r   rL  zTestSoundFadeout.setUpH  s$    >>#LL $r   c                 @    t         j                  j                          y r:   rH   r   r"   r$   s    r   r&   zTestSoundFadeout.tearDownL      r   c                 @   t        t        j                  j                  dd            }t	        j
                  |      }|j                         }|j                  d       t        j                  j                  d       | j                  |j                                y)zaTests if fadeout stops sound playback after fading it out over the time argument in milliseconds.rQ   r  rS   rV   i  N)r   r\   r]   r^   r   rc   r   r   rH   r   r   r   r   )r%   r
  r   r  s       r   test_fadeout_with_valid_timez-TestSoundFadeout.test_fadeout_with_valid_timeO  si    V[ AB***,))+,r   N)r   r   r   rL  r&   rE  r   r   r   r?  r?  G  s     -r   r?  c                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)TestGetBusyz1Test pygame.mixer.get_busy.

    |tags:slow|
    c                 @    t         j                  j                          y r:   )rH   r   r)   r$   s    r   rL  zTestGetBusy.setUp{  rC  r   c                 @    t         j                  j                          y r:   rB  r$   s    r   r&   zTestGetBusy.tearDown~  rC  r   c                 ^    | j                  t        j                  j                                y)zL
        Test that get_busy returns False when no sound is playing.
        N)r   rH   r   r   r$   s    r   test_no_sound_playingz!TestGetBusy.test_no_sound_playing  s     	..01r   c                    t         j                  j                  t        d            }|j	                          t        j                  d       | j                  t         j                  j                                |j                          y)zL
        Test that get_busy returns True when one sound is playing.
        r   皙?N
rH   r   rc   r   r   r   sleeprd   r   r	  r%   r   s     r   test_one_sound_playingz"TestGetBusy.test_one_sound_playing  sT     ""<0C#DE



3--/0

r   c                    t         j                  j                  t        d            }t         j                  j                  t        d            }|j	                          |j	                          t        j                  d       | j                  t         j                  j                                |j                          |j                          y)zS
        Test that get_busy returns True when multiple sounds are playing.
        r   rM  NrN  r%   rr  rs  s      r   test_multiple_sounds_playingz(TestGetBusy.test_multiple_sounds_playing  s     ##L1D$EF##L1D$EF

3--/0r   c                    t         j                  j                  t        d            }t         j                  j                  t        d            }|j	                          |j	                          t        j                  d       |j                          |j                          t        j                  d       | j                  t         j                  j                                y)zO
        Test that get_busy returns False when all sounds are stopped.
        r   rM  N)
rH   r   rc   r   r   r   rO  r	  r   r   rS  s      r   test_all_sounds_stoppedz#TestGetBusy.test_all_sounds_stopped  s     ##L1D$EF##L1D$EF

3

3..01r   c                    t         j                  j                  t        d            }t         j                  j                  t        d            }|j	                          |j	                          t        j                  d       |j                  d       |j                  d       t        j                  d       | j                  t         j                  j                                y)zd
        Test that get_busy returns False when all sounds are stopped with
        fadeout.
        r   rM  r^  r  N)
rH   r   rc   r   r   r   rO  r   r   r   rS  s      r   $test_all_sounds_stopped_with_fadeoutz0TestGetBusy.test_all_sounds_stopped_with_fadeout  s    
 ##L1D$EF##L1D$EF

3ss

3..01r   c                    t         j                  j                  t        d            }|j	                  d       t        j                  d       | j                  t         j                  j                                |j                          y)z=Tests that get_busy() returns True when a sound is fading outr   rV   r  r  NrN  rP  s     r   test_sound_fading_outz!TestGetBusy.test_sound_fading_out  sW    ""<0C#DE

4
 

3--/0

r   N)r   r   r   r   rL  r&   rK  rQ  rT  rV  rX  rZ  r   r   r   rG  rG  u  s/    
222r   rG  __main__)ra   r\   r}   r  r9  r   r   r   r   rH   r   python_implementationr;  FREQUENCIESr  CHANNELSBUFFERSCONFIGSr*   r   TestCaser    rA  r  r  r  r  r?  rG  r   main)r   sr   s   000r   <module>rd     s   
 	      0  
2H224
4 +q6&  	 	
	 	
 QA... ba1	M Q	@h'' Q	@nw,h'' w,t@8,, @.)(++ )HY/H%% Y/xm>H%% m>`	-x(( -\L(## Lb zHMMO ]-s   E	