-
Notifications
You must be signed in to change notification settings - Fork 3.7k
added unit test for image.load_extended() #2014
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
Conversation
Thank you for having a go at writing a test, but I suspect this function needs a little more testing of its purpose which is to load image formats other than .bmp. I would expect a test to have a go at loading at least some file types from this list in the docs page:
I believe some of these file types are already included in the pygame package in the example/demo folder. See For example, the test you almost succeeded in writing is actually already covered in another test here: https://github.com/pygame/pygame/blob/master/test/imageext_test.py#L21-L22 If you need to add any new data files that are not already in: https://github.com/pygame/pygame/tree/master/examples/data Then they should be small files (e.g. 32x32 pixels) and added to that directory. If that sounds too difficult then feel free to let us know and move on and I'll add this extra information to the original issue. |
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.
As above
Hey, I am writing to you with a request of some help... Even though I tried
I think I don't really understand how to write a unit test. There are a
couple of examples that I thoroughly understood, but when it comes to real
world examples like that in pygame, my brain starts to struggle. Could you
please show me some tests pretty similar to that one I was assigned to do
and explain it to me? I would be glad to help with improving pygame, but
first of all I need to learn how to do it, lol. Thanks in advance!!!
|
Sure no problem, there is a guide written by @illume on how to write unit tests here and there are lots of example tests in the tests folder of the GitHub repo. For example here is one for Lines 809 to 841 in 6dbff91
Don't worry if you don't figure out writing tests the first time you try, it's all good practice! The general approach when writing a function unit test is to check that everything the function is supposed to do works (the documentation is a good starting place, but reading the code helps too) and everything it's supposed to fail at fails correctly (here you generally need to look at the code for assertions/errors). You can also try to push some limits with parameter inputs, unexpected but still accepted ones for example and see if the behaviour is what you would expect. I'll close this PR for now as we are gearing up for a release, but feel free to come back at a later date if you have a fresh take. |
it's my very first contribution as well as unit test, so please tell me if something is wrong and how should i fix that