From 78eeb24774b9beb765ff6d5b445784be65f520cb Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Sun, 18 Oct 2020 13:48:06 -0400 Subject: [PATCH] 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. --- tests/admin_views/tests.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 6ab401bede..7b884345e1 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -448,24 +448,26 @@ class AdminViewBasicTest(AdminViewBasicTestCase): method in reverse order (i.e. admin_order_field uses the '-' prefix) (column 6 is 'model_year_reverse' in ArticleAdmin) """ + td = '%s' + td_2000, td_2008, td_2009 = td % 2000, td % 2008, td % 2009 response = self.client.get(reverse('admin:admin_views_article_changelist'), {'o': '6'}) self.assertContentBefore( - response, '2009', '2008', + response, td_2009, td_2008, "Results of sorting on ModelAdmin method are out of order." ) self.assertContentBefore( - response, '2008', '2000', + response, td_2008, td_2000, "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 # FieldError when we change to descending order response = self.client.get(reverse('admin:admin_views_article_changelist'), {'o': '-6'}) self.assertContentBefore( - response, '2000', '2008', + response, td_2000, td_2008, "Results of sorting on ModelAdmin method are out of order." ) self.assertContentBefore( - response, '2008', '2009', + response, td_2008, td_2009, "Results of sorting on ModelAdmin method are out of order." )