diff options
author | Tim Graham <timograham@gmail.com> | 2020-11-03 21:20:57 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2020-11-03 22:26:18 -0500 |
commit | be27da9d6e3e3ec5e6c4a35ea275a9ec79551702 (patch) | |
tree | 0dbdd08de866fd2802ad039da62cd1d122843c6b /tests/ordering | |
parent | 009fddc96b88a9aee1232d6a2637f2970fdcfb50 (diff) | |
download | django-be27da9d6e3e3ec5e6c4a35ea275a9ec79551702.tar.gz |
Removed serial pk assumption in ordering tests.
Fixed OrderingTests.test_order_by_fk_attname and test_order_by_pk on
CockroachDB.
Diffstat (limited to 'tests/ordering')
-rw-r--r-- | tests/ordering/tests.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/ordering/tests.py b/tests/ordering/tests.py index fe319b3859..c8e9c98e43 100644 --- a/tests/ordering/tests.py +++ b/tests/ordering/tests.py @@ -315,10 +315,9 @@ class OrderingTests(TestCase): """ 'pk' works as an ordering option in Meta. """ - self.assertQuerysetEqual( - Author.objects.all(), - list(reversed(range(1, Author.objects.count() + 1))), - attrgetter("pk"), + self.assertEqual( + [a.pk for a in Author.objects.all()], + [a.pk for a in Author.objects.order_by('-pk')], ) def test_order_by_fk_attname(self): @@ -326,8 +325,9 @@ class OrderingTests(TestCase): ordering by a foreign key by its attribute name prevents the query from inheriting its related model ordering option (#19195). """ + authors = list(Author.objects.order_by('id')) for i in range(1, 5): - author = Author.objects.get(pk=i) + author = authors[i - 1] article = getattr(self, "a%d" % (5 - i)) article.author = author article.save(update_fields={'author'}) |