  
          test_gmbh.point_of_contact = test_gmbh.ceo
          test_gmbh.save()
          test_gmbh.name = F("ceo__last_name")
          with self.assertRaises(FieldError):
              test_gmbh.save()
  
      def test_object_update_unsaved_objects(self):
          # F expressions cannot be used to update attributes on objects which do
          # not yet exist in the database
 
</s> remove         with self.assertRaises(ValueError):
 </s> add         msg = 'F(ceo)": "Company.point_of_contact" must be a "Employee" instance.'
        with self.assertRaisesMessage(ValueError, msg): </s> remove         with self.assertRaises(AssertionError):
 </s> add         msg = 'Cannot update a query once a slice has been taken.'
        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(transaction.TransactionManagementError):
 </s> add             msg = 'on_commit() cannot be used in manual transaction management'
            with self.assertRaisesMessage(transaction.TransactionManagementError, msg):
        msg = 'Joined field references are not permitted in this query'
        with self.assertRaisesMessage(FieldError, msg):
  
          test_gmbh.point_of_contact = test_gmbh.ceo
          test_gmbh.save()
          test_gmbh.name = F("ceo__last_name")
        msg = 'Joined field references are not permitted in this query'
        with self.assertRaisesMessage(FieldError, msg):
              test_gmbh.save()
  
      def test_object_update_unsaved_objects(self):
          # F expressions cannot be used to update attributes on objects which do
          # not yet exist in the database
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/expressions/tests.py