Fixed #10494 -- Added kwargs to QuerySet.get() error message in the case no objects were found.

Thanks brondsem for the report, Szymon Pyzalski for the patch and oinopion for review.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@17917 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Anssi Kääriäinen 2012-04-20 11:09:32 +00:00
parent a901654a96
commit d5b93d3281
4 changed files with 24 additions and 10 deletions

View file

@ -83,14 +83,23 @@ class ModelTest(TestCase):
# parameters don't match any object.
self.assertRaisesRegexp(
ObjectDoesNotExist,
"Article matching query does not exist.",
"Article matching query does not exist. Lookup parameters were "
"{'id__exact': 2000}",
Article.objects.get,
id__exact=2000,
)
# To avoid dict-ordering related errors check only one lookup
# in single assert.
self.assertRaisesRegexp(
ObjectDoesNotExist,
"Article matching query does not exist.",
".*'pub_date__year': 2005.*",
Article.objects.get,
pub_date__year=2005,
pub_date__month=8,
)
self.assertRaisesRegexp(
ObjectDoesNotExist,
".*'pub_date__month': 8.*",
Article.objects.get,
pub_date__year=2005,
pub_date__month=8,
@ -98,7 +107,8 @@ class ModelTest(TestCase):
self.assertRaisesRegexp(
ObjectDoesNotExist,
"Article matching query does not exist.",
"Article matching query does not exist. Lookup parameters were "
"{'pub_date__week_day': 6}",
Article.objects.get,
pub_date__week_day=6,
)