      def test_nonfield_lookups(self):
          """
          A lookup query containing non-fields raises the proper exception.
          """
          with self.assertRaises(FieldError):
              Article.objects.filter(headline__blahblah=99)
          with self.assertRaises(FieldError):
              Article.objects.filter(headline__blahblah__exact=99)
          with self.assertRaises(FieldError):
              Article.objects.filter(blahblah=99)
 
</s> remove         with self.assertRaises(FieldError):
 </s> add         with self.assertRaisesMessage(FieldError, msg): </s> remove         with self.assertRaises(TemplateSyntaxError):
 </s> add         with self.assertRaisesMessage(TemplateSyntaxError, "Invalid filter: 'fil'"): </s> remove             with self.assertRaises(FieldError):
 </s> add             msg = "Unsupported lookup 'junk' for IntegerField or join on the field not permitted."
            with self.assertRaisesMessage(FieldError, msg): </s> remove             with self.assertRaises(FieldError):
 </s> add             with self.assertRaisesMessage(FieldError, msg): </s> remove         with self.assertRaises(ImproperlyConfigured):
 </s> add         msg = (
            "TemplateResponseMixin requires either a definition of "
            "'template_name' or an implementation of 'get_template_names()'"
        )
        with self.assertRaisesMessage(ImproperlyConfigured, msg):
        msg = "Unsupported lookup 'blahblah' for CharField or join on the field not permitted."
        with self.assertRaisesMessage(FieldError, msg):
      def test_nonfield_lookups(self):
          """
          A lookup query containing non-fields raises the proper exception.
          """
        msg = "Unsupported lookup 'blahblah' for CharField or join on the field not permitted."
        with self.assertRaisesMessage(FieldError, msg):
              Article.objects.filter(headline__blahblah=99)
          with self.assertRaises(FieldError):
              Article.objects.filter(headline__blahblah__exact=99)
          with self.assertRaises(FieldError):
              Article.objects.filter(blahblah=99)
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/lookup/tests.py