Skip to content
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

Improving Surface.get_rect and Surface.get_frect tests #2109

Closed
4 tasks
Matiiss opened this issue Apr 10, 2023 · 0 comments · Fixed by #2492
Closed
4 tasks

Improving Surface.get_rect and Surface.get_frect tests #2109

Matiiss opened this issue Apr 10, 2023 · 0 comments · Fixed by #2492
Labels

Comments

@Matiiss
Copy link
Member

Matiiss commented Apr 10, 2023

Both the tests for pygame.Surface.get_rect and pygame.Surface.get_frect lack a couple of tests for some of the main features of these methods. Using keyword arguments to set rect values. As well as checking whether appropriate exceptions are raised.

For both methods test:

  • whether using correct keyword argument(s) sets the appropriate rect attribute
  • that when using multiple different kwargs, only the last one is applied
  • that appropriate exceptions are raised when using kwarg names that don't match rect attributes (like centre instead of center)

For Rect:

  • add the difference between current get_rect and get_frect tests to get_rect (test position and instance type)

def test_get_rect(self):
"""Ensure a surface's rect can be retrieved."""
size = (16, 16)
surf = pygame.Surface(size)
rect = surf.get_rect()
self.assertEqual(rect.size, size)
########################################################################
def test_get_frect(self):
"""Ensure a surface's frect can be retrieved."""
size = (16.0, 16.0)
surf = pygame.Surface(size)
frect = surf.get_frect()
self.assertEqual(frect.topleft, (0.0, 0.0))
self.assertEqual(frect.size, size)
self.assertIsInstance(frect, pygame.FRect)

JorasOliveira added a commit to JorasOliveira/pygame-ce that referenced this issue Oct 2, 2023
@MyreMylar MyreMylar added Surface pygame.Surface tests tests (module) labels Oct 7, 2023
Matiiss pushed a commit that referenced this issue Oct 20, 2023
* Fix issue #2109: Added requested tests

* isolated test that only works when not using pypy

* Apply formatting

* formatting

* formatting

* added requested changes and merged latest main branch

* implemented requested changes, added more scenarios to test

---------

Co-authored-by: Dan Lawrence <danintheshed@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants