  
          # Bad feature id ranges should raise a type error.
          bad_ranges = (5.0, 'foo', co_shp)
          for bad in bad_ranges:
              self.assertRaises(TypeError, lm.save, fid_range=bad)
  
          # Step keyword should not be allowed w/`fid_range`.
          fr = (3, 5)  # layer[3:5]
          self.assertRaises(LayerMapError, lm.save, fid_range=fr, step=10)
          lm.save(fid_range=fr)
 
</s> remove         self.assertRaises(LayerMapError, lm.save, fid_range=fr, step=10)
 </s> add         with self.assertRaises(LayerMapError):
            lm.save(fid_range=fr, step=10) </s> remove         self.assertRaises(MissingForeignKey, lm.save, silent=True, strict=True)
 </s> add         with self.assertRaises(MissingForeignKey):
            lm.save(silent=True, strict=True) </s> remove             self.assertRaises(LayerMapError, LayerMapping, County, co_shp, co_mapping)
 </s> add             with self.assertRaises(LayerMapError):
                LayerMapping(County, co_shp, co_mapping) </s> remove         self.assertRaises(TypeError, LayerMapping, County, co_shp, bad_fk_map1, transform=False)
        self.assertRaises(LayerMapError, LayerMapping, County, co_shp, bad_fk_map2, transform=False)
 </s> add         with self.assertRaises(TypeError):
            LayerMapping(County, co_shp, bad_fk_map1, transform=False)
        with self.assertRaises(LayerMapError):
            LayerMapping(County, co_shp, bad_fk_map2, transform=False) </s> remove         self.assertRaises(ValueError, Country.objects.filter, mpoly__relate=(23, 'foo'))
 </s> add         with self.assertRaises(ValueError):
            Country.objects.filter(mpoly__relate=(23, 'foo'))
            with self.assertRaises(TypeError):
                lm.save(fid_range=bad)
  
          # Bad feature id ranges should raise a type error.
          bad_ranges = (5.0, 'foo', co_shp)
          for bad in bad_ranges:
            with self.assertRaises(TypeError):
                lm.save(fid_range=bad)
  
          # Step keyword should not be allowed w/`fid_range`.
          fr = (3, 5)  # layer[3:5]
          self.assertRaises(LayerMapError, lm.save, fid_range=fr, step=10)
          lm.save(fid_range=fr)
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/gis_tests/layermap/tests.py