              self.assertEqual(TrackCallsYearTransform.call_order,
                               ['lookup', 'transform'])
              TrackCallsYearTransform.call_order = []
              # junk transform - tries transform only, then fails
              with self.assertRaises(FieldError):
                  Author.objects.filter(birthdate__testyear__junk__more_junk=2012)
              self.assertEqual(TrackCallsYearTransform.call_order,
                               ['transform'])
              TrackCallsYearTransform.call_order = []
              # Just getting the year (implied __exact) - lookup only
 
</s> remove             with self.assertRaises(FieldError):
 </s> add             msg = "Unsupported lookup 'junk' for IntegerField or join on the field not permitted."
            with self.assertRaisesMessage(FieldError, 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 % ''): </s> remove         with self.assertRaises(FieldError):
 </s> add         msg = "Unsupported lookup 'blahblah' for CharField or join on the field not permitted."
        with self.assertRaisesMessage(FieldError, msg): </s> remove         with self.assertRaises(FieldError):
 </s> add         msg = "Cannot compute Avg('mean_age'): 'mean_age' is an aggregate"
        with self.assertRaisesMessage(FieldError, msg): </s> remove         with self.assertRaises(ValueError):
 </s> add         msg = "The annotation 'age' conflicts with a field on the model."
        with self.assertRaisesMessage(ValueError, msg):
            with self.assertRaisesMessage(FieldError, msg):
              self.assertEqual(TrackCallsYearTransform.call_order,
                               ['lookup', 'transform'])
              TrackCallsYearTransform.call_order = []
              # junk transform - tries transform only, then fails
            with self.assertRaisesMessage(FieldError, msg):
                  Author.objects.filter(birthdate__testyear__junk__more_junk=2012)
              self.assertEqual(TrackCallsYearTransform.call_order,
                               ['transform'])
              TrackCallsYearTransform.call_order = []
              # Just getting the year (implied __exact) - lookup only
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/custom_lookups/tests.py