Open
Description
The test_sound_normal_load_and_playback
fails on MacOS (see full output below) with Python 3.13.
Can this be fixed or Is OGG not supported on MacOS?
Suggestion: remove the try/except here in load_sound
:
Lines 242 to 247 in 333ce6e
Forcing the exception to change type to FileNotFoundError
is incorrect and thus confusing in this case. It's also not necessary since the Sound(...)
init will raise a FileNotFoundError
already if the file isn't there.
Would it be easy / desired to add MacOS testing to Github CI?
(.env) cdeil@Kryvoff-MBP arcade % pytest tests/unit/test_sound.py::test_sound_normal_load_and_playback
================================ test session starts =================================
platform darwin -- Python 3.13.1, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/cdeil/code/oss/arcade
configfile: pyproject.toml
plugins: cov-5.0.0, anyio-4.8.0, mock-3.14.0
collected 1 item
tests/unit/test_sound.py F [100%]
====================================== FAILURES ======================================
________________________ test_sound_normal_load_and_playback _________________________
path = ':resources:sounds/laser1.ogg', streaming = False
def load_sound(path: str | Path, streaming: bool = False) -> Sound:
"""Load a file as a :py:class:`Sound` data object.
.. important:: A :py:class:`Sound` with ``streaming=True`` loses features!
Neither ``loop`` nor simultaneous playbacks will work. See
:py;class:`Sound` and :ref:`sound-loading-modes`.
Args:
path: a path which may be prefixed with a
:ref:`resource_handle <resource_handles>`.
streaming: Boolean for determining if we stream the sound or
load it all into memory. Set to ``True`` for long sounds to
save memory, ``False`` for short sounds to speed playback.
Returns:
A :ref:playable <sound-basics-playing>` instance of a
:py:class:`Sound` object.
"""
# Initialize the audio driver if it hasn't been already.
# This call is to avoid audio driver initialization
# the first time a sound is played.
# This call is inexpensive if the driver is already initialized.
media.get_audio_driver()
file_name = str(path)
try:
> return Sound(file_name, streaming)
arcade/sound.py:243:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arcade/sound.py:73: in __init__
self.source: Source = media.load(self.file_name, streaming=streaming)
.env/lib/python3.13/site-packages/pyglet/media/__init__.py:85: in load
return _codec_registry.decode(filename, file, streaming=streaming)
.env/lib/python3.13/site-packages/pyglet/util.py:175: in decode
return decoder.decode(filename, file, **kwargs)
.env/lib/python3.13/site-packages/pyglet/media/codecs/coreaudio.py:177: in decode
return StaticSource(CoreAudioSource(filename, file))
.env/lib/python3.13/site-packages/pyglet/media/codecs/coreaudio.py:56: in __init__
err_check(ca.ExtAudioFileOpenURL(url_ref, byref(audref)))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
err = 1954115647
def err_check(err: int) -> None:
"""Raise an exception of somethings wrong, otherwise return None.
Raises:
CoreAudioException
"""
if err != 0:
> raise CoreAudioException(err, err_str_db.get(err, "Unknown Error"))
E pyglet.libs.darwin.coreaudio.CoreAudioException: (1954115647, 'The file type is not supported.')
.env/lib/python3.13/site-packages/pyglet/libs/darwin/coreaudio.py:239: CoreAudioException
The above exception was the direct cause of the following exception:
window = Window=(width=1280, height=720)
def test_sound_normal_load_and_playback(window):
global frame_count, player
laser_wav = arcade.load_sound(":resources:sounds/laser1.wav")
laser_mp3 = arcade.load_sound(":resources:sounds/laser1.mp3")
> laser_ogg = arcade.load_sound(":resources:sounds/laser1.ogg")
tests/unit/test_sound.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
path = ':resources:sounds/laser1.ogg', streaming = False
def load_sound(path: str | Path, streaming: bool = False) -> Sound:
"""Load a file as a :py:class:`Sound` data object.
.. important:: A :py:class:`Sound` with ``streaming=True`` loses features!
Neither ``loop`` nor simultaneous playbacks will work. See
:py;class:`Sound` and :ref:`sound-loading-modes`.
Args:
path: a path which may be prefixed with a
:ref:`resource_handle <resource_handles>`.
streaming: Boolean for determining if we stream the sound or
load it all into memory. Set to ``True`` for long sounds to
save memory, ``False`` for short sounds to speed playback.
Returns:
A :ref:playable <sound-basics-playing>` instance of a
:py:class:`Sound` object.
"""
# Initialize the audio driver if it hasn't been already.
# This call is to avoid audio driver initialization
# the first time a sound is played.
# This call is inexpensive if the driver is already initialized.
media.get_audio_driver()
file_name = str(path)
try:
return Sound(file_name, streaming)
except Exception as ex:
> raise FileNotFoundError(
f'Unable to load sound file: "{file_name}". Exception: {ex}'
) from ex
E FileNotFoundError: Unable to load sound file: ":resources:sounds/laser1.ogg". Exception: (1954115647, 'The file type is not supported.')
arcade/sound.py:245: FileNotFoundError
------------------------------- Captured stderr setup --------------------------------
2025-01-31 19:12:34.004 Python[56782:13820327] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/q6/tz487k3j71x0cn2yn_3y144h0000gn/T/org.python.python.savedState
============================== short test summary info ===============================
FAILED tests/unit/test_sound.py::test_sound_normal_load_and_playback - FileNotFoundError: Unable to load sound file: ":resources:sounds/laser1.ogg". Exc...
================================= 1 failed in 0.20s ==================================
Activity