1
0
mirror of https://github.com/django/django.git synced 2024-12-25 10:35:48 +00:00

[1.8.x] Refs #24060 -- Added a test demonstrating reverse order isn't mutable

Backport of f218a2ff45 from master
This commit is contained in:
Josh Smeaton 2015-01-27 13:37:43 +11:00
parent 7cc1b4710e
commit 405351ba2f

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