mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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:
committed by
Mariusz Felisiak
parent
13b6fff117
commit
3f7b327562
@@ -78,15 +78,15 @@ class CustomColumnsTests(TestCase):
|
||||
)
|
||||
|
||||
def test_author_querying(self):
|
||||
self.assertQuerysetEqual(
|
||||
self.assertSequenceEqual(
|
||||
Author.objects.all().order_by('last_name'),
|
||||
['<Author: Peter Jones>', '<Author: John Smith>']
|
||||
[self.a2, self.a1],
|
||||
)
|
||||
|
||||
def test_author_filtering(self):
|
||||
self.assertQuerysetEqual(
|
||||
self.assertSequenceEqual(
|
||||
Author.objects.filter(first_name__exact='John'),
|
||||
['<Author: John Smith>']
|
||||
[self.a1],
|
||||
)
|
||||
|
||||
def test_author_get(self):
|
||||
@@ -111,15 +111,12 @@ class CustomColumnsTests(TestCase):
|
||||
getattr(a, 'last')
|
||||
|
||||
def test_m2m_table(self):
|
||||
self.assertQuerysetEqual(
|
||||
self.assertSequenceEqual(
|
||||
self.article.authors.all().order_by('last_name'),
|
||||
['<Author: Peter Jones>', '<Author: John Smith>']
|
||||
[self.a2, self.a1],
|
||||
)
|
||||
self.assertQuerysetEqual(
|
||||
self.a1.article_set.all(),
|
||||
['<Article: Django lets you build Web apps easily>']
|
||||
)
|
||||
self.assertQuerysetEqual(
|
||||
self.assertSequenceEqual(self.a1.article_set.all(), [self.article])
|
||||
self.assertSequenceEqual(
|
||||
self.article.authors.filter(last_name='Jones'),
|
||||
['<Author: Peter Jones>']
|
||||
[self.a2],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user