New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some mixer Sound tests #1934
Conversation
While I was there, I also tried to do the get_length test above it. It kind of strange to essentially do the same thing pygame does and compare it... but I don't see how else I could do it. |
OK, for the
Suggests that there are three possible paths through the code on SDL 2, and two on on SDL 1, depening on the audio data started with. Probably the easiest way to test this is to find three audio file in each of the different formats and run each of them through the test. There is more detail on the SDL Audio spec here: https://wiki.libsdl.org/SDL_AudioSpec which covers what those audio format constants represent.
Lines 7 to 9 in ff86036
When testing a similar macro in the surface module there was a format for the unit tests that worked reasonably well:
The mixer tests may currently be set up in a slightly different way, I know there are For the I thought I was being a bit overzealous getting people to test this in the surface module, but then we actually found a bug in the SDL2 version's |
Ok. I will try to look at this in the next days. Thanks 😄 |
I started thinking about the get_length issue.
So at this point... It's not about testing with different files, but with different mixer formats. |
Ah right, well that makes it easier I guess you can just |
I have a question about the test for MIX_INIT_CHECK() Do you want to change all the tests that use it to see if they don't work when mixer is not initialized? This would mean calling mixer.init() and mixer.quit() for every test instead of only once in setUpClass and tearDownClass. I see that it was done this way to save on the initialization time :
but perhaps it's not so much of a problem anymore... |
I think it can take 1 second on some platforms. Perhaps all of them can be tested together in one method to raise? This way it would only init/quit once. mixer.quit()
...
# test all mixer functions raise when quit |
I suppose the best way is to test it out - if switching every test over to My preference, absent speed concerns, is to have it on every test for consistency with the surface module and general safety when refactoring and to create implicit guidelines/expectations for people writing new functions in the future. |
ok thanks! I may get the time to try some stuff in the next days. I converted the pr to a draft and I will let you know if I do something useful. 😄 |
I only wanted to add a test for Sound.get_num_channels 😄 So, if it's good enough, I'm fine if you want to merge the PR. If I ever decide to do some more tests, I will open a new one. Oh, and thank you for taking the time to look at my pr and making suggestions to make it better instead of rejecting it or simply changing it yourself. All of this is a really big and fun learning experience for me and it's really appreciated. 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, code and time wise, and all the CI tests pass! 👍 🎉
Thank you for the contribution.
I remembered a bug I fixed (#1431) a while ago that wasn't caught in unittests, so I made a really simple change to fix that.