  
          # This won't work because the Place we select is not a Restaurant (it's
          # a Supplier).
          p = Place.objects.get(name="Joe's Chickens")
          self.assertRaises(
              Restaurant.DoesNotExist, lambda: p.restaurant
          )
  
          self.assertEqual(p.supplier, s1)
          self.assertQuerysetEqual(
              self.italian_restaurant.provider.order_by("-name"), [
                  "Luigi's Pasta",
 
</s> remove         self.assertRaises(
            ItalianRestaurant.DoesNotExist,
            lambda: Place.objects.get(name="Demon Dogs").restaurant.italianrestaurant
        )
 </s> add         with self.assertRaises(ItalianRestaurant.DoesNotExist):
            Place.objects.get(name="Demon Dogs").restaurant.italianrestaurant </s> remove         self.assertRaises(
            Place.DoesNotExist,
            ItalianRestaurant.objects.get, name="The Noodle Void"
        )
 </s> add         with self.assertRaises(Place.DoesNotExist):
            ItalianRestaurant.objects.get(name="The Noodle Void") </s> remove         self.assertRaises(AttributeError, lambda: CommonInfo.objects.all())
 </s> add         with self.assertRaises(AttributeError):
            CommonInfo.objects.all() </s> remove         self.assertRaises(FieldError, Restaurant.objects.filter, supplier__name="foo")
 </s> add         with self.assertRaises(FieldError):
            Restaurant.objects.filter(supplier__name="foo") </s> remove         self.assertRaises(InvalidSessionKey,
                          self.backend()._key_to_file, "a\\b\\c")
 </s> add         with self.assertRaises(InvalidSessionKey):
            self.backend()._key_to_file("a\\b\\c")
        with self.assertRaises(Restaurant.DoesNotExist):
            p.restaurant
  
          # This won't work because the Place we select is not a Restaurant (it's
          # a Supplier).
          p = Place.objects.get(name="Joe's Chickens")
        with self.assertRaises(Restaurant.DoesNotExist):
            p.restaurant
        with self.assertRaises(Restaurant.DoesNotExist):
            p.restaurant
        with self.assertRaises(Restaurant.DoesNotExist):
            p.restaurant
  
          self.assertEqual(p.supplier, s1)
          self.assertQuerysetEqual(
              self.italian_restaurant.provider.order_by("-name"), [
                  "Luigi's Pasta",
keep keep keep keep replace replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/model_inheritance/tests.py