          MyPerson.objects.create(name="Bazza del Frob")
          LowerStatusPerson.objects.create(status="low", name="homer")
          max_id = Person.objects.aggregate(max_id=models.Max('id'))['max_id']
  
          self.assertRaises(
              Person.DoesNotExist,
              MyPersonProxy.objects.get,
              name='Zathras'
          )
          self.assertRaises(
              Person.MultipleObjectsReturned,
              MyPersonProxy.objects.get,
              id__lt=max_id + 1
          )
          self.assertRaises(
              Person.DoesNotExist,
              StatusPerson.objects.get,
              name='Zathras'
          )
  
          StatusPerson.objects.create(name='Bazza Jr.')
          StatusPerson.objects.create(name='Foo Jr.')
          max_id = Person.objects.aggregate(max_id=models.Max('id'))['max_id']
  
 
</s> remove         self.assertRaises(
            Person.MultipleObjectsReturned,
            StatusPerson.objects.get,
            id__lt=max_id + 1
        )
 </s> add         with self.assertRaises(Person.MultipleObjectsReturned):
            StatusPerson.objects.get(id__lt=max_id + 1) </s> remove         self.assertRaises(
            FieldError,
            lambda: Book.objects.all().annotate(num_authors=Count('foo'))
        )
 </s> add         with self.assertRaises(FieldError):
            Book.objects.all().annotate(num_authors=Count('foo')) </s> remove         self.assertRaises(
            FieldError,
            lambda: Book.objects.all().aggregate(num_authors=Count('foo'))
        )
 </s> add         with self.assertRaises(FieldError):
            Book.objects.all().aggregate(num_authors=Count('foo')) </s> remove         self.assertRaises(
            Book.DoesNotExist,
            Book.objects.get,
            title="Dive into Python"
        )
        self.assertRaises(
            Book.DoesNotExist,
            Book.objects.using('default').get,
            title="Dive into Python"
        )
 </s> add         with self.assertRaises(Book.DoesNotExist):
            Book.objects.get(title="Dive into Python")
        with self.assertRaises(Book.DoesNotExist):
            Book.objects.using('default').get(title="Dive into Python") </s> remove         self.assertRaises(
            FieldError,
            lambda: Author.objects.filter(firstname__exact="John")
        )
 </s> add         with self.assertRaises(FieldError):
            Author.objects.filter(firstname__exact="John")
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
          MyPerson.objects.create(name="Bazza del Frob")
          LowerStatusPerson.objects.create(status="low", name="homer")
          max_id = Person.objects.aggregate(max_id=models.Max('id'))['max_id']
  
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
        with self.assertRaises(Person.DoesNotExist):
            MyPersonProxy.objects.get(name='Zathras')
        with self.assertRaises(Person.MultipleObjectsReturned):
            MyPersonProxy.objects.get(id__lt=max_id + 1)
        with self.assertRaises(Person.DoesNotExist):
            StatusPerson.objects.get(name='Zathras')
  
          StatusPerson.objects.create(name='Bazza Jr.')
          StatusPerson.objects.create(name='Foo Jr.')
          max_id = Person.objects.aggregate(max_id=models.Max('id'))['max_id']
  
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/proxy_models/tests.py