1
0
mirror of https://github.com/django/django.git synced 2024-12-24 10:05:46 +00:00

Fix TestCase.assertQuerysetEqual on python 3, this is needed for a large number of tests

This commit is contained in:
Alex Gaynor 2012-08-08 07:37:10 -07:00
parent 4c97101b1f
commit 7515f6576b

View File

@ -796,9 +796,10 @@ class TransactionTestCase(SimpleTestCase):
" the response" % template_name) " the response" % template_name)
def assertQuerysetEqual(self, qs, values, transform=repr, ordered=True): def assertQuerysetEqual(self, qs, values, transform=repr, ordered=True):
items = six.moves.map(transform, qs)
if not ordered: if not ordered:
return self.assertEqual(set(map(transform, qs)), set(values)) return self.assertEqual(set(items), set(values))
return self.assertEqual(map(transform, qs), values) return self.assertEqual(list(items), values)
def assertNumQueries(self, num, func=None, *args, **kwargs): def assertNumQueries(self, num, func=None, *args, **kwargs):
using = kwargs.pop("using", DEFAULT_DB_ALIAS) using = kwargs.pop("using", DEFAULT_DB_ALIAS)