Skip to content

Commit 92053ac

Browse files
committed
Fixed E128 flake8 warnings in tests/.
1 parent df8d8d4 commit 92053ac

File tree

148 files changed

+2077
-2252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+2077
-2252
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
44

55
[flake8]
66
exclude = build,.git,./django/utils/lru_cache.py,./django/utils/six.py,./django/conf/app_template/*,./django/dispatch/weakref_backports.py,./tests/.env,./xmlrunner,tests/view_tests/tests/py3_test_debug.py,tests/template_tests/annotated_tag_function.py
7-
ignore = E128,W601
7+
ignore = W601
88
max-line-length = 119
99

1010
[isort]

tests/admin_changelist/admin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
class CustomPaginator(Paginator):
1414
def __init__(self, queryset, page_size, orphans=0, allow_empty_first_page=True):
15-
super(CustomPaginator, self).__init__(queryset, 5, orphans=2,
16-
allow_empty_first_page=allow_empty_first_page)
15+
super(CustomPaginator, self).__init__(queryset, 5, orphans=2, allow_empty_first_page=allow_empty_first_page)
1716

1817

1918
class EventAdmin(admin.ModelAdmin):

tests/admin_changelist/tests.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ def test_result_list_empty_changelist_value(self):
130130
'<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th>'
131131
'<td class="field-parent nowrap">-</td></tr></tbody>' % link
132132
)
133-
self.assertNotEqual(table_output.find(row_html), -1,
134-
'Failed to find expected row element: %s' % table_output)
133+
self.assertNotEqual(table_output.find(row_html), -1, 'Failed to find expected row element: %s' % table_output)
135134

136135
def test_result_list_set_empty_value_display_on_admin_site(self):
137136
"""
@@ -152,8 +151,7 @@ def test_result_list_set_empty_value_display_on_admin_site(self):
152151
'<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th>'
153152
'<td class="field-parent nowrap">???</td></tr></tbody>' % link
154153
)
155-
self.assertNotEqual(table_output.find(row_html), -1,
156-
'Failed to find expected row element: %s' % table_output)
154+
self.assertNotEqual(table_output.find(row_html), -1, 'Failed to find expected row element: %s' % table_output)
157155

158156
def test_result_list_set_empty_value_display_in_model_admin(self):
159157
"""
@@ -172,8 +170,7 @@ def test_result_list_set_empty_value_display_in_model_admin(self):
172170
'<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th>'
173171
'<td class="field-age_display">&amp;dagger;</td><td class="field-age">-empty-</td></tr></tbody>' % link
174172
)
175-
self.assertNotEqual(table_output.find(row_html), -1,
176-
'Failed to find expected row element: %s' % table_output)
173+
self.assertNotEqual(table_output.find(row_html), -1, 'Failed to find expected row element: %s' % table_output)
177174

178175
def test_result_list_html(self):
179176
"""
@@ -194,8 +191,7 @@ def test_result_list_html(self):
194191
'<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th>'
195192
'<td class="field-parent nowrap">Parent object</td></tr></tbody>' % link
196193
)
197-
self.assertNotEqual(table_output.find(row_html), -1,
198-
'Failed to find expected row element: %s' % table_output)
194+
self.assertNotEqual(table_output.find(row_html), -1, 'Failed to find expected row element: %s' % table_output)
199195

200196
def test_result_list_editable_html(self):
201197
"""
@@ -894,8 +890,7 @@ def test_add_row_selection(self):
894890
Ensure that the status line for selected rows gets updated correctly (#22038)
895891
"""
896892
self.admin_login(username='super', password='secret')
897-
self.selenium.get('%s%s' % (self.live_server_url,
898-
reverse('admin:auth_user_changelist')))
893+
self.selenium.get(self.live_server_url + reverse('admin:auth_user_changelist'))
899894

900895
form_id = '#changelist-form'
901896

tests/admin_custom_urls/tests.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@ def test_admin_URLs_no_clash(self):
7373
"""
7474
# Should get the change_view for model instance with PK 'add', not show
7575
# the add_view
76-
url = reverse('admin_custom_urls:%s_action_change' % Action._meta.app_label,
77-
args=(quote('add'),))
76+
url = reverse('admin_custom_urls:%s_action_change' % Action._meta.app_label, args=(quote('add'),))
7877
response = self.client.get(url)
7978
self.assertContains(response, 'Change action')
8079

8180
# Should correctly get the change_view for the model instance with the
8281
# funny-looking PK (the one with a 'path/to/html/document.html' value)
83-
url = reverse('admin_custom_urls:%s_action_change' % Action._meta.app_label,
84-
args=(quote("path/to/html/document.html"),))
82+
url = reverse(
83+
'admin_custom_urls:%s_action_change' % Action._meta.app_label,
84+
args=(quote("path/to/html/document.html"),)
85+
)
8586
response = self.client.get(url)
8687
self.assertContains(response, 'Change action')
8788
self.assertContains(response, 'value="path/to/html/document.html"')
@@ -95,12 +96,11 @@ def test_post_save_add_redirect(self):
9596
"""
9697
post_data = {'name': 'John Doe'}
9798
self.assertEqual(Person.objects.count(), 0)
98-
response = self.client.post(
99-
reverse('admin_custom_urls:admin_custom_urls_person_add'), post_data)
99+
response = self.client.post(reverse('admin_custom_urls:admin_custom_urls_person_add'), post_data)
100100
persons = Person.objects.all()
101101
self.assertEqual(len(persons), 1)
102-
self.assertRedirects(
103-
response, reverse('admin_custom_urls:admin_custom_urls_person_history', args=[persons[0].pk]))
102+
redirect_url = reverse('admin_custom_urls:admin_custom_urls_person_history', args=[persons[0].pk])
103+
self.assertRedirects(response, redirect_url)
104104

105105
def test_post_save_change_redirect(self):
106106
"""
@@ -112,11 +112,9 @@ def test_post_save_change_redirect(self):
112112
Person.objects.create(name='John Doe')
113113
self.assertEqual(Person.objects.count(), 1)
114114
person = Person.objects.all()[0]
115-
post_data = {'name': 'Jack Doe'}
116-
response = self.client.post(
117-
reverse('admin_custom_urls:admin_custom_urls_person_change', args=[person.pk]), post_data)
118-
self.assertRedirects(
119-
response, reverse('admin_custom_urls:admin_custom_urls_person_delete', args=[person.pk]))
115+
post_url = reverse('admin_custom_urls:admin_custom_urls_person_change', args=[person.pk])
116+
response = self.client.post(post_url, {'name': 'Jack Doe'})
117+
self.assertRedirects(response, reverse('admin_custom_urls:admin_custom_urls_person_delete', args=[person.pk]))
120118

121119
def test_post_url_continue(self):
122120
"""
@@ -125,9 +123,7 @@ def test_post_url_continue(self):
125123
"""
126124
post_data = {'name': 'SuperFast', '_continue': '1'}
127125
self.assertEqual(Car.objects.count(), 0)
128-
response = self.client.post(
129-
reverse('admin_custom_urls:admin_custom_urls_car_add'), post_data)
126+
response = self.client.post(reverse('admin_custom_urls:admin_custom_urls_car_add'), post_data)
130127
cars = Car.objects.all()
131128
self.assertEqual(len(cars), 1)
132-
self.assertRedirects(
133-
response, reverse('admin_custom_urls:admin_custom_urls_car_history', args=[cars[0].pk]))
129+
self.assertRedirects(response, reverse('admin_custom_urls:admin_custom_urls_car_history', args=[cars[0].pk]))

tests/admin_docs/tests.py

Lines changed: 28 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,11 @@ def test_index(self):
5454
self.client.logout()
5555
response = self.client.get(reverse('django-admindocs-docroot'), follow=True)
5656
# Should display the login screen
57-
self.assertContains(response,
58-
'<input type="hidden" name="next" value="/admindocs/" />', html=True)
57+
self.assertContains(response, '<input type="hidden" name="next" value="/admindocs/" />', html=True)
5958
self.client.force_login(self.superuser)
6059
response = self.client.get(reverse('django-admindocs-docroot'))
6160
self.assertContains(response, '<h1>Documentation</h1>', html=True)
62-
self.assertContains(response,
63-
'<h1 id="site-name"><a href="/admin/">Django '
64-
'administration</a></h1>')
61+
self.assertContains(response, '<h1 id="site-name"><a href="/admin/">Django administration</a></h1>')
6562

6663
def test_bookmarklets(self):
6764
response = self.client.get(reverse('django-admindocs-bookmarklets'))
@@ -77,26 +74,26 @@ def test_templatefilter_index(self):
7774

7875
def test_view_index(self):
7976
response = self.client.get(reverse('django-admindocs-views-index'))
80-
self.assertContains(response,
77+
self.assertContains(
78+
response,
8179
'<h3><a href="/admindocs/views/django.contrib.admindocs.views.BaseAdminDocsView/">/admindocs/</a></h3>',
82-
html=True)
80+
html=True
81+
)
8382
self.assertContains(response, 'Views by namespace test')
8483
self.assertContains(response, 'Name: <code>test:func</code>.')
8584

8685
def test_view_detail(self):
87-
response = self.client.get(
88-
reverse('django-admindocs-views-detail',
89-
args=['django.contrib.admindocs.views.BaseAdminDocsView']))
86+
url = reverse('django-admindocs-views-detail', args=['django.contrib.admindocs.views.BaseAdminDocsView'])
87+
response = self.client.get(url)
9088
# View docstring
9189
self.assertContains(response, 'Base view for admindocs views.')
9290

9391
def test_view_detail_illegal_import(self):
9492
"""
9593
#23601 - Ensure the view exists in the URLconf.
9694
"""
97-
response = self.client.get(
98-
reverse('django-admindocs-views-detail',
99-
args=['urlpatterns_reverse.nonimported_module.view']))
95+
url = reverse('django-admindocs-views-detail', args=['urlpatterns_reverse.nonimported_module.view'])
96+
response = self.client.get(url)
10097
self.assertEqual(response.status_code, 404)
10198
self.assertNotIn("urlpatterns_reverse.nonimported_module", sys.modules)
10299

@@ -109,22 +106,20 @@ def test_model_index(self):
109106
)
110107

111108
def test_template_detail(self):
112-
response = self.client.get(reverse('django-admindocs-templates',
113-
args=['admin_doc/template_detail.html']))
114-
self.assertContains(response,
115-
'<h1>Template: "admin_doc/template_detail.html"</h1>', html=True)
109+
response = self.client.get(reverse('django-admindocs-templates', args=['admin_doc/template_detail.html']))
110+
self.assertContains(response, '<h1>Template: "admin_doc/template_detail.html"</h1>', html=True)
116111

117112
def test_missing_docutils(self):
118113
utils.docutils_is_available = False
119114
try:
120115
response = self.client.get(reverse('django-admindocs-docroot'))
121-
self.assertContains(response,
116+
self.assertContains(
117+
response,
122118
'<h3>The admin documentation system requires Python\'s '
123119
'<a href="http://docutils.sf.net/">docutils</a> library.</h3>',
124-
html=True)
125-
self.assertContains(response,
126-
'<h1 id="site-name"><a href="/admin/">Django '
127-
'administration</a></h1>')
120+
html=True
121+
)
122+
self.assertContains(response, '<h1 id="site-name"><a href="/admin/">Django administration</a></h1>')
128123
finally:
129124
utils.docutils_is_available = True
130125

@@ -200,18 +195,12 @@ def test_parse_rst(self):
200195
``django.contrib.admindocs.utils.parse_rst`` should use
201196
``cmsreference`` as the default role.
202197
"""
203-
markup = ('<p><a class="reference external" href="/admindocs/%s">'
204-
'title</a></p>\n')
205-
self.assertEqual(utils.parse_rst('`title`', 'model'),
206-
markup % 'models/title/')
207-
self.assertEqual(utils.parse_rst('`title`', 'view'),
208-
markup % 'views/title/')
209-
self.assertEqual(utils.parse_rst('`title`', 'template'),
210-
markup % 'templates/title/')
211-
self.assertEqual(utils.parse_rst('`title`', 'filter'),
212-
markup % 'filters/#title')
213-
self.assertEqual(utils.parse_rst('`title`', 'tag'),
214-
markup % 'tags/#title')
198+
markup = '<p><a class="reference external" href="/admindocs/%s">title</a></p>\n'
199+
self.assertEqual(utils.parse_rst('`title`', 'model'), markup % 'models/title/')
200+
self.assertEqual(utils.parse_rst('`title`', 'view'), markup % 'views/title/')
201+
self.assertEqual(utils.parse_rst('`title`', 'template'), markup % 'templates/title/')
202+
self.assertEqual(utils.parse_rst('`title`', 'filter'), markup % 'filters/#title')
203+
self.assertEqual(utils.parse_rst('`title`', 'tag'), markup % 'tags/#title')
215204

216205
def test_publish_parts(self):
217206
"""
@@ -220,8 +209,7 @@ def test_publish_parts(self):
220209
``cmsreference``. See #6681.
221210
"""
222211
import docutils
223-
self.assertNotEqual(docutils.parsers.rst.roles.DEFAULT_INTERPRETED_ROLE,
224-
'cmsreference')
212+
self.assertNotEqual(docutils.parsers.rst.roles.DEFAULT_INTERPRETED_ROLE, 'cmsreference')
225213
source = 'reST, `interpreted text`, default role.'
226214
markup = '<p>reST, <cite>interpreted text</cite>, default role.</p>\n'
227215
parts = docutils.core.publish_parts(source=source, writer_name="html4css1")
@@ -286,21 +274,9 @@ def test_method_data_types(self):
286274
by a method
287275
"""
288276
company = Company.objects.create(name="Django")
289-
person = Person.objects.create(
290-
first_name="Human",
291-
last_name="User",
292-
company=company
293-
)
294-
295-
self.assertEqual(
296-
get_return_data_type(person.get_status_count.__name__),
297-
'Integer'
298-
)
299-
300-
self.assertEqual(
301-
get_return_data_type(person.get_groups_list.__name__),
302-
'List'
303-
)
277+
person = Person.objects.create(first_name="Human", last_name="User", company=company)
278+
self.assertEqual(get_return_data_type(person.get_status_count.__name__), 'Integer')
279+
self.assertEqual(get_return_data_type(person.get_groups_list.__name__), 'List')
304280

305281
def test_descriptions_render_correctly(self):
306282
"""
@@ -361,10 +337,7 @@ def test_model_with_no_backward_relations_render_only_relevant_fields(self):
361337
A model with ``related_name`` of `+` should not show backward relationship
362338
links in admin docs
363339
"""
364-
response = self.client.get(
365-
reverse('django-admindocs-models-detail',
366-
args=['admin_docs', 'family']))
367-
340+
response = self.client.get(reverse('django-admindocs-models-detail', args=['admin_docs', 'family']))
368341
fields = response.context_data.get('fields')
369342
self.assertEqual(len(fields), 2)
370343

tests/admin_inlines/admin.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ class EditablePKBookStackedInline(admin.StackedInline):
3737

3838

3939
class AuthorAdmin(admin.ModelAdmin):
40-
inlines = [BookInline,
41-
NonAutoPKBookTabularInline, NonAutoPKBookStackedInline,
42-
EditablePKBookTabularInline, EditablePKBookStackedInline]
40+
inlines = [
41+
BookInline, NonAutoPKBookTabularInline, NonAutoPKBookStackedInline,
42+
EditablePKBookTabularInline, EditablePKBookStackedInline,
43+
]
4344

4445

4546
class InnerInline(admin.StackedInline):

0 commit comments

Comments
 (0)