old_contents: from BasicGeometry.polygon import Polygon
  
  
  class TestPolygon(unittest.TestCase):
      def setUp(self):
          pass
  
      def test_polygon1(self):
          polygon = Polygon()
          polygon.add_vertex(1, 1)
          polygon.add_vertex(1, 2)
          polygon.add_vertex(2, 3)
          polygon.add_vertex(3, 2.6)
          polygon.add_vertex(2.5, 0)
  
          self.assertTrue(polygon.contains(1.5, 1.5))
          self.assertFalse(polygon.contains(0, 1.5))
          self.assertFalse(polygon.contains(1.6, 3.1))
  
      def test_polygon2(self):
          polygon = Polygon()
          polygon.add_vertex(1, 1)
          polygon.add_vertex(1, 2)
          polygon.add_vertex(1.5, 1.5)
          polygon.add_vertex(3, 2.6)
          polygon.add_vertex(2.5, 0)
  
          self.assertFalse(polygon.contains(1.5, 1.6))
          self.assertFalse(polygon.contains(0, 1.5))
          self.assertTrue(polygon.contains(1.3, 1.7))
  
  
new_contents: from BasicGeometry import Polygon
  
  
  def test_initialize():
      polygon = Polygon([(1, 1), (1, 2), (2, 3), (3, 2.6), (2.5, 0)])
      assert polygon.vertices == [(1, 1), (1, 2), (2, 3), (3, 2.6), (2.5, 0)]
  
  def test_translate():
      polygon = Polygon([(1, 1), (1, 2), (2, 3)])
      polygon_tranlated = polygon.translate((2, 2))
      assert polygon_tranlated.vertices == [(3, 3), (3, 4), (4, 5)]
  
  def test_contains():
      polygon = Polygon()
      polygon.add_vertex((1, 1))
      polygon.add_vertex((1, 2))
      polygon.add_vertex((2, 3))
      polygon.add_vertex((3, 2.6))
      polygon.add_vertex((2.5, 0))
      assert polygon.contains((1.5, 1.5))
      assert (not polygon.contains((0, 1.5)))
      assert (not polygon.contains((1.6, 3.1)))
  
subject: update polygon test