  
          # Ensuring bad byteorders are not accepted.
          for bad_byteorder in (-1, 2, 523, 'foo', None):
              # Equivalent of `wkb_w.byteorder = bad_byteorder`
              self.assertRaises(ValueError, wkb_w._set_byteorder, bad_byteorder)
  
          # Setting the byteorder to 0 (for Big Endian)
          wkb_w.byteorder = 0
          self.assertEqual(hex2, wkb_w.write_hex(g))
          self.assertEqual(wkb2, wkb_w.write(g))
 
</s> remove             self.assertRaises(ValueError, wkb_w._set_outdim, bad_outdim)
 </s> add             with self.assertRaises(ValueError):
                wkb_w._set_outdim(bad_outdim) </s> remove             self.assertRaises(forms.ValidationError, fld.to_python, wkt)
 </s> add             with self.assertRaises(forms.ValidationError):
                fld.to_python(wkt) </s> remove         self.assertRaises(
            FieldError,
            lambda: Book.objects.annotate(mean_age=Avg('authors__age')).annotate(Avg('mean_age'))
        )
 </s> add         with self.assertRaises(FieldError):
            Book.objects.annotate(mean_age=Avg('authors__age')).annotate(Avg('mean_age')) </s> remove             self.assertRaises(TypeError, fg1._set_ptr, bad_ptr)
            self.assertRaises(TypeError, fg2._set_ptr, bad_ptr)
 </s> add             with self.assertRaises(TypeError):
                fg1._set_ptr(bad_ptr)
            with self.assertRaises(TypeError):
                fg2._set_ptr(bad_ptr) </s> remove             self.assertRaises(TypeError, lm.save, fid_range=bad)
 </s> add             with self.assertRaises(TypeError):
                lm.save(fid_range=bad)
            with self.assertRaises(ValueError):
                wkb_w._set_byteorder(bad_byteorder)
  
          # Ensuring bad byteorders are not accepted.
          for bad_byteorder in (-1, 2, 523, 'foo', None):
              # Equivalent of `wkb_w.byteorder = bad_byteorder`
            with self.assertRaises(ValueError):
                wkb_w._set_byteorder(bad_byteorder)
  
          # Setting the byteorder to 0 (for Big Endian)
          wkb_w.byteorder = 0
          self.assertEqual(hex2, wkb_w.write_hex(g))
          self.assertEqual(wkb2, wkb_w.write(g))
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/gis_tests/geos_tests/test_io.py