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

better rect tests using literal values #3190

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions test/rect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,27 +777,27 @@ def test_inflate__larger(self):
r = Rect(2, 4, 6, 8)
r2 = r.inflate(4, 6)

self.assertEqual(r.center, r2.center)
self.assertEqual(r.left - 2, r2.left)
self.assertEqual(r.top - 3, r2.top)
self.assertEqual(r.right + 2, r2.right)
self.assertEqual(r.bottom + 3, r2.bottom)
self.assertEqual(r.width + 4, r2.width)
self.assertEqual(r.height + 6, r2.height)
self.assertEqual(r2.center, (5, 8))
self.assertEqual(r2.left, 0)
self.assertEqual(r2.top, 1)
self.assertEqual(r2.right, 10)
self.assertEqual(r2.bottom, 15)
self.assertEqual(r2.width, 10)
self.assertEqual(r2.height, 14)

def test_inflate__smaller(self):
"""Ensures deflating a rect keeps its center the same
and shrinks dimensions by correct values."""
r = Rect(2, 4, 6, 8)
r2 = r.inflate(-4, -6)

self.assertEqual(r.center, r2.center)
self.assertEqual(r.left + 2, r2.left)
self.assertEqual(r.top + 3, r2.top)
self.assertEqual(r.right - 2, r2.right)
self.assertEqual(r.bottom - 3, r2.bottom)
self.assertEqual(r.width - 4, r2.width)
self.assertEqual(r.height - 6, r2.height)
self.assertEqual((5, 8), r2.center)
self.assertEqual(4, r2.left)
self.assertEqual(7, r2.top)
self.assertEqual(6, r2.right)
self.assertEqual(9, r2.bottom)
self.assertEqual(2, r2.width)
self.assertEqual(2, r2.height)

def test_inflate_ip__larger(self):
"""Ensures inflating a rect in place keeps its center the same
Expand All @@ -806,13 +806,13 @@ def test_inflate_ip__larger(self):
r2 = Rect(r)
r2.inflate_ip(4, 6)

self.assertEqual(r.center, r2.center)
self.assertEqual(r.left - 2, r2.left)
self.assertEqual(r.top - 3, r2.top)
self.assertEqual(r.right + 2, r2.right)
self.assertEqual(r.bottom + 3, r2.bottom)
self.assertEqual(r.width + 4, r2.width)
self.assertEqual(r.height + 6, r2.height)
self.assertEqual(r2.center, (5, 8))
self.assertEqual(r2.left, 0)
self.assertEqual(r2.top, 1)
self.assertEqual(r2.right, 10)
self.assertEqual(r2.bottom, 15)
self.assertEqual(r2.width, 10)
self.assertEqual(r2.height, 14)

def test_inflate_ip__smaller(self):
"""Ensures deflating a rect in place keeps its center the same
Expand All @@ -821,13 +821,13 @@ def test_inflate_ip__smaller(self):
r2 = Rect(r)
r2.inflate_ip(-4, -6)

self.assertEqual(r.center, r2.center)
self.assertEqual(r.left + 2, r2.left)
self.assertEqual(r.top + 3, r2.top)
self.assertEqual(r.right - 2, r2.right)
self.assertEqual(r.bottom - 3, r2.bottom)
self.assertEqual(r.width - 4, r2.width)
self.assertEqual(r.height - 6, r2.height)
self.assertEqual(r2.center, (5, 8))
self.assertEqual(r2.left, 4)
self.assertEqual(r2.top, 7)
self.assertEqual(r2.right, 6)
self.assertEqual(r2.bottom, 9)
self.assertEqual(r2.width, 2)
self.assertEqual(r2.height, 2)

def test_scale_by__larger_single_argument(self):
"""The scale method scales around the center of the rectangle"""
Expand Down
Loading