          )
  
      def test_latest(self):
          # Because no Articles exist yet, latest() raises ArticleDoesNotExist.
          self.assertRaises(Article.DoesNotExist, Article.objects.latest)
  
          a1 = Article.objects.create(
              headline="Article 1", pub_date=datetime(2005, 7, 26),
              expire_date=datetime(2005, 9, 1)
          )
 
</s> remove         self.assertRaises(Article.DoesNotExist, Article.objects.earliest)
 </s> add         with self.assertRaises(Article.DoesNotExist):
            Article.objects.earliest() </s> remove         self.assertRaises(Http404, get_object_or_404, Article, title="Foo")
 </s> add         with self.assertRaises(Http404):
            get_object_or_404(Article, title="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(
            Place.MultipleObjectsReturned,
            Restaurant.objects.get, id__lt=12321
        )
 </s> add         with self.assertRaises(Place.MultipleObjectsReturned):
            Restaurant.objects.get(id__lt=12321) </s> remove         self.assertRaises(
            ValueError,
            Book.objects.all().annotate,
            Avg('authors__age'), authors__age__avg=Avg('authors__age')
        )
 </s> add         with self.assertRaises(ValueError):
            Book.objects.all().annotate(Avg('authors__age'), authors__age__avg=Avg('authors__age'))
        with self.assertRaises(Article.DoesNotExist):
            Article.objects.latest()
          )
  
      def test_latest(self):
          # Because no Articles exist yet, latest() raises ArticleDoesNotExist.
        with self.assertRaises(Article.DoesNotExist):
            Article.objects.latest()
  
          a1 = Article.objects.create(
              headline="Article 1", pub_date=datetime(2005, 7, 26),
              expire_date=datetime(2005, 9, 1)
          )
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/get_earliest_or_latest/tests.py