lordmauve / pgzero

A zero-boilerplate games programming framework for Python 3, based on Pygame.
https://pygame-zero.readthedocs.io/
GNU Lesser General Public License v3.0
527 stars 191 forks source link

errors showing up on tests #305

Open saraaldosari opened 1 year ago

saraaldosari commented 1 year ago

I'm running the head version of pygame zero on MacOS 12.6, python 3.8.13 under a virtual environment. If I run the tests by doing python setup.py test I get failures saying the mixer is not initialized.

<SNIPPED OUT PASSING TESTS>

test_load_11kgsm (test.test_sound_formats.SoundFormatsTest) ... ERROR
test_load_11kulaw (test.test_sound_formats.SoundFormatsTest) ... ERROR
test_load_22k16bitpcm (test.test_sound_formats.SoundFormatsTest) ... ERROR
test_load_22k8bitpcm (test.test_sound_formats.SoundFormatsTest) ... ERROR
test_load_22kadpcm (test.test_sound_formats.SoundFormatsTest) ... ERROR
test_load_8k16bitpcm (test.test_sound_formats.SoundFormatsTest) ... ERROR
test_load_8k8bitpcm (test.test_sound_formats.SoundFormatsTest) ... ERROR
test_load_8kadpcm (test.test_sound_formats.SoundFormatsTest) ... ERROR
test_load_8kmp316 (test.test_sound_formats.SoundFormatsTest) ... ERROR
test_load_8kmp38 (test.test_sound_formats.SoundFormatsTest) ... ERROR
test_load_vorbis1 (test.test_sound_formats.SoundFormatsTest)
Load OGG Vorbis with .ogg extension. ... ERROR
test_load_vorbis2 (test.test_sound_formats.SoundFormatsTest)
Load OGG Vorbis with .oga extension. ... ERROR

