          class Meta:
              model = A
              fields = '__all__'
  
          with self.assertRaises(ValueError):
              ModelFormMetaclass('Form', (ModelForm,), {'Meta': Meta})
  
          class B(models.Model):
              pass
  
 
</s> remove         with self.assertRaises(ImproperlyConfigured):
 </s> add         msg = (
            "AUTH_USER_MODEL refers to model 'thismodel.doesntexist' "
            "that has not been installed"
        )
        with self.assertRaisesMessage(ImproperlyConfigured, msg): </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(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(ValidationError):
 </s> add         msg = 'ManagementForm data is missing or has been tampered with'
        with self.assertRaisesMessage(ValidationError, msg):
        msg = (
            "Cannot create form field for 'ref' yet, because "
            "its related model 'B' has not been loaded yet"
        )
        with self.assertRaisesMessage(ValueError, msg):
          class Meta:
              model = A
              fields = '__all__'
  
        msg = (
            "Cannot create form field for 'ref' yet, because "
            "its related model 'B' has not been loaded yet"
        )
        with self.assertRaisesMessage(ValueError, msg):
              ModelFormMetaclass('Form', (ModelForm,), {'Meta': Meta})
  
          class B(models.Model):
              pass
  
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/forms_tests/tests/tests.py