  from .models import Account, Employee, Person, Profile, ProxyEmployee
  
  
  class UpdateOnlyFieldsTests(TestCase):
      def test_update_fields_basic(self):
          s = Person.objects.create(name='Sara', gender='F')
          self.assertEqual(s.gender, 'F')
  
          s.gender = 'M'
          s.name = 'Ian'
 
</s> remove         with self.assertRaises(ValueError):
 </s> add         with self.assertRaisesMessage(ValueError, self.msg % 'first_name'): </s> remove         with self.assertRaises(ValueError):
 </s> add         # "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> remove         with self.assertRaises(TypeError):
 </s> add         msg = "refresh_from_db() got an unexpected keyword argument 'unknown_kwarg'"
        with self.assertRaisesMessage(TypeError, 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 = 'The following fields do not exist in this model or are m2m fields: %s'

  from .models import Account, Employee, Person, Profile, ProxyEmployee
  
  
  class UpdateOnlyFieldsTests(TestCase):
    msg = 'The following fields do not exist in this model or are m2m fields: %s'

      def test_update_fields_basic(self):
          s = Person.objects.create(name='Sara', gender='F')
          self.assertEqual(s.gender, 'F')
  
          s.gender = 'M'
          s.name = 'Ian'
keep keep keep add keep keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/update_only_fields/tests.py