                  self.assertEqual(p.ext_ring_cs, ring.tuple)
                  self.assertEqual(p.ext_ring_cs, poly[0].tuple)  # Testing __getitem__
  
              # Testing __getitem__ and __setitem__ on invalid indices
              self.assertRaises(IndexError, poly.__getitem__, len(poly))
              self.assertRaises(IndexError, poly.__setitem__, len(poly), False)
              self.assertRaises(IndexError, poly.__getitem__, -1 * len(poly) - 1)
  
              # Testing __iter__
              for r in poly:
                  self.assertEqual(r.geom_type, 'LinearRing')
                  self.assertEqual(r.geom_typeid, 2)
 
</s> remove             self.assertRaises(TypeError, Polygon, 0, [1, 2, 3])
            self.assertRaises(TypeError, Polygon, 'foo')
 </s> add             with self.assertRaises(TypeError):
                Polygon(0, [1, 2, 3])
            with self.assertRaises(TypeError):
                Polygon('foo') </s> remove         self.assertRaises(IndexError, popfcn, ul, self.limit)
        self.assertRaises(IndexError, popfcn, ul, -1 - self.limit)
 </s> add         with self.assertRaises(IndexError):
            popfcn(ul, self.limit)
        with self.assertRaises(IndexError):
            popfcn(ul, -1 - self.limit) </s> remove             self.assertRaises(IndexError, lambda: IndexErrorArticle.objects.all()[0])
            self.assertRaises(IndexError, IndexErrorArticle.objects.all().first)
            self.assertRaises(IndexError, IndexErrorArticle.objects.all().last)
 </s> add             with self.assertRaises(IndexError):
                IndexErrorArticle.objects.all()[0]
            with self.assertRaises(IndexError):
                IndexErrorArticle.objects.all().first()
            with self.assertRaises(IndexError):
                IndexErrorArticle.objects.all().last() </s> remove             self.assertRaises(IndexError, setfcn, ul, i)  # 'set index %d' % i)
            self.assertRaises(IndexError, getfcn, ul, i)  # 'get index %d' % i)
            self.assertRaises(IndexError, delfcn, ul, i)  # 'del index %d' % i)
 </s> add             with self.assertRaises(IndexError):  # 'set index %d' % i)
                setfcn(ul, i)
            with self.assertRaises(IndexError):  # 'get index %d' % i)
                getfcn(ul, i)
            with self.assertRaises(IndexError):  # 'del index %d' % i)
                delfcn(ul, i) </s> remove         self.assertRaises(IndexError, p._checkindex, 2)
        self.assertRaises(IndexError, p._checkindex, -3)
 </s> add         with self.assertRaises(IndexError):
            p._checkindex(2)
        with self.assertRaises(IndexError):
            p._checkindex(-3)
            with self.assertRaises(IndexError):
                poly.__getitem__(len(poly))
            with self.assertRaises(IndexError):
                poly.__setitem__(len(poly), False)
            with self.assertRaises(IndexError):
                poly.__getitem__(-1 * len(poly) - 1)
                  self.assertEqual(p.ext_ring_cs, ring.tuple)
                  self.assertEqual(p.ext_ring_cs, poly[0].tuple)  # Testing __getitem__
  
              # Testing __getitem__ and __setitem__ on invalid indices
            with self.assertRaises(IndexError):
                poly.__getitem__(len(poly))
            with self.assertRaises(IndexError):
                poly.__setitem__(len(poly), False)
            with self.assertRaises(IndexError):
                poly.__getitem__(-1 * len(poly) - 1)
            with self.assertRaises(IndexError):
                poly.__getitem__(len(poly))
            with self.assertRaises(IndexError):
                poly.__setitem__(len(poly), False)
            with self.assertRaises(IndexError):
                poly.__getitem__(-1 * len(poly) - 1)
            with self.assertRaises(IndexError):
                poly.__getitem__(len(poly))
            with self.assertRaises(IndexError):
                poly.__setitem__(len(poly), False)
            with self.assertRaises(IndexError):
                poly.__getitem__(-1 * len(poly) - 1)
  
              # Testing __iter__
              for r in poly:
                  self.assertEqual(r.geom_type, 'LinearRing')
                  self.assertEqual(r.geom_typeid, 2)
keep keep keep keep replace replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/gis_tests/geos_tests/test_geos.py