[1.7.x] Fixed #22909 -- Removed camelCasing in some tests.
Thanks brylie.
Backport of 89b9e6e5d6
from master
This commit is contained in:
parent
c379fc4eec
commit
28962c57f3
|
@ -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.
|
||||
"""
|
||||
|
|
|
@ -93,7 +93,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.
|
||||
"""
|
||||
|
@ -102,7 +102,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.
|
||||
"""
|
||||
|
@ -110,13 +110,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.
|
||||
"""
|
||||
|
@ -124,7 +124,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
|
||||
|
@ -133,7 +133,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
|
||||
|
@ -142,7 +142,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.
|
||||
"""
|
||||
|
@ -156,7 +156,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.
|
||||
"""
|
||||
|
@ -213,14 +213,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".
|
||||
"""
|
||||
|
@ -236,7 +236,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)
|
||||
|
@ -247,7 +247,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)
|
||||
|
@ -258,7 +258,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)
|
||||
|
@ -269,7 +269,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)
|
||||
|
@ -288,7 +288,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)
|
||||
|
@ -308,7 +308,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
|
||||
|
@ -328,7 +328,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')
|
||||
|
@ -343,7 +343,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)
|
||||
|
@ -354,7 +354,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()
|
||||
|
@ -384,7 +384,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
|
||||
|
@ -410,7 +410,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').
|
||||
"""
|
||||
|
@ -421,7 +421,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
|||
self.assertNotContains(response, '<a href="?color__id__exact=3">Blue</a>',
|
||||
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)
|
||||
|
@ -460,7 +460,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)
|
||||
|
@ -476,7 +476,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)
|
||||
|
@ -490,12 +490,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, '<a href="/test_admin/%s/logout/">' % self.urlbit)
|
||||
self.assertContains(response, '<a href="/test_admin/%s/password_change/">' % 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
|
||||
|
@ -508,7 +508,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
|||
self.assertContains(response, '<a href="%s">Horizontal</a>' % link1, msg_prefix=fail_msg, html=True)
|
||||
self.assertContains(response, '<a href="%s">Vertical</a>' % 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.
|
||||
|
@ -521,7 +521,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
|||
self.assertContains(response,
|
||||
'<a href="?surface__exact=y">Vertical</a>', 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
|
||||
|
@ -529,7 +529,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
|
||||
|
@ -539,7 +539,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.
|
||||
|
@ -548,7 +548,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.
|
||||
|
@ -790,7 +790,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
|
||||
"""
|
||||
|
@ -798,7 +798,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.
|
||||
|
@ -893,7 +893,7 @@ class CustomModelAdminTest(AdminViewBasicTestCase):
|
|||
urls = "admin_views.urls"
|
||||
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)
|
||||
|
@ -907,20 +907,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:
|
||||
|
@ -929,25 +929,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!")
|
||||
|
@ -1042,7 +1042,7 @@ class AdminViewPermissionsTest(TestCase):
|
|||
'password': 'secret',
|
||||
}
|
||||
|
||||
def testLogin(self):
|
||||
def test_login(self):
|
||||
"""
|
||||
Make sure only staff members can log in.
|
||||
|
||||
|
@ -1112,7 +1112,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'
|
||||
|
@ -1125,7 +1125,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/'
|
||||
|
||||
|
@ -1153,7 +1153,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/'
|
||||
|
@ -1209,7 +1209,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/'
|
||||
|
@ -1287,7 +1287,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/'
|
||||
|
@ -1329,7 +1329,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.
|
||||
|
@ -1352,7 +1352,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)
|
||||
|
@ -1393,7 +1393,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/'
|
||||
|
@ -1428,7 +1428,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
|
||||
|
@ -1441,7 +1441,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
|
||||
|
@ -1454,7 +1454,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.
|
||||
|
@ -1838,7 +1838,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.
|
||||
"""
|
||||
|
@ -1871,7 +1871,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
|
||||
"""
|
||||
|
@ -2341,7 +2341,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"
|
||||
|
@ -2728,7 +2728,7 @@ class TestInlineNotEditable(TestCase):
|
|||
def tearDown(self):
|
||||
self.client.logout()
|
||||
|
||||
def test(self):
|
||||
def test_GET_parent_add(self):
|
||||
"""
|
||||
InlineModelAdmin broken?
|
||||
"""
|
||||
|
@ -3358,64 +3358,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)
|
||||
|
@ -4053,7 +4053,7 @@ class CSSTest(TestCase):
|
|||
self.assertContains(response, '<tr class="model-actor">')
|
||||
self.assertContains(response, '<tr class="model-album">')
|
||||
|
||||
def testAppModelInFormBodyClass(self):
|
||||
def test_app_model_in_form_body_class(self):
|
||||
"""
|
||||
Ensure app and model tag are correctly read by change_form template
|
||||
"""
|
||||
|
@ -4062,7 +4062,7 @@ class CSSTest(TestCase):
|
|||
self.assertContains(response,
|
||||
'<body class=" app-admin_views model-section ')
|
||||
|
||||
def testAppModelInListBodyClass(self):
|
||||
def test_app_model_in_list_body_class(self):
|
||||
"""
|
||||
Ensure app and model tag are correctly read by change_list template
|
||||
"""
|
||||
|
@ -4071,7 +4071,7 @@ class CSSTest(TestCase):
|
|||
self.assertContains(response,
|
||||
'<body class=" app-admin_views model-section ')
|
||||
|
||||
def testAppModelInDeleteConfirmationBodyClass(self):
|
||||
def test_app_model_in_delete_confirmation_body_class(self):
|
||||
"""
|
||||
Ensure app and model tag are correctly read by delete_confirmation
|
||||
template
|
||||
|
@ -4082,7 +4082,7 @@ class CSSTest(TestCase):
|
|||
self.assertContains(response,
|
||||
'<body class=" app-admin_views model-section ')
|
||||
|
||||
def testAppModelInAppIndexBodyClass(self):
|
||||
def test_app_model_in_app_index_body_class(self):
|
||||
"""
|
||||
Ensure app and model tag are correctly read by app_index template
|
||||
"""
|
||||
|
@ -4090,7 +4090,7 @@ class CSSTest(TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, '<body class=" dashboard app-admin_views')
|
||||
|
||||
def testAppModelInDeleteSelectedConfirmationBodyClass(self):
|
||||
def test_app_model_in_delete_selected_confirmation_body_class(self):
|
||||
"""
|
||||
Ensure app and model tag are correctly read by
|
||||
delete_selected_confirmation template
|
||||
|
@ -4190,7 +4190,7 @@ class ValidXHTMLTests(TestCase):
|
|||
global_settings.TEMPLATE_CONTEXT_PROCESSORS),
|
||||
USE_I18N=False,
|
||||
)
|
||||
def testLangNamePresent(self):
|
||||
def test_lang_name_present(self):
|
||||
response = self.client.get('/test_admin/%s/admin_views/' % self.urlbit)
|
||||
self.assertNotContains(response, ' lang=""')
|
||||
self.assertNotContains(response, ' xml:lang=""')
|
||||
|
|
|
@ -71,61 +71,61 @@ class AdminFormfieldForDBFieldTests(TestCase):
|
|||
# Return the formfield so that other tests can continue
|
||||
return ff
|
||||
|
||||
def testDateField(self):
|
||||
def test_DateField(self):
|
||||
self.assertFormfield(models.Event, 'start_date', widgets.AdminDateWidget)
|
||||
|
||||
def testDateTimeField(self):
|
||||
def test_DateTimeField(self):
|
||||
self.assertFormfield(models.Member, 'birthdate', widgets.AdminSplitDateTime)
|
||||
|
||||
def testTimeField(self):
|
||||
def test_TimeField(self):
|
||||
self.assertFormfield(models.Event, 'start_time', widgets.AdminTimeWidget)
|
||||
|
||||
def testTextField(self):
|
||||
def test_TextField(self):
|
||||
self.assertFormfield(models.Event, 'description', widgets.AdminTextareaWidget)
|
||||
|
||||
def testURLField(self):
|
||||
def test_URLField(self):
|
||||
self.assertFormfield(models.Event, 'link', widgets.AdminURLFieldWidget)
|
||||
|
||||
def testIntegerField(self):
|
||||
def test_IntegerField(self):
|
||||
self.assertFormfield(models.Event, 'min_age', widgets.AdminIntegerFieldWidget)
|
||||
|
||||
def testCharField(self):
|
||||
def test_CharField(self):
|
||||
self.assertFormfield(models.Member, 'name', widgets.AdminTextInputWidget)
|
||||
|
||||
def testEmailField(self):
|
||||
def test_EmailField(self):
|
||||
self.assertFormfield(models.Member, 'email', widgets.AdminEmailInputWidget)
|
||||
|
||||
def testFileField(self):
|
||||
def test_FileField(self):
|
||||
self.assertFormfield(models.Album, 'cover_art', widgets.AdminFileWidget)
|
||||
|
||||
def testForeignKey(self):
|
||||
def test_ForeignKey(self):
|
||||
self.assertFormfield(models.Event, 'main_band', forms.Select)
|
||||
|
||||
def testRawIDForeignKey(self):
|
||||
def test_raw_id_ForeignKey(self):
|
||||
self.assertFormfield(models.Event, 'main_band', widgets.ForeignKeyRawIdWidget,
|
||||
raw_id_fields=['main_band'])
|
||||
|
||||
def testRadioFieldsForeignKey(self):
|
||||
def test_radio_fields_ForeignKey(self):
|
||||
ff = self.assertFormfield(models.Event, 'main_band', widgets.AdminRadioSelect,
|
||||
radio_fields={'main_band': admin.VERTICAL})
|
||||
self.assertEqual(ff.empty_label, None)
|
||||
|
||||
def testManyToMany(self):
|
||||
def test_many_to_many(self):
|
||||
self.assertFormfield(models.Band, 'members', forms.SelectMultiple)
|
||||
|
||||
def testRawIDManyTOMany(self):
|
||||
def test_raw_id_many_to_many(self):
|
||||
self.assertFormfield(models.Band, 'members', widgets.ManyToManyRawIdWidget,
|
||||
raw_id_fields=['members'])
|
||||
|
||||
def testFilteredManyToMany(self):
|
||||
def test_filtered_many_to_many(self):
|
||||
self.assertFormfield(models.Band, 'members', widgets.FilteredSelectMultiple,
|
||||
filter_vertical=['members'])
|
||||
|
||||
def testFormfieldOverrides(self):
|
||||
def test_formfield_overrides(self):
|
||||
self.assertFormfield(models.Event, 'start_date', forms.TextInput,
|
||||
formfield_overrides={DateField: {'widget': forms.TextInput}})
|
||||
|
||||
def testFormfieldOverridesWidgetInstances(self):
|
||||
def test_formfield_overrides_widget_instances(self):
|
||||
"""
|
||||
Test that widget instances in formfield_overrides are not shared between
|
||||
different fields. (#19423)
|
||||
|
@ -142,14 +142,14 @@ class AdminFormfieldForDBFieldTests(TestCase):
|
|||
self.assertEqual(f2.widget.attrs['maxlength'], '20')
|
||||
self.assertEqual(f2.widget.attrs['size'], '10')
|
||||
|
||||
def testFieldWithChoices(self):
|
||||
def test_field_with_choices(self):
|
||||
self.assertFormfield(models.Member, 'gender', forms.Select)
|
||||
|
||||
def testChoicesWithRadioFields(self):
|
||||
def test_choices_with_radio_fields(self):
|
||||
self.assertFormfield(models.Member, 'gender', widgets.AdminRadioSelect,
|
||||
radio_fields={'gender': admin.VERTICAL})
|
||||
|
||||
def testInheritance(self):
|
||||
def test_inheritance(self):
|
||||
self.assertFormfield(models.Album, 'backside_art', widgets.AdminFileWidget)
|
||||
|
||||
def test_m2m_widgets(self):
|
||||
|
@ -169,7 +169,7 @@ class AdminFormfieldForDBFieldWithRequestTests(DjangoTestCase):
|
|||
fixtures = ["admin-widgets-users.xml"]
|
||||
urls = 'admin_widgets.urls'
|
||||
|
||||
def testFilterChoicesByRequestUser(self):
|
||||
def test_filter_choices_by_request_user(self):
|
||||
"""
|
||||
Ensure the user can only see their own cars in the foreign key dropdown.
|
||||
"""
|
||||
|
@ -190,7 +190,7 @@ class AdminForeignKeyWidgetChangeList(DjangoTestCase):
|
|||
def tearDown(self):
|
||||
self.client.logout()
|
||||
|
||||
def test_changelist_foreignkey(self):
|
||||
def test_changelist_ForeignKey(self):
|
||||
response = self.client.get('/admin_widgets/car/')
|
||||
self.assertContains(response, '/auth/user/add/')
|
||||
|
||||
|
@ -959,7 +959,7 @@ class AdminRawIdWidgetSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
|||
models.Band.objects.create(id=98, name='Green Potatoes')
|
||||
super(AdminRawIdWidgetSeleniumFirefoxTests, self).setUp()
|
||||
|
||||
def test_foreignkey(self):
|
||||
def test_ForeignKey(self):
|
||||
self.admin_login(username='super', password='secret', login_url='/')
|
||||
self.selenium.get(
|
||||
'%s%s' % (self.live_server_url, '/admin_widgets/event/add/'))
|
||||
|
@ -1045,7 +1045,7 @@ class RelatedFieldWidgetSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
|||
urls = "admin_widgets.urls"
|
||||
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
|
||||
|
||||
def test_foreign_key_using_to_field(self):
|
||||
def test_ForeignKey_using_to_field(self):
|
||||
self.admin_login(username='super', password='secret', login_url='/')
|
||||
self.selenium.get('%s%s' % (
|
||||
self.live_server_url,
|
||||
|
|
|
@ -16,7 +16,7 @@ from .models import Photo, PhotoForm, temp_storage_dir
|
|||
|
||||
class Bug639Test(unittest.TestCase):
|
||||
|
||||
def testBug639(self):
|
||||
def test_bug_639(self):
|
||||
"""
|
||||
Simulate a file upload and check how many times Model.save() gets
|
||||
called.
|
||||
|
|
|
@ -31,11 +31,11 @@ class ConditionalGet(TestCase):
|
|||
self.assertEqual(response.status_code, 304)
|
||||
self.assertEqual(response.content, b'')
|
||||
|
||||
def testWithoutConditions(self):
|
||||
def test_without_conditions(self):
|
||||
response = self.client.get('/condition/')
|
||||
self.assertFullResponse(response)
|
||||
|
||||
def testIfModifiedSince(self):
|
||||
def test_if_modified_since(self):
|
||||
self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR
|
||||
response = self.client.get('/condition/')
|
||||
self.assertNotModified(response)
|
||||
|
@ -49,7 +49,7 @@ class ConditionalGet(TestCase):
|
|||
response = self.client.get('/condition/')
|
||||
self.assertFullResponse(response)
|
||||
|
||||
def testIfNoneMatch(self):
|
||||
def test_if_none_match(self):
|
||||
self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % ETAG
|
||||
response = self.client.get('/condition/')
|
||||
self.assertNotModified(response)
|
||||
|
@ -62,7 +62,7 @@ class ConditionalGet(TestCase):
|
|||
response = self.client.get('/condition/')
|
||||
self.assertNotModified(response)
|
||||
|
||||
def testIfMatch(self):
|
||||
def test_if_match(self):
|
||||
self.client.defaults['HTTP_IF_MATCH'] = '"%s"' % ETAG
|
||||
response = self.client.put('/condition/etag/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
@ -70,7 +70,7 @@ class ConditionalGet(TestCase):
|
|||
response = self.client.put('/condition/etag/')
|
||||
self.assertEqual(response.status_code, 412)
|
||||
|
||||
def testBothHeaders(self):
|
||||
def test_both_headers(self):
|
||||
self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR
|
||||
self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % ETAG
|
||||
response = self.client.get('/condition/')
|
||||
|
@ -86,45 +86,45 @@ class ConditionalGet(TestCase):
|
|||
response = self.client.get('/condition/')
|
||||
self.assertFullResponse(response)
|
||||
|
||||
def testSingleCondition1(self):
|
||||
def test_single_condition_1(self):
|
||||
self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR
|
||||
response = self.client.get('/condition/last_modified/')
|
||||
self.assertNotModified(response)
|
||||
response = self.client.get('/condition/etag/')
|
||||
self.assertFullResponse(response, check_last_modified=False)
|
||||
|
||||
def testSingleCondition2(self):
|
||||
def test_single_condition_2(self):
|
||||
self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % ETAG
|
||||
response = self.client.get('/condition/etag/')
|
||||
self.assertNotModified(response)
|
||||
response = self.client.get('/condition/last_modified/')
|
||||
self.assertFullResponse(response, check_etag=False)
|
||||
|
||||
def testSingleCondition3(self):
|
||||
def test_single_condition_3(self):
|
||||
self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = EXPIRED_LAST_MODIFIED_STR
|
||||
response = self.client.get('/condition/last_modified/')
|
||||
self.assertFullResponse(response, check_etag=False)
|
||||
|
||||
def testSingleCondition4(self):
|
||||
def test_single_condition_4(self):
|
||||
self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % EXPIRED_ETAG
|
||||
response = self.client.get('/condition/etag/')
|
||||
self.assertFullResponse(response, check_last_modified=False)
|
||||
|
||||
def testSingleCondition5(self):
|
||||
def test_single_condition_5(self):
|
||||
self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR
|
||||
response = self.client.get('/condition/last_modified2/')
|
||||
self.assertNotModified(response)
|
||||
response = self.client.get('/condition/etag2/')
|
||||
self.assertFullResponse(response, check_last_modified=False)
|
||||
|
||||
def testSingleCondition6(self):
|
||||
def test_single_condition_6(self):
|
||||
self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % ETAG
|
||||
response = self.client.get('/condition/etag2/')
|
||||
self.assertNotModified(response)
|
||||
response = self.client.get('/condition/last_modified2/')
|
||||
self.assertFullResponse(response, check_etag=False)
|
||||
|
||||
def testInvalidETag(self):
|
||||
def test_invalid_etag(self):
|
||||
self.client.defaults['HTTP_IF_NONE_MATCH'] = r'"\"'
|
||||
response = self.client.get('/condition/etag/')
|
||||
self.assertFullResponse(response, check_last_modified=False)
|
||||
|
|
|
@ -52,7 +52,7 @@ class DispatcherTests(unittest.TestCase):
|
|||
self.assertFalse(signal.has_listeners())
|
||||
self.assertEqual(signal.receivers, [])
|
||||
|
||||
def testExact(self):
|
||||
def test_exact(self):
|
||||
a_signal.connect(receiver_1_arg, sender=self)
|
||||
expected = [(receiver_1_arg, "test")]
|
||||
result = a_signal.send(sender=self, val="test")
|
||||
|
@ -60,7 +60,7 @@ class DispatcherTests(unittest.TestCase):
|
|||
a_signal.disconnect(receiver_1_arg, sender=self)
|
||||
self._testIsClean(a_signal)
|
||||
|
||||
def testIgnoredSender(self):
|
||||
def test_ignored_sender(self):
|
||||
a_signal.connect(receiver_1_arg)
|
||||
expected = [(receiver_1_arg, "test")]
|
||||
result = a_signal.send(sender=self, val="test")
|
||||
|
@ -68,7 +68,7 @@ class DispatcherTests(unittest.TestCase):
|
|||
a_signal.disconnect(receiver_1_arg)
|
||||
self._testIsClean(a_signal)
|
||||
|
||||
def testGarbageCollected(self):
|
||||
def test_garbage_collected(self):
|
||||
a = Callable()
|
||||
a_signal.connect(a.a, sender=self)
|
||||
expected = []
|
||||
|
@ -78,7 +78,7 @@ class DispatcherTests(unittest.TestCase):
|
|||
self.assertEqual(result, expected)
|
||||
self._testIsClean(a_signal)
|
||||
|
||||
def testCachedGarbagedCollected(self):
|
||||
def test_cached_garbaged_collected(self):
|
||||
"""
|
||||
Make sure signal caching sender receivers don't prevent garbage
|
||||
collection of senders.
|
||||
|
@ -96,7 +96,7 @@ class DispatcherTests(unittest.TestCase):
|
|||
# Disconnect after reference check since it flushes the tested cache.
|
||||
d_signal.disconnect(receiver_1_arg)
|
||||
|
||||
def testMultipleRegistration(self):
|
||||
def test_multiple_registration(self):
|
||||
a = Callable()
|
||||
a_signal.connect(a)
|
||||
a_signal.connect(a)
|
||||
|
@ -112,7 +112,7 @@ class DispatcherTests(unittest.TestCase):
|
|||
garbage_collect()
|
||||
self._testIsClean(a_signal)
|
||||
|
||||
def testUidRegistration(self):
|
||||
def test_uid_registration(self):
|
||||
def uid_based_receiver_1(**kwargs):
|
||||
pass
|
||||
|
||||
|
@ -125,7 +125,7 @@ class DispatcherTests(unittest.TestCase):
|
|||
a_signal.disconnect(dispatch_uid="uid")
|
||||
self._testIsClean(a_signal)
|
||||
|
||||
def testRobust(self):
|
||||
def test_robust(self):
|
||||
"""Test the sendRobust function"""
|
||||
def fails(val, **kwargs):
|
||||
raise ValueError('this')
|
||||
|
@ -137,7 +137,7 @@ class DispatcherTests(unittest.TestCase):
|
|||
a_signal.disconnect(fails)
|
||||
self._testIsClean(a_signal)
|
||||
|
||||
def testDisconnection(self):
|
||||
def test_disconnection(self):
|
||||
receiver_1 = Callable()
|
||||
receiver_2 = Callable()
|
||||
receiver_3 = Callable()
|
||||
|
@ -167,7 +167,7 @@ class ReceiverTestCase(unittest.TestCase):
|
|||
Test suite for receiver.
|
||||
|
||||
"""
|
||||
def testReceiverSingleSignal(self):
|
||||
def test_receiver_single_signal(self):
|
||||
@receiver(a_signal)
|
||||
def f(val, **kwargs):
|
||||
self.state = val
|
||||
|
@ -175,7 +175,7 @@ class ReceiverTestCase(unittest.TestCase):
|
|||
a_signal.send(sender=self, val=True)
|
||||
self.assertTrue(self.state)
|
||||
|
||||
def testReceiverSignalList(self):
|
||||
def test_receiver_signal_list(self):
|
||||
@receiver([a_signal, b_signal, c_signal])
|
||||
def f(val, **kwargs):
|
||||
self.state.append(val)
|
||||
|
|
|
@ -45,21 +45,21 @@ class GenericAdminViewTest(TestCase):
|
|||
def tearDown(self):
|
||||
self.client.logout()
|
||||
|
||||
def testBasicAddGet(self):
|
||||
def test_basic_add_GET(self):
|
||||
"""
|
||||
A smoke test to ensure GET on the add_view works.
|
||||
"""
|
||||
response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/episode/add/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def testBasicEditGet(self):
|
||||
def test_basic_edit_GET(self):
|
||||
"""
|
||||
A smoke test to ensure GET on the change_view works.
|
||||
"""
|
||||
response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/episode/%d/' % self.episode_pk)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def testBasicAddPost(self):
|
||||
def test_basic_add_POST(self):
|
||||
"""
|
||||
A smoke test to ensure POST on add_view works.
|
||||
"""
|
||||
|
@ -73,7 +73,7 @@ class GenericAdminViewTest(TestCase):
|
|||
response = self.client.post('/generic_inline_admin/admin/generic_inline_admin/episode/add/', post_data)
|
||||
self.assertEqual(response.status_code, 302) # redirect somewhere
|
||||
|
||||
def testBasicEditPost(self):
|
||||
def test_basic_edit_POST(self):
|
||||
"""
|
||||
A smoke test to ensure POST on edit_view works.
|
||||
"""
|
||||
|
@ -94,7 +94,7 @@ class GenericAdminViewTest(TestCase):
|
|||
response = self.client.post(url, post_data)
|
||||
self.assertEqual(response.status_code, 302) # redirect somewhere
|
||||
|
||||
def testGenericInlineFormset(self):
|
||||
def test_generic_inline_formset(self):
|
||||
EpisodeMediaFormSet = generic_inlineformset_factory(Media, can_delete=False, exclude=['description', 'keywords'], extra=3)
|
||||
e = Episode.objects.get(name='This Week in Django')
|
||||
|
||||
|
@ -118,7 +118,7 @@ class GenericAdminViewTest(TestCase):
|
|||
self.assertHTMLEqual(formset.forms[0].as_p(), '<p><label for="id_generic_inline_admin-media-content_type-object_id-0-url">Url:</label> <input id="id_generic_inline_admin-media-content_type-object_id-0-url" type="url" name="generic_inline_admin-media-content_type-object_id-0-url" value="http://example.com/logo.png" maxlength="200" /><input type="hidden" name="generic_inline_admin-media-content_type-object_id-0-id" value="%s" id="id_generic_inline_admin-media-content_type-object_id-0-id" /></p>' % self.png_media_pk)
|
||||
self.assertHTMLEqual(formset.forms[1].as_p(), '<p><label for="id_generic_inline_admin-media-content_type-object_id-1-url">Url:</label> <input id="id_generic_inline_admin-media-content_type-object_id-1-url" type="url" name="generic_inline_admin-media-content_type-object_id-1-url" maxlength="200" /><input type="hidden" name="generic_inline_admin-media-content_type-object_id-1-id" id="id_generic_inline_admin-media-content_type-object_id-1-id" /></p>')
|
||||
|
||||
def testGenericInlineFormsetFactory(self):
|
||||
def test_generic_inline_formset_factory(self):
|
||||
# Regression test for #10522.
|
||||
inline_formset = generic_inlineformset_factory(Media,
|
||||
exclude=('url',))
|
||||
|
@ -152,7 +152,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.
|
||||
"""
|
||||
|
@ -162,7 +162,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.
|
||||
"""
|
||||
|
@ -201,7 +201,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.
|
||||
"""
|
||||
|
@ -233,7 +233,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",
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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'),)
|
||||
|
|
Loading…
Reference in New Issue