From 321e94fa41b121f65c02119c02098df327bbd569 Mon Sep 17 00:00:00 2001 From: za Date: Thu, 27 Oct 2016 14:53:39 +0700 Subject: Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings. --- tests/admin_views/admin.py | 2 - tests/admin_views/tests.py | 205 ++++++++++++++++++++------------------------- 2 files changed, 93 insertions(+), 114 deletions(-) (limited to 'tests/admin_views') diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index be38a14b03..2aa042c386 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -108,7 +108,6 @@ class ArticleAdmin(admin.ModelAdmin): ) def changelist_view(self, request): - "Test that extra_context works" return super(ArticleAdmin, self).changelist_view( request, extra_context={ 'extra_var': 'Hello!' @@ -163,7 +162,6 @@ class CustomArticleAdmin(admin.ModelAdmin): delete_selected_confirmation_template = 'custom_admin/delete_selected_confirmation.html' def changelist_view(self, request): - "Test that extra_context works" return super(CustomArticleAdmin, self).changelist_view( request, extra_context={ 'extra_var': 'Hello!' diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 0eae2e467a..0643448984 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -213,8 +213,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase): def test_admin_static_template_tag(self): """ - Test that admin_static.static is pointing to the collectstatic version - (as django.contrib.collectstatic is in installed apps). + admin_static.static points to the collectstatic version + (as django.contrib.collectstatic is in INSTALLED_APPS). """ old_url = staticfiles_storage.base_url staticfiles_storage.base_url = '/test/' @@ -486,8 +486,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertContentBefore(response, link1, link2) def test_multiple_sort_same_field(self): - # Check that we get the columns we expect if we have two columns - # that correspond to the same ordering field + # The changelist displays the correct columns if two columns correspond + # to the same ordering field. dt = datetime.datetime.now() p1 = Podcast.objects.create(name="A", release_date=dt) p2 = Podcast.objects.create(name="B", release_date=dt - datetime.timedelta(10)) @@ -517,9 +517,9 @@ class AdminViewBasicTest(AdminViewBasicTestCase): def test_sort_indicators_admin_order(self): """ - Ensures that the admin shows default sort indicators for all - kinds of 'ordering' fields: field names, method on the model - admin and model itself, and other callables. See #17252. + The admin shows default sort indicators for all kinds of 'ordering' + fields: field names, method on the model admin and model itself, and + other callables. See #17252. """ models = [(AdminOrderedField, 'adminorderedfield'), (AdminOrderedModelMethod, 'adminorderedmodelmethod'), @@ -857,9 +857,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase): def test_change_view_with_show_delete_extra_context(self): """ - Ensured that the 'show_delete' context variable in the admin's change - view actually controls the display of the delete button. - Refs #10057. + The 'show_delete' context variable in the admin's change view controls + the display of the delete button. """ instance = UndeletableObject.objects.create(name='foo') response = self.client.get(reverse('admin:admin_views_undeletableobject_change', args=(instance.pk,))) @@ -867,11 +866,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase): def test_allows_attributeerror_to_bubble_up(self): """ - Ensure that AttributeErrors are allowed to bubble when raised inside - a change list view. - - Requires a model to be created so there's something to be displayed - + AttributeErrors are allowed to bubble when raised inside a change list + view. Requires a model to be created so there's something to display. Refs: #16655, #18593, and #18747 """ Simple.objects.create() @@ -881,9 +877,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): def test_changelist_with_no_change_url(self): """ ModelAdmin.changelist_view shouldn't result in a NoReverseMatch if url - for change_view is removed from get_urls - - Regression test for #20934 + for change_view is removed from get_urls (#20934). """ UnchangeableObject.objects.create() response = self.client.get(reverse('admin:admin_views_unchangeableobject_changelist')) @@ -977,7 +971,7 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase): def test_extended_bodyclass_template_change_form(self): """ - Ensure that the admin/change_form.html template uses block.super in the + The admin/change_form.html template uses block.super in the bodyclass block. """ response = self.client.get(reverse('admin:admin_views_section_add')) @@ -997,15 +991,14 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase): def test_extended_bodyclass_template_index(self): """ - Ensure that the admin/index.html template uses block.super in the - bodyclass block. + The admin/index.html template uses block.super in the bodyclass block. """ response = self.client.get(reverse('admin:index')) self.assertContains(response, 'bodyclass_consistency_check ') def test_extended_bodyclass_change_list(self): """ - Ensure that the admin/change_list.html' template uses block.super + The admin/change_list.html' template uses block.super in the bodyclass block. """ response = self.client.get(reverse('admin:admin_views_article_changelist')) @@ -1013,7 +1006,7 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase): def test_extended_bodyclass_template_login(self): """ - Ensure that the admin/login.html template uses block.super in the + The admin/login.html template uses block.super in the bodyclass block. """ self.client.logout() @@ -1022,7 +1015,7 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase): def test_extended_bodyclass_template_delete_confirmation(self): """ - Ensure that the admin/delete_confirmation.html template uses + The admin/delete_confirmation.html template uses block.super in the bodyclass block. """ group = Group.objects.create(name="foogroup") @@ -1031,7 +1024,7 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase): def test_extended_bodyclass_template_delete_selected_confirmation(self): """ - Ensure that the admin/delete_selected_confirmation.html template uses + The admin/delete_selected_confirmation.html template uses block.super in bodyclass block. """ group = Group.objects.create(name="foogroup") @@ -1047,8 +1040,7 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase): def test_filter_with_custom_template(self): """ - Ensure that one can use a custom template to render an admin filter. - Refs #17515. + A custom template can be used to render an admin filter. """ response = self.client.get(reverse('admin:admin_views_color2_changelist')) self.assertTemplateUsed(response, 'custom_filter_template.html') @@ -1078,7 +1070,7 @@ class AdminViewFormUrlTest(TestCase): def test_change_form_URL_has_correct_value(self): """ - Tests whether change_view has form_url in response.context + change_view has form_url in response.context """ response = self.client.get( reverse('admin:admin_views_section_change', args=(self.s1.pk,), current_app=self.current_app) @@ -1088,10 +1080,8 @@ class AdminViewFormUrlTest(TestCase): def test_initial_data_can_be_overridden(self): """ - Tests that the behavior for setting initial - form data can be overridden in the ModelAdmin class. - - Usually, the initial value is set via the GET params. + The behavior for setting initial form data can be overridden in the + ModelAdmin class. Usually, the initial value is set via the GET params. """ response = self.client.get( reverse('admin:admin_views_restaurant_add', current_app=self.current_app), @@ -1115,9 +1105,7 @@ class AdminJavaScriptTest(TestCase): def test_js_minified_only_if_debug_is_false(self): """ - Ensure that the minified versions of the JS files are only used when - DEBUG is False. - Refs #17521. + The minified versions of the JS files are only used when DEBUG is False. """ with override_settings(DEBUG=False): response = self.client.get(reverse('admin:admin_views_section_add')) @@ -1157,7 +1145,7 @@ class SaveAsTests(TestCase): self.client.force_login(self.superuser) def test_save_as_duplication(self): - """Ensure save as actually creates a new person""" + """'save as' creates a new person""" post_data = {'_saveasnew': '', 'name': 'John M', 'gender': 1, 'age': 42} response = self.client.post(reverse('admin:admin_views_person_change', args=(self.per1.pk,)), post_data) self.assertEqual(len(Person.objects.filter(name='John M')), 1) @@ -1179,7 +1167,7 @@ class SaveAsTests(TestCase): def test_save_as_new_with_validation_errors(self): """ - Ensure that when you click "Save as new" and have a validation error, + When you click "Save as new" and have a validation error, you only see the "Save as new" button and not the other save buttons, and that only the "Save as" button is visible. """ @@ -1609,7 +1597,7 @@ class AdminViewPermissionsTest(TestCase): self.assertEqual(mail.outbox[0].subject, 'Greetings from a created object') self.client.get(reverse('admin:logout')) - # Check that the addition was logged correctly + # The addition was logged correctly addition_log = LogEntry.objects.all()[0] new_article = Article.objects.last() article_ct = ContentType.objects.get_for_model(Article) @@ -1968,7 +1956,7 @@ class AdminViewPermissionsTest(TestCase): def test_has_module_permission(self): """ - Ensure that has_module_permission() returns True for all users who + has_module_permission() returns True for all users who have any permission for that module (add, change, or delete), so that the module is displayed on the admin index page. """ @@ -1997,9 +1985,8 @@ class AdminViewPermissionsTest(TestCase): def test_overriding_has_module_permission(self): """ - Ensure that overriding has_module_permission() has the desired effect. - In this case, it always returns False, so the module should not be - displayed on the admin index page for any users. + If has_module_permission() always returns False, the module shouldn't + be displayed on the admin index page for any users. """ articles = Article._meta.verbose_name_plural.title() sections = Section._meta.verbose_name_plural.title() @@ -2438,9 +2425,6 @@ class SecureViewTests(TestCase): """ def test_secure_view_shows_login_if_not_logged_in(self): - """ - Ensure that we see the admin login form. - """ secure_url = reverse('secure_view') response = self.client.get(secure_url) self.assertRedirects(response, '%s?next=%s' % (reverse('admin:login'), secure_url)) @@ -2450,7 +2434,7 @@ class SecureViewTests(TestCase): def test_staff_member_required_decorator_works_with_argument(self): """ - Ensure that staff_member_required decorator works with an argument + Staff_member_required decorator works with an argument (redirect_field_name). """ secure_url = '/test_admin/admin/secure-view2/' @@ -2518,7 +2502,7 @@ class AdminViewUnicodeTest(TestCase): def test_unicode_delete(self): """ - Ensure that the delete_view handles non-ASCII characters + The delete_view handles non-ASCII characters """ delete_dict = {'post': 'yes'} delete_url = reverse('admin:admin_views_book_delete', args=(self.b1.pk,)) @@ -2664,9 +2648,10 @@ class AdminViewListEditable(TestCase): self.assertIs(Person.objects.get(name="John Mauchly").alive, False) def test_non_field_errors(self): - ''' Ensure that non field errors are displayed for each of the - forms in the changelist's formset. Refs #13126. - ''' + """ + Non-field errors are displayed for each of the forms in the + changelist's formset. + """ fd1 = FoodDelivery.objects.create(reference='123', driver='bill', restaurant='thai') fd2 = FoodDelivery.objects.create(reference='456', driver='bill', restaurant='india') fd3 = FoodDelivery.objects.create(reference='789', driver='bill', restaurant='pizza') @@ -2747,7 +2732,7 @@ class AdminViewListEditable(TestCase): "form-0-alive": "1", "form-0-gender": "2", - # Ensure that the form processing understands this as a list_editable "Save" + # The form processing understands this as a list_editable "Save" # and not an action "Go". "_save": "Save", } @@ -2802,7 +2787,7 @@ class AdminViewListEditable(TestCase): "form-3-id": "4", "form-3-collector": "1", - # Ensure that the form processing understands this as a list_editable "Save" + # The form processing understands this as a list_editable "Save" # and not an action "Go". "_save": "Save", } @@ -2810,7 +2795,7 @@ class AdminViewListEditable(TestCase): # Successful post will redirect self.assertEqual(response.status_code, 302) - # Check that the order values have been applied to the right objects + # The order values have been applied to the right objects self.assertEqual(Category.objects.get(id=1).order, 14) self.assertEqual(Category.objects.get(id=2).order, 13) self.assertEqual(Category.objects.get(id=3).order, 1) @@ -2818,8 +2803,7 @@ class AdminViewListEditable(TestCase): def test_list_editable_pagination(self): """ - Ensure that pagination works for list_editable items. - Refs #16819. + Pagination works for list_editable items. """ UnorderedObject.objects.create(id=1, name='Unordered object #1') UnorderedObject.objects.create(id=2, name='Unordered object #2') @@ -2897,11 +2881,10 @@ class AdminViewListEditable(TestCase): self.assertEqual(response.context['cl'].list_editable, ()) def test_pk_hidden_fields(self): - """ Ensure that hidden pk fields aren't displayed in the table body and - that their corresponding human-readable value is displayed instead. - Note that the hidden pk fields are in fact be displayed but - separately (not in the table), and only once. - Refs #12475. + """ + hidden pk fields aren't displayed in the table body and their + corresponding human-readable value is displayed instead. The hidden pk + fields are displayed but separately (not in the table) and only once. """ story1 = Story.objects.create(title='The adventures of Guido', content='Once upon a time in Djangoland...') story2 = Story.objects.create( @@ -2991,15 +2974,15 @@ class AdminSearchTest(TestCase): self.client.force_login(self.superuser) def test_search_on_sibling_models(self): - "Check that a search that mentions sibling models" + "A search that mentions sibling models" response = self.client.get(reverse('admin:admin_views_recommendation_changelist') + '?q=bar') # confirm the search returned 1 object self.assertContains(response, "\n1 recommendation\n") def test_with_fk_to_field(self): """ - Ensure that the to_field GET parameter is preserved when a search - is performed. Refs #10918. + The to_field GET parameter is preserved when a search is performed. + Refs #10918. """ response = self.client.get(reverse('admin:auth_user_changelist') + '?q=joe&%s=id' % TO_FIELD_VAR) self.assertContains(response, "\n1 user\n") @@ -3082,7 +3065,9 @@ class AdminInheritedInlinesTest(TestCase): self.client.force_login(self.superuser) def test_inline(self): - "Ensure that inline models which inherit from a common parent are correctly handled by admin." + """ + Inline models which inherit from a common parent are correctly handled. + """ foo_user = "foo username" bar_user = "bar username" @@ -3300,8 +3285,8 @@ class AdminActionsTest(TestCase): def test_default_redirect(self): """ - Test that actions which don't return an HttpResponse are redirected to - the same page, retaining the querystring (which may contain changelist + Actions which don't return an HttpResponse are redirected to the same + page, retaining the querystring (which may contain changelist information). """ action_data = { @@ -3338,8 +3323,7 @@ class AdminActionsTest(TestCase): def test_actions_ordering(self): """ - Ensure that actions are ordered as expected. - Refs #15964. + Actions are ordered as expected. """ response = self.client.get(reverse('admin:admin_views_externalsubscriber_changelist')) self.assertContains(response, '''