  
          # Won't work because force_update and force_insert are mutually
          # exclusive
          c.value = 4
          with self.assertRaises(ValueError):
              c.save(force_insert=True, force_update=True)
  
          # Try to update something that doesn't have a primary key in the first
          # place.
          c1 = Counter(name="two", value=2)
 
</s> remove         with self.assertRaises(ValueError):
 </s> add         msg = 'Cannot force an update in save() with no primary key.'
        with self.assertRaisesMessage(ValueError, 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(DatabaseError):
 </s> add         msg = 'Forced update did not affect any rows.'
        with self.assertRaisesMessage(DatabaseError, msg): </s> remove         with self.assertRaises(FieldError):
 </s> add         msg = 'Joined field references are not permitted in this query'
        with self.assertRaisesMessage(FieldError, msg): </s> remove         with self.assertRaises(IntegrityError):
 </s> add         msg = (
            "Cannot delete some instances of model 'R' because they are "
            "referenced through a protected foreign key: 'A.protect'"
        )
        with self.assertRaisesMessage(IntegrityError, msg):
        msg = 'Cannot force both insert and updating in model saving.'
        with self.assertRaisesMessage(ValueError, msg):
  
          # Won't work because force_update and force_insert are mutually
          # exclusive
          c.value = 4
        msg = 'Cannot force both insert and updating in model saving.'
        with self.assertRaisesMessage(ValueError, msg):
              c.save(force_insert=True, force_update=True)
  
          # Try to update something that doesn't have a primary key in the first
          # place.
          c1 = Counter(name="two", value=2)
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/force_insert_update/tests.py