======================================================================
ERROR: test_load_11kgsm (test.test_sound_formats.SoundFormatsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 44, in test_load_11kgsm
    self.assert_errmsg('wav22kgsm', 'WAV audio encoded as GSM')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 23, in assert_errmsg
    sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

======================================================================
ERROR: test_load_11kulaw (test.test_sound_formats.SoundFormatsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 47, in test_load_11kulaw
    self.assert_loadable('wav22kulaw')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 15, in assert_loadable
    s = sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

======================================================================
ERROR: test_load_22k16bitpcm (test.test_sound_formats.SoundFormatsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 26, in test_load_22k16bitpcm
    self.assert_loadable('wav22k16bitpcm')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 15, in assert_loadable
    s = sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

======================================================================
ERROR: test_load_22k8bitpcm (test.test_sound_formats.SoundFormatsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 29, in test_load_22k8bitpcm
    self.assert_loadable('wav22k8bitpcm')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 15, in assert_loadable
    s = sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

======================================================================
ERROR: test_load_22kadpcm (test.test_sound_formats.SoundFormatsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 32, in test_load_22kadpcm
    self.assert_loadable('wav22kadpcm')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 15, in assert_loadable
    s = sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

======================================================================
ERROR: test_load_8k16bitpcm (test.test_sound_formats.SoundFormatsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 35, in test_load_8k16bitpcm
    self.assert_loadable('wav8k16bitpcm')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 15, in assert_loadable
    s = sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

======================================================================
ERROR: test_load_8k8bitpcm (test.test_sound_formats.SoundFormatsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 38, in test_load_8k8bitpcm
    self.assert_loadable('wav8k8bitpcm')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 15, in assert_loadable
    s = sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

======================================================================
ERROR: test_load_8kadpcm (test.test_sound_formats.SoundFormatsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 41, in test_load_8kadpcm
    self.assert_loadable('wav8kadpcm')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 15, in assert_loadable
    s = sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

======================================================================
ERROR: test_load_8kmp316 (test.test_sound_formats.SoundFormatsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 50, in test_load_8kmp316
    self.assert_errmsg('wav8kmp316', 'WAV audio encoded as MP3')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 23, in assert_errmsg
    sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

======================================================================
ERROR: test_load_8kmp38 (test.test_sound_formats.SoundFormatsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 53, in test_load_8kmp38
    self.assert_errmsg('wav8kmp38', 'WAV audio encoded as MP3')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 23, in assert_errmsg
    sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

======================================================================
ERROR: test_load_vorbis1 (test.test_sound_formats.SoundFormatsTest)
Load OGG Vorbis with .ogg extension.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 57, in test_load_vorbis1
    self.assert_loadable('vorbis1')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 15, in assert_loadable
    s = sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

======================================================================
ERROR: test_load_vorbis2 (test.test_sound_formats.SoundFormatsTest)
Load OGG Vorbis with .oga extension.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 61, in test_load_vorbis2
    self.assert_loadable('vorbis2')
  File "/Users/school/temp/editable/pgzero/test/test_sound_formats.py", line 15, in assert_loadable
    s = sounds.load(name)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 140, in load
    res = self._cache[key] = self._load(p, *args, **kwargs)
  File "/Users/school/temp/editable/pgzero/pgzero/loaders.py", line 195, in _load
    return pygame.mixer.Sound(path)
pygame.error: mixer not initialized

----------------------------------------------------------------------
Ran 178 tests in 1.622s

FAILED (errors=12)
Test failed: <unittest.runner.TextTestResult run=178 errors=12 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=178 errors=12 failures=0>
/Users/school/temp/editable/pgzero/venv/lib/python3.8/site-packages/pygame/surfarray.py:47: UserWarning: The NumPy module was reloaded (imported a second time). This can in some cases result in small but subtle issues and is discouraged.
  import numpy
pygame 2.1.2 (SDL 2.0.18, Python 3.8.13)
Hello from the pygame community. https://www.pygame.org/contribute.html

However, if I run the failing unit test file on its own, i.e. by running python setup.py test -s test/test_sound_formats.py, I do not get any failures:

running test
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
running egg_info
writing pgzero.egg-info/PKG-INFO
writing dependency_links to pgzero.egg-info/dependency_links.txt
writing entry points to pgzero.egg-info/entry_points.txt
writing requirements to pgzero.egg-info/requires.txt
writing top-level names to pgzero.egg-info/top_level.txt
adding license file 'COPYING' (matched pattern 'COPYING*')
adding license file 'AUTHORS' (matched pattern 'AUTHORS*')
reading manifest file 'pgzero.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'README.txt'
no previously-included directories found matching 'doc/_build'
writing manifest file 'pgzero.egg-info/SOURCES.txt'
running build_ext
pygame 2.1.2 (SDL 2.0.18, Python 3.8.13)
Hello from the pygame community. https://www.pygame.org/contribute.html
test_load_11kgsm (test.test_sound_formats.SoundFormatsTest) ... ok
test_load_11kulaw (test.test_sound_formats.SoundFormatsTest) ... ok
test_load_22k16bitpcm (test.test_sound_formats.SoundFormatsTest) ... ok
test_load_22k8bitpcm (test.test_sound_formats.SoundFormatsTest) ... ok
test_load_22kadpcm (test.test_sound_formats.SoundFormatsTest) ... ok
test_load_8k16bitpcm (test.test_sound_formats.SoundFormatsTest) ... ok
test_load_8k8bitpcm (test.test_sound_formats.SoundFormatsTest) ... ok
test_load_8kadpcm (test.test_sound_formats.SoundFormatsTest) ... ok
test_load_8kmp316 (test.test_sound_formats.SoundFormatsTest) ... ok
test_load_8kmp38 (test.test_sound_formats.SoundFormatsTest) ... ok
test_load_vorbis1 (test.test_sound_formats.SoundFormatsTest)
Load OGG Vorbis with .ogg extension. ... ok
test_load_vorbis2 (test.test_sound_formats.SoundFormatsTest)
Load OGG Vorbis with .oga extension. ... ok

----------------------------------------------------------------------
Ran 12 tests in 0.049s

OK
/Users/school/temp/editable/pgzero/venv/lib/python3.8/site-packages/pygame/surfarray.py:47: UserWarning: The NumPy module was reloaded (imported a second time). This can in some cases result in small but subtle issues and is discouraged.
  import numpy
pygame 2.1.2 (SDL 2.0.18, Python 3.8.13)
Hello from the pygame community. https://www.pygame.org/contribute.html

Assuming this is a valid issue, rather than me running the tests incorrectly - as a neophyte I would like to have the opportunity to fix it. :)

(In which case some pointers to get to the bottom of the issue would be appreciated!)