summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-04-03 20:37:32 -0400
committerTim Graham <timograham@gmail.com>2016-04-04 17:14:26 -0400
commit2cd2d188516475ddf256e6267cd82c495fb5c430 (patch)
tree1a7c3c167c1576923c7c4f5544495face5bd7327 /tests
parentd356bb653f4d90ae9809e5a051791ded39010c38 (diff)
Fixed W503 flake8 warnings.
Diffstat (limited to 'tests')
-rw-r--r--tests/aggregation_regress/tests.py4
-rw-r--r--tests/forms_tests/tests/test_forms.py20
-rw-r--r--tests/gis_tests/geos_tests/test_geos_mutation.py7
-rw-r--r--tests/or_lookups/tests.py4
-rw-r--r--tests/queries/tests.py32
-rw-r--r--tests/serializers/tests.py6
6 files changed, 35 insertions, 38 deletions
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py
index f92459a990..6d6ca3480f 100644
--- a/tests/aggregation_regress/tests.py
+++ b/tests/aggregation_regress/tests.py
@@ -983,8 +983,8 @@ class AggregationTests(TestCase):
Book.objects
.annotate(n_authors=Count("authors"))
.filter(
- Q(name="The Definitive Guide to Django: Web Development Done Right")
- | (Q(name="Artificial Intelligence: A Modern Approach") & Q(n_authors=3))
+ Q(name="The Definitive Guide to Django: Web Development Done Right") |
+ (Q(name="Artificial Intelligence: A Modern Approach") & Q(n_authors=3))
)
)
self.assertQuerysetEqual(
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
index 22675bb84b..99bcfe3417 100644
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -941,8 +941,8 @@ value="Should escape &lt; &amp; &gt; and &lt;script&gt;alert(&#39;xss&#39;)&lt;/
password2 = CharField(widget=PasswordInput)
def clean_password2(self):
- if (self.cleaned_data.get('password1') and self.cleaned_data.get('password2')
- and self.cleaned_data['password1'] != self.cleaned_data['password2']):
+ if (self.cleaned_data.get('password1') and self.cleaned_data.get('password2') and
+ self.cleaned_data['password1'] != self.cleaned_data['password2']):
raise ValidationError('Please make sure your passwords match.')
return self.cleaned_data['password2']
@@ -980,8 +980,8 @@ value="Should escape &lt; &amp; &gt; and &lt;script&gt;alert(&#39;xss&#39;)&lt;/
def clean(self):
# Test raising a ValidationError as NON_FIELD_ERRORS.
- if (self.cleaned_data.get('password1') and self.cleaned_data.get('password2')
- and self.cleaned_data['password1'] != self.cleaned_data['password2']):
+ if (self.cleaned_data.get('password1') and self.cleaned_data.get('password2') and
+ self.cleaned_data['password1'] != self.cleaned_data['password2']):
raise ValidationError('Please make sure your passwords match.')
# Test raising ValidationError that targets multiple fields.
@@ -1120,8 +1120,8 @@ value="Should escape &lt; &amp; &gt; and &lt;script&gt;alert(&#39;xss&#39;)&lt;/
password2 = CharField(widget=PasswordInput)
def clean(self):
- if (self.cleaned_data.get('password1') and self.cleaned_data.get('password2')
- and self.cleaned_data['password1'] != self.cleaned_data['password2']):
+ if (self.cleaned_data.get('password1') and self.cleaned_data.get('password2') and
+ self.cleaned_data['password1'] != self.cleaned_data['password2']):
raise ValidationError(
'Please make sure your passwords match.',
code='password_mismatch',
@@ -2309,8 +2309,8 @@ Password: <input type="password" name="password" /></li>
password2 = CharField(widget=PasswordInput)
def clean(self):
- if (self.cleaned_data.get('password1') and self.cleaned_data.get('password2')
- and self.cleaned_data['password1'] != self.cleaned_data['password2']):
+ if (self.cleaned_data.get('password1') and self.cleaned_data.get('password2') and
+ self.cleaned_data['password1'] != self.cleaned_data['password2']):
raise ValidationError('Please make sure your passwords match.')
return self.cleaned_data
@@ -2369,8 +2369,8 @@ Password: <input type="password" name="password" /></li>
password2 = CharField(widget=PasswordInput)
def clean(self):
- if (self.cleaned_data.get('password1') and self.cleaned_data.get('password2')
- and self.cleaned_data['password1'] != self.cleaned_data['password2']):
+ if (self.cleaned_data.get('password1') and self.cleaned_data.get('password2') and
+ self.cleaned_data['password1'] != self.cleaned_data['password2']):
raise ValidationError('Please make sure your passwords match.')
return self.cleaned_data
diff --git a/tests/gis_tests/geos_tests/test_geos_mutation.py b/tests/gis_tests/geos_tests/test_geos_mutation.py
index 56f2a7d7a7..d235aeb2fc 100644
--- a/tests/gis_tests/geos_tests/test_geos_mutation.py
+++ b/tests/gis_tests/geos_tests/test_geos_mutation.py
@@ -65,9 +65,10 @@ def api_get_area(x):
def api_get_length(x):
return x.length
-geos_function_tests = [val for name, val in vars().items()
- if hasattr(val, '__call__')
- and name.startswith('api_get_')]
+geos_function_tests = [
+ val for name, val in vars().items()
+ if hasattr(val, '__call__') and name.startswith('api_get_')
+]
@skipUnless(HAS_GEOS, "Geos is required.")
diff --git a/tests/or_lookups/tests.py b/tests/or_lookups/tests.py
index 35c7f34d61..87f4efc069 100644
--- a/tests/or_lookups/tests.py
+++ b/tests/or_lookups/tests.py
@@ -27,8 +27,8 @@ class OrLookupsTests(TestCase):
def test_filter_or(self):
self.assertQuerysetEqual(
(
- Article.objects.filter(headline__startswith='Hello')
- | Article.objects.filter(headline__startswith='Goodbye')
+ Article.objects.filter(headline__startswith='Hello') |
+ Article.objects.filter(headline__startswith='Goodbye')
), [
'Hello',
'Goodbye',
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 3a36316407..87baef2da6 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -1170,8 +1170,7 @@ class Queries1Tests(BaseQuerysetTest):
def test_ticket19672(self):
self.assertQuerysetEqual(
- Report.objects.filter(Q(creator__isnull=False) &
- ~Q(creator__extra__value=41)),
+ Report.objects.filter(Q(creator__isnull=False) & ~Q(creator__extra__value=41)),
['<Report: r1>']
)
@@ -1390,8 +1389,8 @@ class Queries4Tests(BaseQuerysetTest):
q1 = Item.objects.filter(Q(creator__report__name='e1') | Q(creator=self.a1)).order_by()
q2 = (
- Item.objects.filter(Q(creator__report__name='e1')).order_by()
- | Item.objects.filter(Q(creator=self.a1)).order_by()
+ Item.objects.filter(Q(creator__report__name='e1')).order_by() |
+ Item.objects.filter(Q(creator=self.a1)).order_by()
)
self.assertQuerysetEqual(q1, ["<Item: i1>"])
self.assertEqual(str(q1.query), str(q2.query))
@@ -3081,12 +3080,10 @@ class NullJoinPromotionOrTest(TestCase):
# Test OR + doubleneg. The expected result is that channel is LOUTER
# joined, program INNER joined
qs1_filter = Identifier.objects.filter(
- Q(program__id=p2.id, channel__id=c1.id)
- | Q(program__id=p1.id)
+ Q(program__id=p2.id, channel__id=c1.id) | Q(program__id=p1.id)
).order_by('pk')
qs1_doubleneg = Identifier.objects.exclude(
- ~Q(Q(program__id=p2.id, channel__id=c1.id)
- | Q(program__id=p1.id))
+ ~Q(Q(program__id=p2.id, channel__id=c1.id) | Q(program__id=p1.id))
).order_by('pk')
self.assertQuerysetEqual(qs1_doubleneg, qs1_filter, lambda x: x)
self.assertEqual(str(qs1_filter.query).count('JOIN'),
@@ -3106,11 +3103,11 @@ class NullJoinPromotionOrTest(TestCase):
# NOT is pushed to lowest level in the boolean tree, and
# another query where this isn't done.
qs1 = Identifier.objects.filter(
- ~Q(~Q(program__id=p2.id, channel__id=c1.id)
- & Q(program__id=p1.id))).order_by('pk')
+ ~Q(~Q(program__id=p2.id, channel__id=c1.id) & Q(program__id=p1.id))
+ ).order_by('pk')
qs2 = Identifier.objects.filter(
- Q(Q(program__id=p2.id, channel__id=c1.id)
- | ~Q(program__id=p1.id))).order_by('pk')
+ Q(Q(program__id=p2.id, channel__id=c1.id) | ~Q(program__id=p1.id))
+ ).order_by('pk')
self.assertQuerysetEqual(qs1, qs2, lambda x: x)
self.assertEqual(str(qs1.query).count('JOIN'),
str(qs2.query).count('JOIN'))
@@ -3697,8 +3694,7 @@ class Ticket23605Tests(TestCase):
F("ticket23605b__modelc_fk__field_c0")
) &
# True for a1 (field_b1=True)
- Q(ticket23605b__field_b1=True) &
- ~Q(ticket23605b__pk__in=Ticket23605B.objects.filter(
+ Q(ticket23605b__field_b1=True) & ~Q(ticket23605b__pk__in=Ticket23605B.objects.filter(
~(
# Same filters as above commented filters, but
# double-negated (one for Q() above, one for
@@ -3803,12 +3799,12 @@ class Ticket23622Tests(TestCase):
modelc_fk=c1,
)
qx = (
- Q(ticket23605b__pk__in=Ticket23605B.objects.order_by('modela_fk', '-field_b1').distinct('modela_fk'))
- & Q(ticket23605b__field_b0__gte=300)
+ Q(ticket23605b__pk__in=Ticket23605B.objects.order_by('modela_fk', '-field_b1').distinct('modela_fk')) &
+ Q(ticket23605b__field_b0__gte=300)
)
qy = (
- Q(ticket23605b__in=Ticket23605B.objects.order_by('modela_fk', '-field_b1').distinct('modela_fk'))
- & Q(ticket23605b__field_b0__gte=300)
+ Q(ticket23605b__in=Ticket23605B.objects.order_by('modela_fk', '-field_b1').distinct('modela_fk')) &
+ Q(ticket23605b__field_b0__gte=300)
)
self.assertEqual(
set(Ticket23605A.objects.filter(qx).values_list('pk', flat=True)),
diff --git a/tests/serializers/tests.py b/tests/serializers/tests.py
index af275a8568..c18cdae7e0 100644
--- a/tests/serializers/tests.py
+++ b/tests/serializers/tests.py
@@ -398,9 +398,9 @@ def register_tests(test_class, method_name, test_func, exclude=None):
"""
formats = [
f for f in serializers.get_serializer_formats()
- if (not isinstance(serializers.get_serializer(f), serializers.BadSerializer)
- and not f == 'geojson'
- and (exclude is None or f not in exclude))
+ if (not isinstance(serializers.get_serializer(f), serializers.BadSerializer) and
+ f != 'geojson' and
+ (exclude is None or f not in exclude))
]
for format_ in formats:
setattr(test_class, method_name % format_, curry(test_func, format_))