pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
830 stars 138 forks source link

Incorrect tests & missing test in ``rect_test`` #3096

Open bilhox opened 2 weeks ago

bilhox commented 2 weeks ago

I'm opening this issue as I don't want to work on it for the moment.

I have noticed many errors when I tried to implement rel_center :

avpai-dinosaur commented 2 weeks ago

Hi @bilhox,

I'm happy to work on this issue. I see the problem with inflate_ipsmaller's docstring. Also the fact that test_inflage_iplarger isn't actually making the rect larger.

I agree that the test should have some comparison to literal values. I'm wondering if there is a case where the comparison with attribute succeeds but the comparison to a literal value would fail as that would be the best test case to add.

In any case I can submit a pull request for this.

avpai-dinosaur commented 2 weeks ago

Actually while working on this I've become less convinced that checks need to be done for literal values. If the previous tests for the attributes work then it seems redundant to add tests for literal values vs just using the attributes. Further comparing to attributes is much more readable.

I'm going to submit the pull request to fix the docstring and test_inflate_ip__larger but hold off on making the cases with literal values. I think it should be two separate commits anyways since many other tests for rect use comparison to attributes (so if there is a reason to compare to literals we should probably add literals to those other tests as well)

Could you expand on why comparison to attributes isn't sufficient?

bilhox commented 2 weeks ago

Could you expand on why comparison to attributes isn't sufficient?

Basically, it's more a question of ethic, you can't just check if the value is correct using other attributes in a test case. I talked with some python pros about this, they did not really suggest new tests, but what they think it's the most suitable is to actually use literal values which you can predict way before attribute values.

Thank you for taking care of this issue !

bilhox commented 2 weeks ago

Reopenening it as there is a missing task.