summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJulien Phalip <jphalip@gmail.com>2012-03-17 21:45:36 +0000
committerJulien Phalip <jphalip@gmail.com>2012-03-17 21:45:36 +0000
commit1ff9be1144e80802ea810e6e70ef2b54b6e42047 (patch)
treec78e1854401ce3136774192278ed9cde107aa5f0 /tests
parentb452439a6ef291e54877668719aa32888b3b3e1a (diff)
Fixed #17828 -- Ensured that when a list filter's `queryset()` method fails, it does so loudly instead of getting swallowed by a `IncorrectLookupParameters` exception. This also properly fixes #16705, which hadn't been addressed correctly in [16705].
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17763 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/admin_filters/tests.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/regressiontests/admin_filters/tests.py b/tests/regressiontests/admin_filters/tests.py
index 539bb0cc7a..b42dfd700d 100644
--- a/tests/regressiontests/admin_filters/tests.py
+++ b/tests/regressiontests/admin_filters/tests.py
@@ -56,7 +56,7 @@ class DecadeListFilterWithNoneReturningLookups(DecadeListFilterWithTitleAndParam
class DecadeListFilterWithFailingQueryset(DecadeListFilterWithTitleAndParameter):
def queryset(self, request, queryset):
- raise Exception
+ raise 1/0
class DecadeListFilterWithQuerysetBasedLookups(DecadeListFilterWithTitleAndParameter):
@@ -77,6 +77,7 @@ class DecadeListFilterParameterEndsWith__Isnull(DecadeListFilter):
title = 'publication decade'
parameter_name = 'decade__isnull' # Ends with '__isnull"
+
class CustomUserAdmin(UserAdmin):
list_filter = ('books_authored', 'books_contributed')
@@ -112,6 +113,8 @@ class DecadeFilterBookAdminParameterEndsWith__In(ModelAdmin):
class DecadeFilterBookAdminParameterEndsWith__Isnull(ModelAdmin):
list_filter = (DecadeListFilterParameterEndsWith__Isnull,)
+
+
class ListFiltersTests(TestCase):
def setUp(self):
@@ -542,14 +545,13 @@ class ListFiltersTests(TestCase):
def test_filter_with_failing_queryset(self):
"""
- Ensure that a filter's failing queryset is interpreted as if incorrect
- lookup parameters were passed (therefore causing a 302 redirection to
- the changelist).
- Refs #16716, #16714.
+ Ensure that when a filter's queryset method fails, it fails loudly and
+ the corresponding exception doesn't get swallowed.
+ Refs #17828.
"""
modeladmin = DecadeFilterBookAdminWithFailingQueryset(Book, site)
request = self.request_factory.get('/', {})
- self.assertRaises(IncorrectLookupParameters, self.get_changelist, request, Book, modeladmin)
+ self.assertRaises(ZeroDivisionError, self.get_changelist, request, Book, modeladmin)
def test_simplelistfilter_with_queryset_based_lookups(self):
modeladmin = DecadeFilterBookAdminWithQuerysetBasedLookups(Book, site)