From 170988ee0f93c74d7c21661663940c5fc7e6928b Mon Sep 17 00:00:00 2001
From: Jonas Obrist <ojiidotch@gmail.com>
Date: Tue, 3 Jan 2012 14:27:01 +0100
Subject: [PATCH] added a test illustrating potentially confusing exception
messages when using values_list and spanning relations
---
tests/modeltests/many_to_one/tests.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/tests/modeltests/many_to_one/tests.py b/tests/modeltests/many_to_one/tests.py
index 922506e..3e3c341 100644
a
|
b
|
|
3 | 3 | from copy import deepcopy |
4 | 4 | from datetime import datetime |
5 | 5 | |
6 | | from django.core.exceptions import MultipleObjectsReturned |
| 6 | from django.core.exceptions import MultipleObjectsReturned, FieldError |
7 | 7 | from django.test import TestCase |
8 | 8 | |
9 | 9 | from .models import Article, Reporter |
… |
… |
def test_manager_class_caching(self):
|
411 | 411 | |
412 | 412 | # Same as each other |
413 | 413 | self.assertTrue(r1.article_set.__class__ is r2.article_set.__class__) |
| 414 | |
| 415 | def test_values_list_exception(self): |
| 416 | expected_message = "Cannot resolve keyword 'notafield' into field. Choices are: %s" % ', '.join(Reporter._meta.get_all_field_names()) |
| 417 | self.assertRaisesMessage(FieldError, expected_message, Article.objects.values_list, 'reporter__notafield') |