      def test_reverse_field_name_disallowed(self):
          """
          If a related_name is given you can't use the field name instead
          """
          self.assertRaises(FieldError, Poll.objects.get,
              choice__name__exact="This is the answer")
 
</s> remove         self.assertRaises(TemplateDoesNotExist, self.client.get, '/render_no_template/')
 </s> add         with self.assertRaises(TemplateDoesNotExist):
            self.client.get('/render_no_template/') </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(
            DatabaseError,
            list,
            Person.objects.all().select_for_update(nowait=True)
        )
 </s> add         with self.assertRaises(DatabaseError):
            list(Person.objects.all().select_for_update(nowait=True)) </s> remove         self.assertRaises(ImproperlyConfigured, view.get_template_names)
 </s> add         with self.assertRaises(ImproperlyConfigured):
            view.get_template_names() </s> remove         self.assertRaises(AttributeError, lambda: e.id)
 </s> add         with self.assertRaises(AttributeError):
            e.id
        with self.assertRaises(FieldError):
            Poll.objects.get(choice__name__exact="This is the answer")
      def test_reverse_field_name_disallowed(self):
          """
          If a related_name is given you can't use the field name instead
          """
        with self.assertRaises(FieldError):
            Poll.objects.get(choice__name__exact="This is the answer")
        with self.assertRaises(FieldError):
            Poll.objects.get(choice__name__exact="This is the answer")
keep keep keep keep replace replace
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/reverse_lookup/tests.py