          # You can still use latest() with a model that doesn't have
          # "get_latest_by" set -- just pass in the field name manually.
          Person.objects.create(name="Ralph", birthday=datetime(1950, 1, 1))
          p2 = Person.objects.create(name="Stephanie", birthday=datetime(1960, 2, 3))
          self.assertRaises(AssertionError, Person.objects.latest)
          self.assertEqual(Person.objects.latest("birthday"), p2)
  
  
  class TestFirstLast(TestCase):
  
 
</s> remove         self.assertRaises(ValueError, Author.objects.annotate, book_contact_set=Avg('friends__age'))
 </s> add         with self.assertRaises(ValueError):
            Author.objects.annotate(book_contact_set=Avg('friends__age')) </s> remove         self.assertRaises(ValueError, Author.objects.annotate, age=Avg('friends__age'))
 </s> add         with self.assertRaises(ValueError):
            Author.objects.annotate(age=Avg('friends__age')) </s> remove         self.assertRaises(
            AttributeError, getattr, post, "attached_%(class)s_set"
        )
 </s> add         with self.assertRaises(AttributeError):
            getattr(post, "attached_%(class)s_set") </s> remove         self.assertRaises(ValueError, Author.objects.annotate, friends=Count('friends'))
 </s> add         with self.assertRaises(ValueError):
            Author.objects.annotate(friends=Count('friends')) </s> remove         self.assertRaises(LayerMapError, LayerMapping,
                          Point3D, city_file, point_mapping, transform=False)
 </s> add         with self.assertRaises(LayerMapError):
            LayerMapping(Point3D, city_file, point_mapping, transform=False)
        with self.assertRaises(AssertionError):
            Person.objects.latest()
          # You can still use latest() with a model that doesn't have
          # "get_latest_by" set -- just pass in the field name manually.
          Person.objects.create(name="Ralph", birthday=datetime(1950, 1, 1))
          p2 = Person.objects.create(name="Stephanie", birthday=datetime(1960, 2, 3))
        with self.assertRaises(AssertionError):
            Person.objects.latest()
          self.assertEqual(Person.objects.latest("birthday"), p2)
  
  
  class TestFirstLast(TestCase):
  
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