          bad_fk_map1 = copy(co_mapping)
          bad_fk_map1['state'] = 'name'
          bad_fk_map2 = copy(co_mapping)
          bad_fk_map2['state'] = {'nombre': 'State'}
          self.assertRaises(TypeError, LayerMapping, County, co_shp, bad_fk_map1, transform=False)
          self.assertRaises(LayerMapError, LayerMapping, County, co_shp, bad_fk_map2, transform=False)
  
          # There exist no State models for the ForeignKey mapping to work -- should raise
          # a MissingForeignKey exception (this error would be ignored if the `strict`
          # keyword is not set).
          lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')
 
</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(e, LayerMapping, County, co_shp, co_mapping, transform=False, unique=arg)
 </s> add             with self.assertRaises(e):
                LayerMapping(County, co_shp, co_mapping, transform=False, unique=arg) </s> remove         self.assertRaises(LayerMapError, LayerMapping,
                          Point3D, city_file, point_mapping, transform=False)
 </s> add         with self.assertRaises(LayerMapError):
            LayerMapping(Point3D, city_file, point_mapping, transform=False) </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)
        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)
          bad_fk_map1 = copy(co_mapping)
          bad_fk_map1['state'] = 'name'
          bad_fk_map2 = copy(co_mapping)
          bad_fk_map2['state'] = {'nombre': 'State'}
        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)
        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)
  
          # There exist no State models for the ForeignKey mapping to work -- should raise
          # a MissingForeignKey exception (this error would be ignored if the `strict`
          # keyword is not set).
          lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')
keep keep keep keep replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/gis_tests/layermap/tests.py