From 82550c448b42059a627bfbf40b5f8539b22d7406 Mon Sep 17 00:00:00 2001 From: Chaebin-Kim24 <161917587+Chaebin-Kim24@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:28:54 +0900 Subject: [PATCH 1/2] Update test_turtle.py (added TestRawTurtle.test_clone() test_turtle.TestRawTurtle.test_clone(self): assert the last item in the items list of the cloned turtle is correct. more specifically, the item should be the same as the currentLineItem of the cloned turtle. also, the currentLineItem of the original turtle should not be in the items list of the cloned turtle. test_turtle.TestRawTurtle.setUp(self): skip test if the RawTurtle cannot be initialized because tk/tcl is not supported --- Lib/test/test_turtle.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Lib/test/test_turtle.py b/Lib/test/test_turtle.py index c75a002a89b4c4..8197b2130761b7 100644 --- a/Lib/test/test_turtle.py +++ b/Lib/test/test_turtle.py @@ -466,6 +466,20 @@ def test_teleport(self): self.assertTrue(tpen.isdown()) + +class TestRawTurtle(unittest.TestCase): + def setUp(self): + try: + self.screen = turtle.Screen() + except turtle.TK.TclError: + raise unittest.SkipTest() # cannot instantiate RawTurtle without a screen + + def test_clone(self): + rawturtle = turtle.RawTurtle(self.screen) + another_turtle = rawturtle.clone() + self.assertEqual(another_turtle.currentLineItem, another_turtle.items[-1]) + self.assertFalse(rawturtle.currentLineItem in another_turtle.items) + class TestTurtleScreen(unittest.TestCase): def test_save_raises_if_wrong_extension(self) -> None: screen = unittest.mock.Mock() From 724ac4a916e450ba9f256c2a5db68e8a54923f30 Mon Sep 17 00:00:00 2001 From: Chaebin-Kim24 <161917587+Chaebin-Kim24@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:30:12 +0900 Subject: [PATCH 2/2] Update test_turtle.py edited spacings --- Lib/test/test_turtle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_turtle.py b/Lib/test/test_turtle.py index 8197b2130761b7..086b5fe52878d3 100644 --- a/Lib/test/test_turtle.py +++ b/Lib/test/test_turtle.py @@ -466,7 +466,6 @@ def test_teleport(self): self.assertTrue(tpen.isdown()) - class TestRawTurtle(unittest.TestCase): def setUp(self): try: @@ -480,6 +479,7 @@ def test_clone(self): self.assertEqual(another_turtle.currentLineItem, another_turtle.items[-1]) self.assertFalse(rawturtle.currentLineItem in another_turtle.items) + class TestTurtleScreen(unittest.TestCase): def test_save_raises_if_wrong_extension(self) -> None: screen = unittest.mock.Mock()