          # Assigning None fails: Place.restaurant is null=False
          self.assertRaises(ValueError, setattr, p, 'restaurant', None)
  
          # You also can't assign an object of the wrong type here
          self.assertRaises(ValueError, setattr, p, 'restaurant', p)
  
          # Creation using keyword argument should cache the related object.
          p = Place.objects.get(name="Demon Dogs")
          r = Restaurant(place=p)
          self.assertIs(r.place, p)
 
</s> remove         self.assertRaises(ValueError, setattr, p, 'restaurant', None)
 </s> add         with self.assertRaises(ValueError):
            setattr(p, 'restaurant', None) </s> remove         self.assertRaises(TemplateSyntaxError, FilterExpression, "article._hidden|upper", p)
 </s> add         with self.assertRaises(TemplateSyntaxError):
            FilterExpression("article._hidden|upper", p) </s> remove         self.assertRaises(Site.DoesNotExist, Site.objects.get_current)
 </s> add         with self.assertRaises(Site.DoesNotExist):
            Site.objects.get_current() </s> remove         self.assertRaises(ValueError, qs.aggregate, Union('name'))
 </s> add         with self.assertRaises(ValueError):
            qs.aggregate(Union('name')) </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
        with self.assertRaises(ValueError):
            setattr(p, 'restaurant', p)
          # Assigning None fails: Place.restaurant is null=False
          self.assertRaises(ValueError, setattr, p, 'restaurant', None)
  
          # You also can't assign an object of the wrong type here
        with self.assertRaises(ValueError):
            setattr(p, 'restaurant', p)
  
          # Creation using keyword argument should cache the related object.
          p = Place.objects.get(name="Demon Dogs")
          r = Restaurant(place=p)
          self.assertIs(r.place, p)
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/one_to_one/tests.py