Skip to content

Commit

Permalink
pygame.Rect/FRect() init no args docs change, tests for FRect and sub…
Browse files Browse the repository at this point in the history
…classes
  • Loading branch information
damusss committed Jan 7, 2024
1 parent 9e530fe commit a0773c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/reST/ref/rect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
values to construct a Rect. This makes it easier to create Rects on the fly
as arguments to functions.

If no arguments are given, a zero Rect will be created (x, y, w, h = 0).
If no arguments are given, a zero Rect will be created (x=0, y=0, w=0, h=0).
This will only work when using the Rect/FRect class and not with functions
that require a Rect argument.

Expand Down
14 changes: 14 additions & 0 deletions test/rect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3298,6 +3298,13 @@ def test_frect_subscript(self):
self.assertSeqAlmostEqual5(r[3::-1], [4.8, 3.6, 2.4, 1.2])
self.assertRaises(TypeError, r.__getitem__, None)

def test_construction_no_args(self):
r = FRect()
self.assertEqual(r.x, 0.0)
self.assertEqual(r.y, 0.0)
self.assertEqual(r.w, 0.0)
self.assertEqual(r.h, 0.0)


class SubclassTest(unittest.TestCase):
class MyRect(Rect):
Expand Down Expand Up @@ -3373,6 +3380,13 @@ def test_collection_abc(self):
self.assertTrue(isinstance(mr1, Collection))
self.assertFalse(isinstance(mr1, Sequence))

def test_construction_no_args(self):
mr = self.MyRect()
self.assertEqual(mr.x, 0)
self.assertEqual(mr.y, 0)
self.assertEqual(mr.w, 0)
self.assertEqual(mr.h, 0)


if __name__ == "__main__":
unittest.main()

0 comments on commit a0773c5

Please sign in to comment.