summaryrefslogtreecommitdiff
path: root/tests/m2m_through
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2020-10-18 18:29:52 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-11-06 09:24:50 +0100
commit3f7b3275627385f8f7531fca01cdda50d4ec6b6e (patch)
treefb082d40e73f6c877911eab92229ac21cdfaa5bc /tests/m2m_through
parent13b6fff11703a694e155b84d41d02822bbc0aaa0 (diff)
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>
Diffstat (limited to 'tests/m2m_through')
-rw-r--r--tests/m2m_through/tests.py22
1 files changed, 5 insertions, 17 deletions
diff --git a/tests/m2m_through/tests.py b/tests/m2m_through/tests.py
index ec3c481dd2..6262596dd0 100644
--- a/tests/m2m_through/tests.py
+++ b/tests/m2m_through/tests.py
@@ -42,20 +42,12 @@ class M2mThroughTests(TestCase):
)
def test_filter_on_intermediate_model(self):
- Membership.objects.create(person=self.jim, group=self.rock)
- Membership.objects.create(person=self.jane, group=self.rock)
+ m1 = Membership.objects.create(person=self.jim, group=self.rock)
+ m2 = Membership.objects.create(person=self.jane, group=self.rock)
queryset = Membership.objects.filter(group=self.rock)
- expected = [
- '<Membership: Jim is a member of Rock>',
- '<Membership: Jane is a member of Rock>',
- ]
-
- self.assertQuerysetEqual(
- queryset,
- expected
- )
+ self.assertSequenceEqual(queryset, [m1, m2])
def test_add_on_m2m_with_intermediate_model(self):
self.rock.members.add(self.bob, through_defaults={'invite_reason': 'He is good.'})
@@ -372,12 +364,8 @@ class M2mThroughTests(TestCase):
)
def test_custom_related_name_doesnt_conflict_with_fky_related_name(self):
- CustomMembership.objects.create(person=self.bob, group=self.rock)
-
- self.assertQuerysetEqual(
- self.bob.custom_person_related_name.all(),
- ['<CustomMembership: Bob is a member of Rock>']
- )
+ c = CustomMembership.objects.create(person=self.bob, group=self.rock)
+ self.assertSequenceEqual(self.bob.custom_person_related_name.all(), [c])
def test_through_fields(self):
"""