          # Making sure the right exception is raised for the given
          # bad arguments.
          for bad_args, e in [((pnt1, 0), ValueError), ((pnt2, 'T*T***FF*', 0), ValueError)]:
              qs = Country.objects.filter(mpoly__relate=bad_args)
              self.assertRaises(e, qs.count)
  
          # Relate works differently for the different backends.
          if postgis or spatialite:
              contains_mask = 'T*T***FF*'
              within_mask = 'T*F**F***'
 
</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')) </s> remove             self.assertRaises(GeoIP2Exception, GeoIP2, cache=bad)
 </s> add             with self.assertRaises(GeoIP2Exception):
                GeoIP2(cache=bad) </s> remove             self.assertRaises(GeoIPException, GeoIP, cache=bad)
 </s> add             with self.assertRaises(GeoIPException):
                GeoIP(cache=bad) </s> remove         self.assertRaises(ObjectDoesNotExist, get_current_site, request)
 </s> add         with self.assertRaises(ObjectDoesNotExist):
            get_current_site(request) </s> remove         self.assertRaises(TypeError, qs.kml, 'name')
 </s> add         with self.assertRaises(TypeError):
            qs.kml('name')
            with self.assertRaises(e):
                qs.count()
          # Making sure the right exception is raised for the given
          # bad arguments.
          for bad_args, e in [((pnt1, 0), ValueError), ((pnt2, 'T*T***FF*', 0), ValueError)]:
              qs = Country.objects.filter(mpoly__relate=bad_args)
            with self.assertRaises(e):
                qs.count()
  
          # Relate works differently for the different backends.
          if postgis or spatialite:
              contains_mask = 'T*T***FF*'
              within_mask = 'T*F**F***'
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/gis_tests/geoapp/tests.py