Fixed #31235 -- Made assertQuerysetEqual() compare querysets directly.

This also replaces assertQuerysetEqual() to
assertSequenceEqual()/assertCountEqual() where appropriate.

Co-authored-by: Peter Inglesby <peter.inglesby@gmail.com>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
Hasan Ramezani 2020-10-18 18:29:52 +02:00 committed by Mariusz Felisiak
parent 13b6fff117
commit 3f7b327562
39 changed files with 1447 additions and 1801 deletions

View file

@ -76,7 +76,7 @@ class PrefetchRelatedTests(TestDataMixin, TestCase):
[list(b.first_time_authors.all())
for b in Book.objects.prefetch_related('first_time_authors')]
self.assertQuerysetEqual(self.book2.authors.all(), ["<Author: Charlotte>"])
self.assertSequenceEqual(self.book2.authors.all(), [self.author1])
def test_onetoone_reverse_no_match(self):
# Regression for #17439
@ -1580,4 +1580,4 @@ class ReadPrefetchedObjectsCacheTests(TestCase):
)
with self.assertNumQueries(4):
# AuthorWithAge -> Author -> FavoriteAuthors, Book
self.assertQuerysetEqual(authors, ['<AuthorWithAge: Rousseau>', '<AuthorWithAge: Voltaire>'])
self.assertSequenceEqual(authors, [self.author1, self.author2])