          c3.save()
  
          self.assertEqual(c1.get_next_by_pub_date(), c2)
          self.assertEqual(c2.get_next_by_pub_date(), c3)
          self.assertRaises(
              ArticleWithAuthor.DoesNotExist,
              c3.get_next_by_pub_date)
          self.assertEqual(c3.get_previous_by_pub_date(), c2)
          self.assertEqual(c2.get_previous_by_pub_date(), c1)
          self.assertRaises(
              ArticleWithAuthor.DoesNotExist,
              c1.get_previous_by_pub_date)
 
</s> remove         self.assertRaises(
            ArticleWithAuthor.DoesNotExist,
            c1.get_previous_by_pub_date)
 </s> add         with self.assertRaises(ArticleWithAuthor.DoesNotExist):
            c1.get_previous_by_pub_date() </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(
            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'
        )
 </s> add         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') </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(
                NotImplementedError,
                models.Item.objects.all().aggregate, aggregate('time'))
            self.assertRaises(
                NotImplementedError,
                models.Item.objects.all().aggregate, aggregate('date'))
            self.assertRaises(
                NotImplementedError,
                models.Item.objects.all().aggregate, aggregate('last_modified'))
            self.assertRaises(
                NotImplementedError,
                models.Item.objects.all().aggregate,
                **{'complex': aggregate('last_modified') + aggregate('last_modified')})
 </s> add             with self.assertRaises(NotImplementedError):
                models.Item.objects.all().aggregate(aggregate('time'))
            with self.assertRaises(NotImplementedError):
                models.Item.objects.all().aggregate(aggregate('date'))
            with self.assertRaises(NotImplementedError):
                models.Item.objects.all().aggregate(aggregate('last_modified'))
            with self.assertRaises(NotImplementedError):
                models.Item.objects.all().aggregate(
                    **{'complex': aggregate('last_modified') + aggregate('last_modified')}
                )
        with self.assertRaises(ArticleWithAuthor.DoesNotExist):
            c3.get_next_by_pub_date()
          c3.save()
  
          self.assertEqual(c1.get_next_by_pub_date(), c2)
          self.assertEqual(c2.get_next_by_pub_date(), c3)
        with self.assertRaises(ArticleWithAuthor.DoesNotExist):
            c3.get_next_by_pub_date()
        with self.assertRaises(ArticleWithAuthor.DoesNotExist):
            c3.get_next_by_pub_date()
        with self.assertRaises(ArticleWithAuthor.DoesNotExist):
            c3.get_next_by_pub_date()
          self.assertEqual(c3.get_previous_by_pub_date(), c2)
          self.assertEqual(c2.get_previous_by_pub_date(), c1)
          self.assertRaises(
              ArticleWithAuthor.DoesNotExist,
              c1.get_previous_by_pub_date)
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_regress/tests.py