          # 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')
          self.assertRaises(MissingForeignKey, lm.save, silent=True, strict=True)
  
          # Now creating the state models so the ForeignKey mapping may work.
          State.objects.bulk_create([
              State(name='Colorado'), State(name='Hawaii'), State(name='Texas')
          ])
 
</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(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, lm.save, fid_range=fr, step=10)
 </s> add         with self.assertRaises(LayerMapError):
            lm.save(fid_range=fr, step=10) </s> remove             self.assertRaises(TypeError, lm.save, fid_range=bad)
 </s> add             with self.assertRaises(TypeError):
                lm.save(fid_range=bad)
        with self.assertRaises(MissingForeignKey):
            lm.save(silent=True, strict=True)
          # 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')
        with self.assertRaises(MissingForeignKey):
            lm.save(silent=True, strict=True)
  
          # Now creating the state models so the ForeignKey mapping may work.
          State.objects.bulk_create([
              State(name='Colorado'), State(name='Hawaii'), State(name='Texas')
          ])
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