def it_serializes_errors(self): expected = { 'collection': { 'error': { 'title': 'Error title', 'code': 404, 'message': 'Not found' } } } j = CollectionJsonSerializer.error(status=404, message='Not found', title='Error title') eq_(expected, json.loads(j))