From f218a2ff455b5f7391dd38038994f2c5f8b0eca1 Mon Sep 17 00:00:00 2001 From: Josh Smeaton Date: Tue, 27 Jan 2015 13:37:43 +1100 Subject: [PATCH] Refs #24060 -- Added a test demonstrating reverse order isn't mutable --- tests/ordering/tests.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/ordering/tests.py b/tests/ordering/tests.py index 60880b71be..19d289a2d1 100644 --- a/tests/ordering/tests.py +++ b/tests/ordering/tests.py @@ -137,6 +137,28 @@ class OrderingTests(TestCase): attrgetter("headline") ) + def test_reverse_ordering_pure(self): + qs1 = Article.objects.order_by(F('headline').asc()) + qs2 = qs1.reverse() + self.assertQuerysetEqual( + qs1, [ + "Article 1", + "Article 2", + "Article 3", + "Article 4", + ], + attrgetter("headline") + ) + self.assertQuerysetEqual( + qs2, [ + "Article 4", + "Article 3", + "Article 2", + "Article 1", + ], + attrgetter("headline") + ) + def test_extra_ordering(self): """ Ordering can be based on fields included from an 'extra' clause