              # behaved for databases that do not return correct information
              # about matched rows for UPDATE.
              with self.assertRaises(DatabaseError):
                  asos.save(force_update=True)
              with self.assertRaises(DatabaseError):
                  asos.save(update_fields=['pub_date'])
          finally:
              Article._base_manager._queryset_class = orig_class
  
  
 
</s> remove             with self.assertRaises(DatabaseError):
 </s> add             with self.assertRaisesMessage(DatabaseError, 'Forced update did not affect any rows.'): </s> remove         with self.assertRaises(DatabaseError):
 </s> add         with self.assertRaisesMessage(DatabaseError, 'Forced update did not affect any rows.'): </s> remove         with self.assertRaises(DatabaseError):
 </s> add         msg = 'Forced update did not affect any rows.'
        with self.assertRaisesMessage(DatabaseError, msg): </s> remove         with self.assertRaises(ValueError):
 </s> add         msg = "The annotation 'book_contact_set' conflicts with a field on the model."
        with self.assertRaisesMessage(ValueError, msg): </s> remove         with self.assertRaises(ValueError):
 </s> add         msg = "The annotation 'age' conflicts with a field on the model."
        with self.assertRaisesMessage(ValueError, msg):
            msg = (
                "An error occurred in the current transaction. You can't "
                "execute queries until the end of the 'atomic' block."
            )
            with self.assertRaisesMessage(DatabaseError, msg):
              # behaved for databases that do not return correct information
              # about matched rows for UPDATE.
              with self.assertRaises(DatabaseError):
                  asos.save(force_update=True)
            msg = (
                "An error occurred in the current transaction. You can't "
                "execute queries until the end of the 'atomic' block."
            )
            with self.assertRaisesMessage(DatabaseError, msg):
                  asos.save(update_fields=['pub_date'])
          finally:
              Article._base_manager._queryset_class = orig_class
  
  
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/basic/tests.py