@@ -26,20 +26,24 @@ def setUp(cls):
2626
2727 def test_load_mp3 (self ):
2828 "|tags:music|"
29- self .music_load ("mp3" )
29+ self .music_load ("house_lo. mp3" )
3030
3131 def test_load_ogg (self ):
3232 "|tags:music|"
33- self .music_load ("ogg" )
33+ self .music_load ("house_lo. ogg" )
3434
3535 def test_load_wav (self ):
3636 "|tags:music|"
37- self .music_load ("wav" )
37+ self .music_load ("house_lo. wav" )
3838
39- def music_load (self , format ):
39+ def test_load_xm (self ):
40+ "|tags:music|"
41+ self .music_load ("surfonasinewave.xm" )
42+
43+ def music_load (self , filename ):
4044 data_fname = example_path ("data" )
4145
42- path = os .path .join (data_fname , f"house_lo. { format } " )
46+ path = os .path .join (data_fname , filename )
4347 if os .sep == "\\ " :
4448 path = path .replace ("\\ " , "\\ \\ " )
4549 umusfn = str (path )
@@ -50,10 +54,10 @@ def music_load(self, format):
5054
5155 def test_load_object (self ):
5256 """test loading music from file-like objects."""
53- formats = ["ogg" , "wav" ]
57+ filenames = ["house_lo. ogg" , "house_lo. wav" , "surfonasinewave.xm " ]
5458 data_fname = example_path ("data" )
55- for f in formats :
56- path = os .path .join (data_fname , f"house_lo. { f } " )
59+ for file in filenames :
60+ path = os .path .join (data_fname , file )
5761 if os .sep == "\\ " :
5862 path = path .replace ("\\ " , "\\ \\ " )
5963 bmusfn = path .encode ()
@@ -63,26 +67,28 @@ def test_load_object(self):
6367
6468 def test_object_namehint (self ):
6569 """test loading & queuing music from file-like objects with namehint argument."""
66- formats = ["wav" , "ogg " ]
70+ filenames = ["house_lo.ogg" , "house_lo. wav" , "surfonasinewave.xm " ]
6771 data_fname = example_path ("data" )
68- for f in formats :
69- path = os .path .join (data_fname , f"house_lo. { f } " )
72+ for file in filenames :
73+ path = os .path .join (data_fname , file )
7074 if os .sep == "\\ " :
7175 path = path .replace ("\\ " , "\\ \\ " )
7276 bmusfn = path .encode ()
7377
78+ * _ , format = file .split ("." )
79+
7480 # these two "with open" blocks need to be separate, which is kinda weird
7581 with open (bmusfn , "rb" ) as musf :
76- pygame .mixer .music .load (musf , f )
82+ pygame .mixer .music .load (musf , format )
7783
7884 with open (bmusfn , "rb" ) as musf :
79- pygame .mixer .music .queue (musf , f )
85+ pygame .mixer .music .queue (musf , format )
8086
8187 with open (bmusfn , "rb" ) as musf :
82- pygame .mixer .music .load (musf , namehint = f )
88+ pygame .mixer .music .load (musf , namehint = format )
8389
8490 with open (bmusfn , "rb" ) as musf :
85- pygame .mixer .music .queue (musf , namehint = f )
91+ pygame .mixer .music .queue (musf , namehint = format )
8692
8793 def test_load_unicode (self ):
8894 """test non-ASCII unicode path"""
@@ -143,6 +149,14 @@ def test_queue_wav(self):
143149 filename = example_path (os .path .join ("data" , "house_lo.wav" ))
144150 pygame .mixer .music .queue (filename )
145151
152+ def test_queue_xm (self ):
153+ """Ensures queue() accepts xm files (tracker music files).
154+
155+ |tags:music|
156+ """
157+ filename = example_path (os .path .join ("data" , "surfonasinewave.xm" ))
158+ pygame .mixer .music .queue (filename )
159+
146160 def test_queue__multiple_calls (self ):
147161 """Ensures queue() can be called multiple times."""
148162 ogg_file = example_path (os .path .join ("data" , "house_lo.ogg" ))
@@ -358,7 +372,7 @@ def test_get_busy(self):
358372 # music is idle this returns False.
359373 #
360374
361- self .music_load ("ogg" )
375+ self .music_load ("house_lo. ogg" )
362376 self .assertFalse (pygame .mixer .music .get_busy ())
363377 pygame .mixer .music .play ()
364378 self .assertTrue (pygame .mixer .music .get_busy ())
0 commit comments