              self.assertEqual(a.pub_date, new_pub_date)
  
      def test_unknown_kwarg(self):
          s = SelfRef.objects.create()
          with self.assertRaises(TypeError):
              s.refresh_from_db(unknown_kwarg=10)
  
      def test_refresh_fk(self):
          s1 = SelfRef.objects.create()
          s2 = SelfRef.objects.create()
 
</s> remove         with self.assertRaises(ValueError):
 </s> add         with self.assertRaisesMessage(ValueError, self.msg % 'first_name'): </s> remove         with self.assertRaises(TypeError):
 </s> add         msg = 'Cannot call delete() after .values() or .values_list()'
        with self.assertRaisesMessage(TypeError, msg): </s> remove         # Can't be instantiated
        with self.assertRaises(TypeError):
 </s> add         msg = "EmptyQuerySet can't be instantiated"
        with self.assertRaisesMessage(TypeError, msg): </s> remove         with self.assertRaises(TypeError):
 </s> add         msg = 'response and/or template_name argument must be provided'
        with self.assertRaisesMessage(TypeError, msg): </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 = "refresh_from_db() got an unexpected keyword argument 'unknown_kwarg'"
        with self.assertRaisesMessage(TypeError, msg):
              self.assertEqual(a.pub_date, new_pub_date)
  
      def test_unknown_kwarg(self):
          s = SelfRef.objects.create()
        msg = "refresh_from_db() got an unexpected keyword argument 'unknown_kwarg'"
        with self.assertRaisesMessage(TypeError, msg):
              s.refresh_from_db(unknown_kwarg=10)
  
      def test_refresh_fk(self):
          s1 = SelfRef.objects.create()
          s2 = SelfRef.objects.create()
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/basic/tests.py