Made test_change_list_sorting_model_admin_reverse's assertions more specific.
The test could fail on databases like CockroachDB that use non-serial primary keys if the numbers (2000, etc.) appeared in the pk values.
This commit is contained in:
parent
7f85498eef
commit
78eeb24774
|
@ -448,24 +448,26 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||||
method in reverse order (i.e. admin_order_field uses the '-' prefix)
|
method in reverse order (i.e. admin_order_field uses the '-' prefix)
|
||||||
(column 6 is 'model_year_reverse' in ArticleAdmin)
|
(column 6 is 'model_year_reverse' in ArticleAdmin)
|
||||||
"""
|
"""
|
||||||
|
td = '<td class="field-model_property_year">%s</td>'
|
||||||
|
td_2000, td_2008, td_2009 = td % 2000, td % 2008, td % 2009
|
||||||
response = self.client.get(reverse('admin:admin_views_article_changelist'), {'o': '6'})
|
response = self.client.get(reverse('admin:admin_views_article_changelist'), {'o': '6'})
|
||||||
self.assertContentBefore(
|
self.assertContentBefore(
|
||||||
response, '2009', '2008',
|
response, td_2009, td_2008,
|
||||||
"Results of sorting on ModelAdmin method are out of order."
|
"Results of sorting on ModelAdmin method are out of order."
|
||||||
)
|
)
|
||||||
self.assertContentBefore(
|
self.assertContentBefore(
|
||||||
response, '2008', '2000',
|
response, td_2008, td_2000,
|
||||||
"Results of sorting on ModelAdmin method are out of order."
|
"Results of sorting on ModelAdmin method are out of order."
|
||||||
)
|
)
|
||||||
# Let's make sure the ordering is right and that we don't get a
|
# Let's make sure the ordering is right and that we don't get a
|
||||||
# FieldError when we change to descending order
|
# FieldError when we change to descending order
|
||||||
response = self.client.get(reverse('admin:admin_views_article_changelist'), {'o': '-6'})
|
response = self.client.get(reverse('admin:admin_views_article_changelist'), {'o': '-6'})
|
||||||
self.assertContentBefore(
|
self.assertContentBefore(
|
||||||
response, '2000', '2008',
|
response, td_2000, td_2008,
|
||||||
"Results of sorting on ModelAdmin method are out of order."
|
"Results of sorting on ModelAdmin method are out of order."
|
||||||
)
|
)
|
||||||
self.assertContentBefore(
|
self.assertContentBefore(
|
||||||
response, '2008', '2009',
|
response, td_2008, td_2009,
|
||||||
"Results of sorting on ModelAdmin method are out of order."
|
"Results of sorting on ModelAdmin method are out of order."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue