          # Prepare a request object
          request = HttpRequest()
          request.session = self.client.session
  
          with self.assertRaises(ImproperlyConfigured):
              get_user(request)
  
  
  class ImportedModelBackend(ModelBackend):
      pass
 
</s> remove         with self.assertRaises(ImproperlyConfigured):
 </s> add         msg = "'apps.apps.NotAConfig' isn't a subclass of AppConfig."
        with self.assertRaisesMessage(ImproperlyConfigured, msg): </s> remove         with self.assertRaises(ValueError):
 </s> add         msg = (
            "Cannot create form field for 'ref' yet, because "
            "its related model 'B' has not been loaded yet"
        )
        with self.assertRaisesMessage(ValueError, msg): </s> remove         with self.assertRaises(ImproperlyConfigured):
 </s> add         msg = "'apps.apps.BadConfig' must supply a name attribute."
        with self.assertRaisesMessage(ImproperlyConfigured, msg): </s> remove         with self.assertRaises(AssertionError):
 </s> add         msg = (
            "earliest() and latest() require either a field_name parameter or "
            "'get_latest_by' in the model"
        )
        with self.assertRaisesMessage(AssertionError, msg): </s> remove         with self.assertRaises(ImproperlyConfigured):
 </s> add         msg = (
            'No authentication backends have been defined. '
            'Does AUTHENTICATION_BACKENDS contain anything?'
        )
        with self.assertRaisesMessage(ImproperlyConfigured, msg):
        msg = (
            "AUTH_USER_MODEL refers to model 'thismodel.doesntexist' "
            "that has not been installed"
        )
        with self.assertRaisesMessage(ImproperlyConfigured, msg):
          # Prepare a request object
          request = HttpRequest()
          request.session = self.client.session
  
        msg = (
            "AUTH_USER_MODEL refers to model 'thismodel.doesntexist' "
            "that has not been installed"
        )
        with self.assertRaisesMessage(ImproperlyConfigured, msg):
              get_user(request)
  
  
  class ImportedModelBackend(ModelBackend):
      pass
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/auth_tests/test_auth_backends.py