From 1932b82552bae33651b9b35382dcd4104602dcc9 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Wed, 16 Oct 2024 14:29:13 +0200 Subject: [PATCH 1/7] Changes to be commited: new file: test.txt --- test.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 0000000000..e69de29bb2 From 49dbee5fd853456b345f7c210ec41b2c989badd4 Mon Sep 17 00:00:00 2001 From: GabrieleLS Date: Wed, 16 Oct 2024 14:30:57 +0200 Subject: [PATCH 2/7] Delete test.txt --- test.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test.txt diff --git a/test.txt b/test.txt deleted file mode 100644 index e69de29bb2..0000000000 From 969cdce4ad48b137a02dba40b22a223b02d2c45b Mon Sep 17 00:00:00 2001 From: AntoineMamou Date: Wed, 23 Oct 2024 12:07:19 +0200 Subject: [PATCH 3/7] Fix functions in rect_test to use literal values for attribute checks --- test/rect_test.py | 56 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/test/rect_test.py b/test/rect_test.py index 0ad1af77c3..e916af89d7 100644 --- a/test/rect_test.py +++ b/test/rect_test.py @@ -777,13 +777,13 @@ 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 @@ -791,13 +791,13 @@ def test_inflate__smaller(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((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 @@ -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 @@ -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""" From 1ff6822b33e0583f6fcf13aa2a5925047fed1898 Mon Sep 17 00:00:00 2001 From: GabrieleLS Date: Wed, 4 Dec 2024 15:23:25 +0100 Subject: [PATCH 4/7] Addition of a function that tests the good initialization of all the attributes of a rect, in rect_tests.py --- test/rect_test.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/rect_test.py b/test/rect_test.py index e916af89d7..2c26e395bd 100644 --- a/test/rect_test.py +++ b/test/rect_test.py @@ -52,6 +52,39 @@ def testCalculatedAttributes(self): self.assertEqual((r.left, r.centery), r.midleft) self.assertEqual((r.right, r.centery), r.midright) + def testAttributes(self): + """Checks that all the attributes are initialized correctly.""" + r = Rect(1, 2, 3, 4) + + self.assertEqual(1, r.left) + self.assertEqual(2, r.top) + self.assertEqual(4, r.right) + self.assertEqual(6, r.bottom) + + self.assertEqual(1, r.x) + self.assertEqual(2, r.y) + + self.assertEqual(3, r.w) + self.assertEqual(4, r.h) + + self.assertEqual((1, 2), r.topleft) + self.assertEqual((4, 2), r.topright) + self.assertEqual((1, 6), r.bottomleft) + self.assertEqual((4, 6), r.bottomright) + + self.assertEqual((3, 4), r.size) + self.assertEqual(3, r.width) + self.assertEqual(4, r.height) + + self.assertEqual(2, r.centerx) + self.assertEqual(4, r.centery) + self.assertEqual((2, 4), r.center) + + self.assertEqual((2, 2), r.midtop) + self.assertEqual((2, 6), r.midbottom) + self.assertEqual((1, 4), r.midleft) + self.assertEqual((4, 4), r.midright) + def testRepr(self): rect = Rect(12, 34, 56, 78) self.assertEqual(repr(rect), "Rect(12, 34, 56, 78)") From f693fd11c7683a064661b5aa519cdeb68c05c377 Mon Sep 17 00:00:00 2001 From: GabrieleLS Date: Wed, 4 Dec 2024 15:35:00 +0100 Subject: [PATCH 5/7] Update rect_test.py --- test/rect_test.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/rect_test.py b/test/rect_test.py index 2c26e395bd..20af675b5f 100644 --- a/test/rect_test.py +++ b/test/rect_test.py @@ -824,13 +824,13 @@ def test_inflate__smaller(self): r = Rect(2, 4, 6, 8) r2 = r.inflate(-4, -6) - 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) + 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 From 41d4b7661c68087eafacc54550cc65524fb51a20 Mon Sep 17 00:00:00 2001 From: Dan Lawrence Date: Tue, 31 Dec 2024 12:11:52 +0000 Subject: [PATCH 6/7] Handle FRect --- test/rect_test.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/test/rect_test.py b/test/rect_test.py index 20af675b5f..7035e7551d 100644 --- a/test/rect_test.py +++ b/test/rect_test.py @@ -76,14 +76,25 @@ def testAttributes(self): self.assertEqual(3, r.width) self.assertEqual(4, r.height) - self.assertEqual(2, r.centerx) - self.assertEqual(4, r.centery) - self.assertEqual((2, 4), r.center) - - self.assertEqual((2, 2), r.midtop) - self.assertEqual((2, 6), r.midbottom) - self.assertEqual((1, 4), r.midleft) - self.assertEqual((4, 4), r.midright) + if isinstance(r, FRect): + self.assertEqual(2.5, r.centerx) + self.assertEqual(4, r.centery) + self.assertEqual((2.5, 4), r.center) + + self.assertEqual((2.5, 2), r.midtop) + self.assertEqual((2.5, 6), r.midbottom) + self.assertEqual((1, 4), r.midleft) + self.assertEqual((4, 4), r.midright) + + elif isinstance(r, Rect): + self.assertEqual(2, r.centerx) + self.assertEqual(4, r.centery) + self.assertEqual((2, 4), r.center) + + self.assertEqual((2, 2), r.midtop) + self.assertEqual((2, 6), r.midbottom) + self.assertEqual((1, 4), r.midleft) + self.assertEqual((4, 4), r.midright) def testRepr(self): rect = Rect(12, 34, 56, 78) From 19cb1a135cc0e3af65f72ada747073b9a7975dd5 Mon Sep 17 00:00:00 2001 From: Dan Lawrence Date: Tue, 31 Dec 2024 12:17:09 +0000 Subject: [PATCH 7/7] fix formatting --- test/rect_test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/rect_test.py b/test/rect_test.py index 7035e7551d..fb8c6e626c 100644 --- a/test/rect_test.py +++ b/test/rect_test.py @@ -851,12 +851,12 @@ def test_inflate_ip__larger(self): r2.inflate_ip(4, 6) 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) + 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