mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
Fix all violators of E231
This commit is contained in:
parent
f2d8027c9a
commit
9d740eb8b1
74 changed files with 628 additions and 629 deletions
|
@ -101,7 +101,7 @@ class M2mThroughTests(TestCase):
|
|||
m2.save()
|
||||
# Verifying that those instances were re-saved successfully.
|
||||
self.assertQuerysetEqual(
|
||||
self.rock.members.all(),[
|
||||
self.rock.members.all(), [
|
||||
'Jane',
|
||||
'Jim'
|
||||
],
|
||||
|
@ -142,7 +142,7 @@ class M2mThroughTests(TestCase):
|
|||
m2.save()
|
||||
# Verifying that those instances were re-saved successfully.
|
||||
self.assertQuerysetEqual(
|
||||
self.jim.group_set.all(),[
|
||||
self.jim.group_set.all(), [
|
||||
'Rock',
|
||||
'Roll'
|
||||
],
|
||||
|
@ -166,7 +166,7 @@ class M2mThroughTests(TestCase):
|
|||
|
||||
# If we get the number of people in Rock, it should be both Bob and Jim.
|
||||
self.assertQuerysetEqual(
|
||||
self.rock.custom_members.all(),[
|
||||
self.rock.custom_members.all(), [
|
||||
'Bob',
|
||||
'Jim'
|
||||
],
|
||||
|
@ -174,14 +174,14 @@ class M2mThroughTests(TestCase):
|
|||
)
|
||||
# Bob should only be in one custom group.
|
||||
self.assertQuerysetEqual(
|
||||
self.bob.custom.all(),[
|
||||
self.bob.custom.all(), [
|
||||
'Rock'
|
||||
],
|
||||
attrgetter("name")
|
||||
)
|
||||
# Let's make sure our new descriptors don't conflict with the FK related_name.
|
||||
self.assertQuerysetEqual(
|
||||
self.bob.custom_person_related_name.all(),[
|
||||
self.bob.custom_person_related_name.all(), [
|
||||
'<CustomMembership: Bob is a member of Rock>'
|
||||
]
|
||||
)
|
||||
|
@ -199,7 +199,7 @@ class M2mThroughTests(TestCase):
|
|||
|
||||
# Tony should now show that Chris is his friend.
|
||||
self.assertQuerysetEqual(
|
||||
tony.friends.all(),[
|
||||
tony.friends.all(), [
|
||||
'Chris'
|
||||
],
|
||||
attrgetter("name")
|
||||
|
@ -214,7 +214,7 @@ class M2mThroughTests(TestCase):
|
|||
# Having added Chris as a friend, let's make sure that his friend set reflects
|
||||
# that addition.
|
||||
self.assertQuerysetEqual(
|
||||
chris.friends.all(),[
|
||||
chris.friends.all(), [
|
||||
'Tony'
|
||||
],
|
||||
attrgetter("name")
|
||||
|
@ -229,7 +229,7 @@ class M2mThroughTests(TestCase):
|
|||
)
|
||||
# Since this isn't a symmetrical relation, Tony's friend link still exists.
|
||||
self.assertQuerysetEqual(
|
||||
tony.friends.all(),[
|
||||
tony.friends.all(), [
|
||||
'Chris'
|
||||
],
|
||||
attrgetter("name")
|
||||
|
@ -253,7 +253,7 @@ class M2mThroughTests(TestCase):
|
|||
# We can query for the related model by using its attribute name (members, in
|
||||
# this case).
|
||||
self.assertQuerysetEqual(
|
||||
Group.objects.filter(members__name='Bob'),[
|
||||
Group.objects.filter(members__name='Bob'), [
|
||||
'Roll'
|
||||
],
|
||||
attrgetter("name")
|
||||
|
@ -262,7 +262,7 @@ class M2mThroughTests(TestCase):
|
|||
# To query through the intermediary model, we specify its model name.
|
||||
# In this case, membership.
|
||||
self.assertQuerysetEqual(
|
||||
Group.objects.filter(membership__invite_reason="She was just awesome."),[
|
||||
Group.objects.filter(membership__invite_reason="She was just awesome."), [
|
||||
'Rock'
|
||||
],
|
||||
attrgetter("name")
|
||||
|
@ -271,7 +271,7 @@ class M2mThroughTests(TestCase):
|
|||
# If we want to query in the reverse direction by the related model, use its
|
||||
# model name (group, in this case).
|
||||
self.assertQuerysetEqual(
|
||||
Person.objects.filter(group__name="Rock"),[
|
||||
Person.objects.filter(group__name="Rock"), [
|
||||
'Jane',
|
||||
'Jim'
|
||||
],
|
||||
|
@ -282,7 +282,7 @@ class M2mThroughTests(TestCase):
|
|||
CustomMembership.objects.create(person=self.jim, group=self.rock)
|
||||
# If the m2m field has specified a related_name, using that will work.
|
||||
self.assertQuerysetEqual(
|
||||
Person.objects.filter(custom__name="Rock"),[
|
||||
Person.objects.filter(custom__name="Rock"), [
|
||||
'Bob',
|
||||
'Jim'
|
||||
],
|
||||
|
@ -292,7 +292,7 @@ class M2mThroughTests(TestCase):
|
|||
# To query through the intermediary model in the reverse direction, we again
|
||||
# specify its model name (membership, in this case).
|
||||
self.assertQuerysetEqual(
|
||||
Person.objects.filter(membership__invite_reason="She was just awesome."),[
|
||||
Person.objects.filter(membership__invite_reason="She was just awesome."), [
|
||||
'Jane'
|
||||
],
|
||||
attrgetter("name")
|
||||
|
@ -300,7 +300,7 @@ class M2mThroughTests(TestCase):
|
|||
|
||||
# Let's see all of the groups that Jane joined after 1 Jan 2005:
|
||||
self.assertQuerysetEqual(
|
||||
Group.objects.filter(membership__date_joined__gt=datetime(2005, 1, 1), membership__person=self.jane),[
|
||||
Group.objects.filter(membership__date_joined__gt=datetime(2005, 1, 1), membership__person=self.jane), [
|
||||
'Rock'
|
||||
],
|
||||
attrgetter("name")
|
||||
|
@ -309,7 +309,7 @@ class M2mThroughTests(TestCase):
|
|||
# Queries also work in the reverse direction: Now let's see all of the people
|
||||
# that have joined Rock since 1 Jan 2005:
|
||||
self.assertQuerysetEqual(
|
||||
Person.objects.filter(membership__date_joined__gt=datetime(2005, 1, 1), membership__group=self.rock),[
|
||||
Person.objects.filter(membership__date_joined__gt=datetime(2005, 1, 1), membership__group=self.rock), [
|
||||
'Jane',
|
||||
'Jim'
|
||||
],
|
||||
|
@ -320,7 +320,7 @@ class M2mThroughTests(TestCase):
|
|||
# querysets. To demonstrate this, we query for all people who have joined a
|
||||
# group after 2004:
|
||||
self.assertQuerysetEqual(
|
||||
Person.objects.filter(membership__date_joined__gt=datetime(2004, 1, 1)),[
|
||||
Person.objects.filter(membership__date_joined__gt=datetime(2004, 1, 1)), [
|
||||
'Jane',
|
||||
'Jim',
|
||||
'Jim'
|
||||
|
@ -335,7 +335,7 @@ class M2mThroughTests(TestCase):
|
|||
)
|
||||
# QuerySet's distinct() method can correct this problem.
|
||||
self.assertQuerysetEqual(
|
||||
Person.objects.filter(membership__date_joined__gt=datetime(2004, 1, 1)).distinct(),[
|
||||
Person.objects.filter(membership__date_joined__gt=datetime(2004, 1, 1)).distinct(), [
|
||||
'Jane',
|
||||
'Jim'
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue