Refs #24060 -- Added a test demonstrating reverse order isn't mutable

This commit is contained in:
Josh Smeaton 2015-01-27 13:37:43 +11:00
parent ac650d02cb
commit f218a2ff45
1 changed files with 22 additions and 0 deletions

View File

@ -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