MCPcopy Index your code
hub / github.com/python/cpython / test_create_polygon

Method test_create_polygon

Lib/test/test_tkinter/test_widgets.py:948–979  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

946 lambda **kwargs: c.create_line(20, 30, 60, 10, **kwargs))
947
948 def test_create_polygon(self):
949 c = self.create()
950 # In Tk < 8.7 polygons are filled, but has no outline by default.
951 # This affects its size, so always explicitly specify outline.
952 i1 = c.create_polygon(20, 30, 40, 50, 60, 10, outline='red')
953 self.assertEqual(c.coords(i1), [20.0, 30.0, 40.0, 50.0, 60.0, 10.0])
954 self.assertEqual(c.bbox(i1), (18, 8, 62, 52))
955 self.assertEqual(c.itemcget(i1, 'joinstyle'), 'round')
956 self.assertEqual(c.itemcget(i1, 'smooth'), '0')
957 self.assertEqual(c.itemcget(i1, 'splinestep'), '12')
958
959 i2 = c.create_polygon([21, 31, 41, 51, 61, 11], outline='red')
960 self.assertEqual(c.coords(i2), [21.0, 31.0, 41.0, 51.0, 61.0, 11.0])
961 self.assertEqual(c.bbox(i2), (19, 9, 63, 53))
962
963 i3 = c.create_polygon((22, 32), (42, 52), (62, 12), outline='red')
964 self.assertEqual(c.coords(i3), [22.0, 32.0, 42.0, 52.0, 62.0, 12.0])
965 self.assertEqual(c.bbox(i3), (20, 10, 64, 54))
966
967 i4 = c.create_polygon([(23, 33), (43, 53), (63, 13)], outline='red')
968 self.assertEqual(c.coords(i4), [23.0, 33.0, 43.0, 53.0, 63.0, 13.0])
969 self.assertEqual(c.bbox(i4), (21, 11, 65, 55))
970
971 self.assertRaises(TclError, c.create_polygon, 20, 30, 60)
972 self.assertRaises(TclError, c.create_polygon, [20, 30, 60])
973 self.assertRaises(IndexError, c.create_polygon)
974 self.assertRaises(IndexError, c.create_polygon, [])
975
976 self._test_option_joinstyle(c,
977 lambda **kwargs: c.create_polygon(20, 30, 40, 50, 60, 10, **kwargs))
978 self._test_option_smooth(c,
979 lambda **kwargs: c.create_polygon(20, 30, 40, 50, 60, 10, **kwargs))
980
981 def test_coords(self):
982 c = self.create()

Callers

nothing calls this directly

Calls 9

createMethod · 0.95
_test_option_smoothMethod · 0.95
create_polygonMethod · 0.80
assertEqualMethod · 0.45
coordsMethod · 0.45
bboxMethod · 0.45
itemcgetMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected