          test_gmbh = Company.objects.get(name="Test GmbH")
  
          def test():
              test_gmbh.point_of_contact = F("ceo")
          with self.assertRaises(ValueError):
              test()
  
          test_gmbh.point_of_contact = test_gmbh.ceo
          test_gmbh.save()
          test_gmbh.name = F("ceo__last_name")
 
</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(ValueError):
 </s> add         with self.assertRaisesMessage(ValueError, self.msg % 'accounts'): </s> remove         with self.assertRaises(ValueError):
 </s> add         msg = 'backend does not support timezone-aware datetimes when USE_TZ is False.'
        with self.assertRaisesMessage(ValueError, msg): </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 % ''):
        msg = 'F(ceo)": "Company.point_of_contact" must be a "Employee" instance.'
        with self.assertRaisesMessage(ValueError, msg):
          test_gmbh = Company.objects.get(name="Test GmbH")
  
          def test():
              test_gmbh.point_of_contact = F("ceo")
        msg = 'F(ceo)": "Company.point_of_contact" must be a "Employee" instance.'
        with self.assertRaisesMessage(ValueError, msg):
              test()
  
          test_gmbh.point_of_contact = test_gmbh.ceo
          test_gmbh.save()
          test_gmbh.name = F("ceo__last_name")
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/expressions/tests.py