def test_get_audio_driver(self): founddummy = False drivercount = audio.get_num_audio_drivers() for index in range(drivercount): drivername = audio.get_audio_driver(index) self.assertIsInstance(drivername, str) if drivername == "dummy": founddummy = True self.assertTrue(founddummy, "could not find dummy driver") self.assertRaises(sdl.SDLError, audio.get_audio_driver, -1) self.assertRaises(sdl.SDLError, audio.get_audio_driver, drivercount + 1) self.assertRaises(TypeError, audio.get_audio_driver, "Test") self.assertRaises(TypeError, audio.get_audio_driver, None)
def test_get_current_audio_driver(self): success = 0 for index in range(audio.get_num_audio_drivers()): drivername = audio.get_audio_driver(index) try: os.environ["SDL_AUDIODRIVER"] = drivername # Certain drivers fail without bringing up the correct # return value, such as the esd, if it is not running. sdl.init_subsystem(sdl.SDL_INIT_AUDIO) driver = audio.get_current_audio_driver() # Do not handle wrong return values. if driver is not None: self.assertEqual(drivername, driver) success += 1 except sdl.SDLError: pass else: sdl.quit_subsystem(sdl.SDL_INIT_AUDIO) self.assertGreaterEqual(success, 1, "Could not initialize any sound driver")