diff --git a/tests/admin_custom_urls/tests.py b/tests/admin_custom_urls/tests.py index f804036158..edabb6eb78 100644 --- a/tests/admin_custom_urls/tests.py +++ b/tests/admin_custom_urls/tests.py @@ -25,7 +25,7 @@ class AdminCustomUrlsTest(TestCase): def tearDown(self): self.client.logout() - def testBasicAddGet(self): + def test_basic_add_GET(self): """ Ensure GET on the add_view works. """ @@ -33,7 +33,7 @@ class AdminCustomUrlsTest(TestCase): self.assertIsInstance(response, TemplateResponse) self.assertEqual(response.status_code, 200) - def testAddWithGETArgs(self): + def test_add_with_GET_args(self): """ Ensure GET on the add_view plus specifying a field value in the query string works. @@ -42,7 +42,7 @@ class AdminCustomUrlsTest(TestCase): self.assertEqual(response.status_code, 200) self.assertContains(response, 'value="My Action"') - def testBasicAddPost(self): + def test_basic_add_POST(self): """ Ensure POST on add_view works. """ @@ -56,7 +56,7 @@ class AdminCustomUrlsTest(TestCase): self.assertContains(response, 'dismissAddAnotherPopup') self.assertContains(response, 'Action added through a popup') - def testAdminUrlsNoClash(self): + def test_admin_URLs_no_clash(self): """ Test that some admin URLs work correctly. """ diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index f1d2dab520..f3e060fd92 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -92,7 +92,7 @@ class AdminViewBasicTestCase(TestCase): class AdminViewBasicTest(AdminViewBasicTestCase): - def testTrailingSlashRequired(self): + def test_trailing_slash_required(self): """ If you leave off the trailing slash, app should redirect and add it. """ @@ -101,7 +101,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): '/test_admin/%s/admin_views/article/add/' % self.urlbit, status_code=301) - def testBasicAddGet(self): + def test_basic_add_GET(self): """ A smoke test to ensure GET on the add_view works. """ @@ -109,13 +109,13 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertIsInstance(response, TemplateResponse) self.assertEqual(response.status_code, 200) - def testAddWithGETArgs(self): + def test_add_with_GET_args(self): response = self.client.get('/test_admin/%s/admin_views/section/add/' % self.urlbit, {'name': 'My Section'}) self.assertEqual(response.status_code, 200) self.assertContains(response, 'value="My Section"', msg_prefix="Couldn't find an input with the right value in the response") - def testBasicEditGet(self): + def test_basic_edit_GET(self): """ A smoke test to ensure GET on the change_view works. """ @@ -123,7 +123,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertIsInstance(response, TemplateResponse) self.assertEqual(response.status_code, 200) - def testBasicEditGetStringPK(self): + def test_basic_edit_GET_string_PK(self): """ Ensure GET on the change_view works (returns an HTTP 404 error, see #11191) when passing a string as the PK argument for a model with an @@ -132,7 +132,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.get('/test_admin/%s/admin_views/section/abc/' % self.urlbit) self.assertEqual(response.status_code, 404) - def testBasicInheritanceGetStringPK(self): + def test_basic_inheritance_GET_string_PK(self): """ Ensure GET on the change_view works on inherited models (returns an HTTP 404 error, see #19951) when passing a string as the PK argument @@ -141,7 +141,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.get('/test_admin/%s/admin_views/supervillain/abc/' % self.urlbit) self.assertEqual(response.status_code, 404) - def testBasicAddPost(self): + def test_basic_add_POST(self): """ A smoke test to ensure POST on add_view works. """ @@ -155,7 +155,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.post('/test_admin/%s/admin_views/section/add/' % self.urlbit, post_data) self.assertEqual(response.status_code, 302) # redirect somewhere - def testPopupAddPost(self): + def test_popup_add_POST(self): """ Ensure http response from a popup is properly escaped. """ @@ -212,14 +212,14 @@ class AdminViewBasicTest(AdminViewBasicTestCase): "article_set-5-date_1": "", } - def testBasicEditPost(self): + def test_basic_edit_POST(self): """ A smoke test to ensure POST on edit_view works. """ response = self.client.post('/test_admin/%s/admin_views/section/1/' % self.urlbit, self.inline_post_data) self.assertEqual(response.status_code, 302) # redirect somewhere - def testEditSaveAs(self): + def test_edit_save_as(self): """ Test "save as". """ @@ -235,7 +235,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.post('/test_admin/%s/admin_views/section/1/' % self.urlbit, post_data) self.assertEqual(response.status_code, 302) # redirect somewhere - def testChangeListSortingCallable(self): + def test_change_list_sorting_callable(self): """ Ensure we can sort on a list_display field that is a callable (column 2 is callable_year in ArticleAdmin) @@ -246,7 +246,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertContentBefore(response, 'Middle content', 'Newest content', "Results of sorting on callable are out of order.") - def testChangeListSortingModel(self): + def test_change_list_sorting_model(self): """ Ensure we can sort on a list_display field that is a Model method (column 3 is 'model_year' in ArticleAdmin) @@ -257,7 +257,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertContentBefore(response, 'Middle content', 'Oldest content', "Results of sorting on Model method are out of order.") - def testChangeListSortingModelAdmin(self): + def test_change_list_sorting_model_admin(self): """ Ensure we can sort on a list_display field that is a ModelAdmin method (column 4 is 'modeladmin_year' in ArticleAdmin) @@ -268,7 +268,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertContentBefore(response, 'Middle content', 'Newest content', "Results of sorting on ModelAdmin method are out of order.") - def testChangeListSortingModelAdminReverse(self): + def test_change_list_sorting_model_admin_reverse(self): """ Ensure we can sort on a list_display field that is a ModelAdmin method in reverse order (i.e. admin_order_field uses the '-' prefix) @@ -287,7 +287,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertContentBefore(response, '2008', '2009', "Results of sorting on ModelAdmin method are out of order.") - def testChangeListSortingMultiple(self): + def test_change_list_sorting_multiple(self): p1 = Person.objects.create(name="Chris", gender=1, alive=True) p2 = Person.objects.create(name="Chris", gender=2, alive=True) p3 = Person.objects.create(name="Bob", gender=1, alive=True) @@ -307,7 +307,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertContentBefore(response, link2, link3) self.assertContentBefore(response, link3, link1) - def testChangeListSortingPreserveQuerySetOrdering(self): + def test_change_list_sorting_preserve_queryset_ordering(self): """ If no ordering is defined in `ModelAdmin.ordering` or in the query string, then the underlying order of the queryset should not be @@ -327,7 +327,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertContentBefore(response, link3, link2) self.assertContentBefore(response, link2, link1) - def testChangeListSortingModelMeta(self): + def test_change_list_sorting_model_meta(self): # Test ordering on Model Meta is respected l1 = Language.objects.create(iso='ur', name='Urdu') @@ -342,7 +342,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.get('/test_admin/admin/admin_views/language/', {'o': '-1'}) self.assertContentBefore(response, link1, link2) - def testChangeListSortingOverrideModelAdmin(self): + def test_change_list_sorting_override_model_admin(self): # Test ordering on Model Admin is respected, and overrides Model Meta dt = datetime.datetime.now() p1 = Podcast.objects.create(name="A", release_date=dt) @@ -353,7 +353,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.get('/test_admin/admin/admin_views/podcast/', {}) self.assertContentBefore(response, link1, link2) - def testMultipleSortSameField(self): + 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 dt = datetime.datetime.now() @@ -383,7 +383,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): # Check sorting - should be by name self.assertContentBefore(response, link2, link1) - def testSortIndicatorsAdminOrder(self): + 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 @@ -409,7 +409,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertContentBefore(response, 'The First Item', 'The Middle Item') self.assertContentBefore(response, 'The Middle Item', 'The Last Item') - def testLimitedFilter(self): + def test_limited_filter(self): """Ensure admin changelist filters do not contain objects excluded via limit_choices_to. This also tests relation-spanning filters (e.g. 'color__value'). """ @@ -420,7 +420,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertNotContains(response, 'Blue', msg_prefix="Changelist filter not correctly limited by limit_choices_to") - def testRelationSpanningFilters(self): + def test_relation_spanning_filters(self): response = self.client.get('/test_admin/%s/admin_views/chapterxtra1/' % self.urlbit) self.assertEqual(response.status_code, 200) @@ -459,7 +459,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): for obj in filtered_response.context['cl'].queryset.all(): self.assertTrue(params['test'](obj, value)) - def testIncorrectLookupParameters(self): + def test_incorrect_lookup_parameters(self): """Ensure incorrect lookup parameters are handled gracefully.""" response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit, {'notarealfield': '5'}) self.assertRedirects(response, '/test_admin/%s/admin_views/thing/?e=1' % self.urlbit) @@ -475,7 +475,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit, {'pub_date__gte': 'foo'}) self.assertRedirects(response, '/test_admin/%s/admin_views/thing/?e=1' % self.urlbit) - def testIsNullLookups(self): + def test_isnull_lookups(self): """Ensure is_null is handled correctly.""" Article.objects.create(title="I Could Go Anywhere", content="Versatile", date=datetime.datetime.now()) response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit) @@ -489,12 +489,12 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit, {'section__isnull': '1'}) self.assertContains(response, '1 article') - def testLogoutAndPasswordChangeURLs(self): + def test_logout_and_password_change_URLs(self): response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit) self.assertContains(response, '' % self.urlbit) self.assertContains(response, '' % self.urlbit) - def testNamedGroupFieldChoicesChangeList(self): + def test_named_group_field_choices_change_list(self): """ Ensures the admin changelist shows correct values in the relevant column for rows corresponding to instances of a model in which a named group @@ -507,7 +507,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertContains(response, 'Horizontal' % link1, msg_prefix=fail_msg, html=True) self.assertContains(response, 'Vertical' % link2, msg_prefix=fail_msg, html=True) - def testNamedGroupFieldChoicesFilter(self): + def test_named_group_field_choices_filter(self): """ Ensures the filter UI shows correctly when at least one named group has been used in the choices option of a model field. @@ -520,7 +520,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): self.assertContains(response, 'Vertical', msg_prefix=fail_msg, html=True) - def testChangeListNullBooleanDisplay(self): + def test_change_list_null_boolean_display(self): Post.objects.create(public=None) # This hard-codes the URl because it'll fail if it runs # against the 'admin2' custom admin (which doesn't have the @@ -528,7 +528,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.get("/test_admin/admin/admin_views/post/") self.assertContains(response, 'icon-unknown.gif') - def testI18NLanguageNonEnglishDefault(self): + def test_i18n_language_non_english_default(self): """ Check if the JavaScript i18n view returns an empty language catalog if the default language is non-English but the selected language @@ -538,7 +538,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.get('/test_admin/admin/jsi18n/') self.assertNotContains(response, 'Choisir une heure') - def testI18NLanguageNonEnglishFallback(self): + def test_i18n_language_non_english_fallback(self): """ Makes sure that the fallback language is still working properly in cases where the selected language cannot be found. @@ -547,7 +547,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.get('/test_admin/admin/jsi18n/') self.assertContains(response, 'Choisir une heure') - def testL10NDeactivated(self): + def test_L10N_deactivated(self): """ Check if L10N is deactivated, the JavaScript i18n view doesn't return localized date/time formats. Refs #14824. @@ -789,7 +789,7 @@ class AdminViewFormUrlTest(TestCase): def tearDown(self): self.client.logout() - def testChangeFormUrlHasCorrectValue(self): + def test_change_form_URL_has_correct_value(self): """ Tests whether change_view has form_url in response.context """ @@ -797,7 +797,7 @@ class AdminViewFormUrlTest(TestCase): self.assertTrue('form_url' in response.context, msg='form_url not present in response.context') self.assertEqual(response.context['form_url'], 'pony') - def testInitialDataCanBeOverridden(self): + def test_initial_data_can_be_overridden(self): """ Tests that the behavior for setting initial form data can be overridden in the ModelAdmin class. @@ -891,7 +891,7 @@ class SaveAsTests(TestCase): class CustomModelAdminTest(AdminViewBasicTestCase): urlbit = "admin2" - def testCustomAdminSiteLoginForm(self): + def test_custom_admin_site_login_form(self): self.client.logout() response = self.client.get('/test_admin/admin2/', follow=True) self.assertIsInstance(response, TemplateResponse) @@ -905,20 +905,20 @@ class CustomModelAdminTest(AdminViewBasicTestCase): self.assertEqual(login.status_code, 200) self.assertContains(login, 'custom form error') - def testCustomAdminSiteLoginTemplate(self): + def test_custom_admin_site_login_template(self): self.client.logout() response = self.client.get('/test_admin/admin2/', follow=True) self.assertIsInstance(response, TemplateResponse) self.assertTemplateUsed(response, 'custom_admin/login.html') self.assertContains(response, 'Hello from a custom login template') - def testCustomAdminSiteLogoutTemplate(self): + def test_custom_admin_site_logout_template(self): response = self.client.get('/test_admin/admin2/logout/') self.assertIsInstance(response, TemplateResponse) self.assertTemplateUsed(response, 'custom_admin/logout.html') self.assertContains(response, 'Hello from a custom logout template') - def testCustomAdminSiteIndexViewAndTemplate(self): + def test_custom_admin_site_index_view_and_template(self): try: response = self.client.get('/test_admin/admin2/') except TypeError: @@ -927,25 +927,25 @@ class CustomModelAdminTest(AdminViewBasicTestCase): self.assertTemplateUsed(response, 'custom_admin/index.html') self.assertContains(response, 'Hello from a custom index template *bar*') - def testCustomAdminSiteAppIndexViewandTemplate(self): + def test_custom_admin_site_app_index_view_and_template(self): response = self.client.get('/test_admin/admin2/admin_views/') self.assertIsInstance(response, TemplateResponse) self.assertTemplateUsed(response, 'custom_admin/app_index.html') self.assertContains(response, 'Hello from a custom app_index template') - def testCustomAdminSitePasswordChangeTemplate(self): + def test_custom_admin_site_password_change_template(self): response = self.client.get('/test_admin/admin2/password_change/') self.assertIsInstance(response, TemplateResponse) self.assertTemplateUsed(response, 'custom_admin/password_change_form.html') self.assertContains(response, 'Hello from a custom password change form template') - def testCustomAdminSitePasswordChangeDoneTemplate(self): + def test_custom_admin_site_password_change_done_template(self): response = self.client.get('/test_admin/admin2/password_change/done/') self.assertIsInstance(response, TemplateResponse) self.assertTemplateUsed(response, 'custom_admin/password_change_done.html') self.assertContains(response, 'Hello from a custom password change done template') - def testCustomAdminSiteView(self): + def test_custom_admin_site_view(self): self.client.login(username='super', password='secret') response = self.client.get('/test_admin/%s/my_view/' % self.urlbit) self.assertEqual(response.content, b"Django is a magical pony!") @@ -1040,7 +1040,7 @@ class AdminViewPermissionsTest(TestCase): 'password': 'secret', } - def testLogin(self): + def test_login(self): """ Make sure only staff members can log in. @@ -1110,7 +1110,7 @@ class AdminViewPermissionsTest(TestCase): form = login.context[0].get('form') self.assertEqual(form.errors['username'][0], 'This field is required.') - def testLoginSuccessfullyRedirectsToOriginalUrl(self): + def test_login_successfully_redirects_to_original_URL(self): response = self.client.get('/test_admin/admin/') self.assertEqual(response.status_code, 302) query_string = 'the-answer=42' @@ -1123,7 +1123,7 @@ class AdminViewPermissionsTest(TestCase): post_data) self.assertRedirects(login, redirect_url) - def testDoubleLoginIsNotAllowed(self): + def test_double_login_is_not_allowed(self): """Regression test for #19327""" login_url = reverse('admin:login') + '?next=/test_admin/admin/' @@ -1151,7 +1151,7 @@ class AdminViewPermissionsTest(TestCase): self.assertFalse(login.context) self.client.get('/test_admin/admin/logout/') - def testAddView(self): + def test_add_view(self): """Test add view restricts access and actually adds items.""" login_url = reverse('admin:login') + '?next=/test_admin/admin/' @@ -1207,7 +1207,7 @@ class AdminViewPermissionsTest(TestCase): # make sure the view removes test cookie self.assertEqual(self.client.session.test_cookie_worked(), False) - def testChangeView(self): + def test_change_view(self): """Change view should restrict access and allow users to edit items.""" login_url = reverse('admin:login') + '?next=/test_admin/admin/' @@ -1285,7 +1285,7 @@ class AdminViewPermissionsTest(TestCase): self.assertContains(response, 'login-form') self.client.get('/test_admin/admin/logout/') - def testHistoryView(self): + def test_history_view(self): """History view should restrict access.""" login_url = reverse('admin:login') + '?next=/test_admin/admin/' @@ -1327,7 +1327,7 @@ class AdminViewPermissionsTest(TestCase): self.client.get('/test_admin/admin/logout/') - def testConditionallyShowAddSectionLink(self): + def test_conditionally_show_add_section_link(self): """ The foreign key widget should only show the "add related" button if the user has permission to add that related item. @@ -1350,7 +1350,7 @@ class AdminViewPermissionsTest(TestCase): response = self.client.get(url) self.assertContains(response, add_link_text) - def testCustomModelAdminTemplates(self): + def test_custom_model_admin_templates(self): login_url = reverse('admin:login') + '?next=/test_admin/admin/' self.client.get('/test_admin/admin/') self.client.post(login_url, self.super_login) @@ -1391,7 +1391,7 @@ class AdminViewPermissionsTest(TestCase): self.client.get('/test_admin/admin/logout/') - def testDeleteView(self): + def test_delete_view(self): """Delete view should restrict access and actually delete items.""" login_url = reverse('admin:login') + '?next=/test_admin/admin/' @@ -1426,7 +1426,7 @@ class AdminViewPermissionsTest(TestCase): self.assertEqual(logged.object_id, '1') self.client.get('/test_admin/admin/logout/') - def testDisabledPermissionsWhenLoggedIn(self): + def test_disabled_permissions_when_logged_in(self): self.client.login(username='super', password='secret') superuser = User.objects.get(username='super') superuser.is_active = False @@ -1439,7 +1439,7 @@ class AdminViewPermissionsTest(TestCase): response = self.client.get('/test_admin/admin/secure-view/', follow=True) self.assertContains(response, 'id="login-form"') - def testDisabledStaffPermissionsWhenLoggedIn(self): + def test_disabled_staff_permissions_when_logged_in(self): self.client.login(username='super', password='secret') superuser = User.objects.get(username='super') superuser.is_staff = False @@ -1452,7 +1452,7 @@ class AdminViewPermissionsTest(TestCase): response = self.client.get('/test_admin/admin/secure-view/', follow=True) self.assertContains(response, 'id="login-form"') - def testAppIndexFailEarly(self): + def test_app_index_fail_early(self): """ If a user has no module perms, avoid iterating over all the modeladmins in the registry. @@ -1901,7 +1901,7 @@ class AdminViewUnicodeTest(TestCase): def tearDown(self): self.client.logout() - def testUnicodeEdit(self): + def test_unicode_edit(self): """ A test to ensure that POST on edit_view handles non-ASCII characters. """ @@ -1934,7 +1934,7 @@ class AdminViewUnicodeTest(TestCase): response = self.client.post('/test_admin/admin/admin_views/book/1/', post_data) self.assertEqual(response.status_code, 302) # redirect somewhere - def testUnicodeDelete(self): + def test_unicode_delete(self): """ Ensure that the delete_view handles non-ASCII characters """ @@ -2404,7 +2404,7 @@ class AdminInheritedInlinesTest(TestCase): def tearDown(self): self.client.logout() - def testInline(self): + def test_inline(self): "Ensure that inline models which inherit from a common parent are correctly handled by admin." foo_user = "foo username" @@ -2791,7 +2791,7 @@ class TestInlineNotEditable(TestCase): def tearDown(self): self.client.logout() - def test(self): + def test_GET_parent_add(self): """ InlineModelAdmin broken? """ @@ -3421,64 +3421,64 @@ class NeverCacheTests(TestCase): def tearDown(self): self.client.logout() - def testAdminIndex(self): + def test_admin_index(self): "Check the never-cache status of the main index" response = self.client.get('/test_admin/admin/') self.assertEqual(get_max_age(response), 0) - def testAppIndex(self): + def test_app_index(self): "Check the never-cache status of an application index" response = self.client.get('/test_admin/admin/admin_views/') self.assertEqual(get_max_age(response), 0) - def testModelIndex(self): + def test_model_index(self): "Check the never-cache status of a model index" response = self.client.get('/test_admin/admin/admin_views/fabric/') self.assertEqual(get_max_age(response), 0) - def testModelAdd(self): + def test_model_add(self): "Check the never-cache status of a model add page" response = self.client.get('/test_admin/admin/admin_views/fabric/add/') self.assertEqual(get_max_age(response), 0) - def testModelView(self): + def test_model_view(self): "Check the never-cache status of a model edit page" response = self.client.get('/test_admin/admin/admin_views/section/1/') self.assertEqual(get_max_age(response), 0) - def testModelHistory(self): + def test_model_history(self): "Check the never-cache status of a model history page" response = self.client.get('/test_admin/admin/admin_views/section/1/history/') self.assertEqual(get_max_age(response), 0) - def testModelDelete(self): + def test_model_delete(self): "Check the never-cache status of a model delete page" response = self.client.get('/test_admin/admin/admin_views/section/1/delete/') self.assertEqual(get_max_age(response), 0) - def testLogin(self): + def test_login(self): "Check the never-cache status of login views" self.client.logout() response = self.client.get('/test_admin/admin/') self.assertEqual(get_max_age(response), 0) - def testLogout(self): + def test_logout(self): "Check the never-cache status of logout view" response = self.client.get('/test_admin/admin/logout/') self.assertEqual(get_max_age(response), 0) - def testPasswordChange(self): + def test_password_change(self): "Check the never-cache status of the password change view" self.client.logout() response = self.client.get('/test_admin/password_change/') self.assertEqual(get_max_age(response), None) - def testPasswordChangeDone(self): + def test_password_change_done(self): "Check the never-cache status of the password change done view" response = self.client.get('/test_admin/admin/password_change/done/') self.assertEqual(get_max_age(response), None) - def testJsi18n(self): + def test_JS_i18n(self): "Check the never-cache status of the JavaScript i18n view" response = self.client.get('/test_admin/admin/jsi18n/') self.assertEqual(get_max_age(response), None) @@ -4116,7 +4116,7 @@ class CSSTest(TestCase): self.assertContains(response, '') self.assertContains(response, '') - def testAppModelInFormBodyClass(self): + def test_app_model_in_form_body_class(self): """ Ensure app and model tag are correctly read by change_form template """ @@ -4125,7 +4125,7 @@ class CSSTest(TestCase): self.assertContains(response, '

' % self.png_media_pk) self.assertHTMLEqual(formset.forms[1].as_p(), '

') - def testGenericInlineFormsetFactory(self): + def test_generic_inline_formset_factory(self): # Regression test for #10522. inline_formset = generic_inlineformset_factory(Media, exclude=('url',)) @@ -153,7 +153,7 @@ class GenericInlineAdminParametersTest(TestCase): Media.objects.create(content_object=e, url='http://example.com/podcast.mp3') return e - def testNoParam(self): + def test_no_param(self): """ With one initial form, extra (default) at 3, there should be 4 forms. """ @@ -163,7 +163,7 @@ class GenericInlineAdminParametersTest(TestCase): self.assertEqual(formset.total_form_count(), 4) self.assertEqual(formset.initial_form_count(), 1) - def testExtraParam(self): + def test_extra_param(self): """ With extra=0, there should be one form. """ @@ -202,7 +202,7 @@ class GenericInlineAdminParametersTest(TestCase): self.assertEqual(formset.total_form_count(), 2) self.assertEqual(formset.initial_form_count(), 1) - def testMinNumParam(self): + def test_min_num_param(self): """ With extra=3 and min_num=2, there should be five forms. """ @@ -234,7 +234,7 @@ class GenericInlineAdminWithUniqueTogetherTest(TestCase): def tearDown(self): self.client.logout() - def testAdd(self): + def test_add(self): category_id = Category.objects.create(name='male').pk post_data = { "name": "John Doe", diff --git a/tests/nested_foreign_keys/tests.py b/tests/nested_foreign_keys/tests.py index faf9f60647..e08922aefb 100644 --- a/tests/nested_foreign_keys/tests.py +++ b/tests/nested_foreign_keys/tests.py @@ -31,7 +31,7 @@ class NestedForeignKeysTests(TestCase): # This test failed in #16715 because in some cases INNER JOIN was selected # for the second foreign key relation instead of LEFT OUTER JOIN. - def testInheritance(self): + def test_inheritance(self): Event.objects.create() Screening.objects.create(movie=self.movie) @@ -52,7 +52,7 @@ class NestedForeignKeysTests(TestCase): self.assertEqual(Event.objects.exclude(screening__movie=self.movie).count(), 1) # These all work because the second foreign key in the chain has null=True. - def testInheritanceNullFK(self): + def test_inheritance_null_FK(self): Event.objects.create() ScreeningNullFK.objects.create(movie=None) ScreeningNullFK.objects.create(movie=self.movie) @@ -79,7 +79,7 @@ class NestedForeignKeysTests(TestCase): # This test failed in #16715 because in some cases INNER JOIN was selected # for the second foreign key relation instead of LEFT OUTER JOIN. - def testExplicitForeignKey(self): + def test_explicit_ForeignKey(self): Package.objects.create() screening = Screening.objects.create(movie=self.movie) Package.objects.create(screening=screening) @@ -99,7 +99,7 @@ class NestedForeignKeysTests(TestCase): self.assertEqual(Package.objects.exclude(screening__movie=self.movie).count(), 1) # These all work because the second foreign key in the chain has null=True. - def testExplicitForeignKeyNullFK(self): + def test_explicit_ForeignKey_NullFK(self): PackageNullFK.objects.create() screening = ScreeningNullFK.objects.create(movie=None) screening_with_movie = ScreeningNullFK.objects.create(movie=self.movie) @@ -128,7 +128,7 @@ class DeeplyNestedForeignKeysTests(TestCase): self.director = Person.objects.create(name='Terry Gilliam / Terry Jones') self.movie = Movie.objects.create(title='Monty Python and the Holy Grail', director=self.director) - def testInheritance(self): + def test_inheritance(self): Event.objects.create() Screening.objects.create(movie=self.movie) @@ -147,7 +147,7 @@ class DeeplyNestedForeignKeysTests(TestCase): self.assertEqual(Event.objects.filter(screening__movie__director=self.director).count(), 1) self.assertEqual(Event.objects.exclude(screening__movie__director=self.director).count(), 1) - def testExplicitForeignKey(self): + def test_explicit_ForeignKey(self): Package.objects.create() screening = Screening.objects.create(movie=self.movie) Package.objects.create(screening=screening) diff --git a/tests/raw_query/tests.py b/tests/raw_query/tests.py index 17479df6cd..80372c1ae0 100644 --- a/tests/raw_query/tests.py +++ b/tests/raw_query/tests.py @@ -59,7 +59,7 @@ class RawQueryTests(TestCase): self.assertTrue(hasattr(result, annotation)) self.assertEqual(getattr(result, annotation), value) - def testSimpleRawQuery(self): + def test_simple_raw_query(self): """ Basic test of raw query with a simple database query """ @@ -67,7 +67,7 @@ class RawQueryTests(TestCase): authors = Author.objects.all() self.assertSuccessfulRawQuery(Author, query, authors) - def testRawQueryLazy(self): + def test_raw_query_lazy(self): """ Raw queries are lazy: they aren't actually executed until they're iterated over. @@ -77,7 +77,7 @@ class RawQueryTests(TestCase): list(q) self.assertTrue(q.query.cursor is not None) - def testFkeyRawQuery(self): + def test_FK_raw_query(self): """ Test of a simple raw query against a model containing a foreign key """ @@ -85,7 +85,7 @@ class RawQueryTests(TestCase): books = Book.objects.all() self.assertSuccessfulRawQuery(Book, query, books) - def testDBColumnHandler(self): + def test_db_column_handler(self): """ Test of a simple raw query against a model containing a field with db_column defined. @@ -94,7 +94,7 @@ class RawQueryTests(TestCase): coffees = Coffee.objects.all() self.assertSuccessfulRawQuery(Coffee, query, coffees) - def testOrderHandler(self): + def test_order_handler(self): """ Test of raw raw query's tolerance for columns being returned in any order @@ -110,7 +110,7 @@ class RawQueryTests(TestCase): authors = Author.objects.all() self.assertSuccessfulRawQuery(Author, query, authors) - def testTranslations(self): + def test_translations(self): """ Test of raw query's optional ability to translate unexpected result column names to specific model fields @@ -120,7 +120,7 @@ class RawQueryTests(TestCase): authors = Author.objects.all() self.assertSuccessfulRawQuery(Author, query, authors, translations=translations) - def testParams(self): + def test_params(self): """ Test passing optional query parameters """ @@ -135,7 +135,7 @@ class RawQueryTests(TestCase): self.assertIsInstance(repr(qset), str) @skipUnlessDBFeature('supports_paramstyle_pyformat') - def testPyformatParams(self): + def test_pyformat_params(self): """ Test passing optional query parameters """ @@ -149,7 +149,7 @@ class RawQueryTests(TestCase): self.assertEqual(len(results), 1) self.assertIsInstance(repr(qset), str) - def testManyToMany(self): + def test_many_to_many(self): """ Test of a simple raw query against a model containing a m2m field """ @@ -157,7 +157,7 @@ class RawQueryTests(TestCase): reviewers = Reviewer.objects.all() self.assertSuccessfulRawQuery(Reviewer, query, reviewers) - def testExtraConversions(self): + def test_extra_conversions(self): """ Test to insure that extra translations are ignored. """ @@ -166,14 +166,14 @@ class RawQueryTests(TestCase): authors = Author.objects.all() self.assertSuccessfulRawQuery(Author, query, authors, translations=translations) - def testMissingFields(self): + def test_missing_fields(self): query = "SELECT id, first_name, dob FROM raw_query_author" for author in Author.objects.raw(query): self.assertNotEqual(author.first_name, None) # last_name isn't given, but it will be retrieved on demand self.assertNotEqual(author.last_name, None) - def testMissingFieldsWithoutPK(self): + def test_missing_fields_without_PK(self): query = "SELECT first_name, dob FROM raw_query_author" try: list(Author.objects.raw(query)) @@ -181,7 +181,7 @@ class RawQueryTests(TestCase): except InvalidQuery: pass - def testAnnotations(self): + def test_annotations(self): query = "SELECT a.*, count(b.id) as book_count FROM raw_query_author a LEFT JOIN raw_query_book b ON a.id = b.author_id GROUP BY a.id, a.first_name, a.last_name, a.dob ORDER BY a.id" expected_annotations = ( ('book_count', 3), @@ -192,12 +192,12 @@ class RawQueryTests(TestCase): authors = Author.objects.all() self.assertSuccessfulRawQuery(Author, query, authors, expected_annotations) - def testWhiteSpaceQuery(self): + def test_white_space_query(self): query = " SELECT * FROM raw_query_author" authors = Author.objects.all() self.assertSuccessfulRawQuery(Author, query, authors) - def testMultipleIterations(self): + def test_multiple_iterations(self): query = "SELECT * FROM raw_query_author" normal_authors = Author.objects.all() raw_authors = Author.objects.raw(query) @@ -216,7 +216,7 @@ class RawQueryTests(TestCase): self.assertEqual(first_iterations, second_iterations) - def testGetItem(self): + def test_get_item(self): # Indexing on RawQuerySets query = "SELECT * FROM raw_query_author ORDER BY id ASC" third_author = Author.objects.raw(query)[2] diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py index eec439a11c..3f512ad80b 100644 --- a/tests/utils_tests/test_http.py +++ b/tests/utils_tests/test_http.py @@ -121,27 +121,27 @@ class TestUtilsHttp(unittest.TestCase): class ETagProcessingTests(unittest.TestCase): - def testParsing(self): + def test_parsing(self): etags = http.parse_etags(r'"", "etag", "e\"t\"ag", "e\\tag", W/"weak"') self.assertEqual(etags, ['', 'etag', 'e"t"ag', r'e\tag', 'weak']) - def testQuoting(self): + def test_quoting(self): quoted_etag = http.quote_etag(r'e\t"ag') self.assertEqual(quoted_etag, r'"e\\t\"ag"') class HttpDateProcessingTests(unittest.TestCase): - def testParsingRfc1123(self): + def test_parsing_rfc1123(self): parsed = http.parse_http_date('Sun, 06 Nov 1994 08:49:37 GMT') self.assertEqual(datetime.utcfromtimestamp(parsed), datetime(1994, 11, 6, 8, 49, 37)) - def testParsingRfc850(self): + def test_parsing_rfc850(self): parsed = http.parse_http_date('Sunday, 06-Nov-94 08:49:37 GMT') self.assertEqual(datetime.utcfromtimestamp(parsed), datetime(1994, 11, 6, 8, 49, 37)) - def testParsingAsctime(self): + def test_parsing_asctime(self): parsed = http.parse_http_date('Sun Nov 6 08:49:37 1994') self.assertEqual(datetime.utcfromtimestamp(parsed), datetime(1994, 11, 6, 8, 49, 37)) diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py index 8798c0d24f..a40491c36c 100644 --- a/tests/view_tests/tests/test_i18n.py +++ b/tests/view_tests/tests/test_i18n.py @@ -115,7 +115,7 @@ class JsI18NTests(TestCase): response = self.client.get('/jsi18n/') self.assertContains(response, 'il faut le traduire') - def testI18NLanguageNonEnglishDefault(self): + def test_i18n_language_non_english_default(self): """ Check if the Javascript i18n view returns an empty language catalog if the default language is non-English, the selected language @@ -127,7 +127,7 @@ class JsI18NTests(TestCase): self.assertNotContains(response, 'Choisir une heure') @modify_settings(INSTALLED_APPS={'append': 'view_tests.app0'}) - def test_nonenglish_default_english_userpref(self): + def test_non_english_default_english_userpref(self): """ Same as above with the difference that there IS an 'en' translation available. The Javascript i18n view must return a NON empty language catalog @@ -137,7 +137,7 @@ class JsI18NTests(TestCase): response = self.client.get('/jsi18n_english_translation/') self.assertContains(response, 'this app0 string is to be translated') - def testI18NLanguageNonEnglishFallback(self): + def test_i18n_language_non_english_fallback(self): """ Makes sure that the fallback language is still working properly in cases where the selected language cannot be found. @@ -170,7 +170,7 @@ class JsI18NTestsMultiPackage(TestCase): settings.LANGUAGE_CODE and merge JS translation from several packages. """ @modify_settings(INSTALLED_APPS={'append': ['view_tests.app1', 'view_tests.app2']}) - def testI18NLanguageEnglishDefault(self): + def test_i18n_language_english_default(self): """ Check if the JavaScript i18n view returns a complete language catalog if the default language is en-us, the selected language has a @@ -183,7 +183,7 @@ class JsI18NTestsMultiPackage(TestCase): self.assertContains(response, 'il faut traduire cette cha\\u00eene de caract\\u00e8res de app1') @modify_settings(INSTALLED_APPS={'append': ['view_tests.app3', 'view_tests.app4']}) - def testI18NDifferentNonEnLangs(self): + def test_i18n_different_non_english_languages(self): """ Similar to above but with neither default or requested language being English. @@ -192,7 +192,7 @@ class JsI18NTestsMultiPackage(TestCase): response = self.client.get('/jsi18n_multi_packages2/') self.assertContains(response, 'este texto de app3 debe ser traducido') - def testI18NWithLocalePaths(self): + def test_i18n_with_locale_paths(self): extended_locale_paths = settings.LOCALE_PATHS + ( path.join(path.dirname( path.dirname(path.abspath(upath(__file__)))), 'app3', 'locale'),)