mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
Fixed #19462 -- Made assertQuerysetEqual detect undefined ordering
If there are more than one values to compare against and the qs isn't ordered then assertQuerysetEqual will raise a ValueError.
This commit is contained in:
@@ -767,6 +767,12 @@ class TransactionTestCase(SimpleTestCase):
|
||||
items = six.moves.map(transform, qs)
|
||||
if not ordered:
|
||||
return self.assertEqual(set(items), set(values))
|
||||
values = list(values)
|
||||
# For example qs.iterator() could be passed as qs, but it does not
|
||||
# have 'ordered' attribute.
|
||||
if len(values) > 1 and hasattr(qs, 'ordered') and not qs.ordered:
|
||||
raise ValueError("Trying to compare non-ordered queryset "
|
||||
"against more than one ordered values")
|
||||
return self.assertEqual(list(items), values)
|
||||
|
||||
def assertNumQueries(self, num, func=None, *args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user