  
          with self.assertRaises(ValueError):
              s.save(update_fields=['first_name'])
  
          with self.assertRaises(ValueError):
              s.save(update_fields="name")
  
      def test_empty_update_fields(self):
          s = Person.objects.create(name='Sara', gender='F')
          pre_save_data = []
 
</s> remove         with self.assertRaises(ValueError):
 </s> add         with self.assertRaisesMessage(ValueError, self.msg % 'first_name'): </s> remove         with self.assertRaises(ValueError):
 </s> add         with self.assertRaisesMessage(ValueError, self.msg % 'accounts'): </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(TypeError):
 </s> add         msg = "refresh_from_db() got an unexpected keyword argument 'unknown_kwarg'"
        with self.assertRaisesMessage(TypeError, msg):
        # "name" is treated as an iterable so the output is something like
        # "n, a, m, e" but the order isn't deterministic.
        with self.assertRaisesMessage(ValueError, self.msg % ''):
  
          with self.assertRaises(ValueError):
              s.save(update_fields=['first_name'])
  
        # "name" is treated as an iterable so the output is something like
        # "n, a, m, e" but the order isn't deterministic.
        with self.assertRaisesMessage(ValueError, self.msg % ''):
              s.save(update_fields="name")
  
      def test_empty_update_fields(self):
          s = Person.objects.create(name='Sara', gender='F')
          pre_save_data = []
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/update_only_fields/tests.py