mirror of
https://github.com/django/django.git
synced 2024-12-22 09:05:43 +00:00
Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings.
This commit is contained in:
parent
4bb70cbcc6
commit
321e94fa41
@ -53,6 +53,19 @@ Python style
|
||||
(``six.assertRaisesRegex()`` as long as we support Python 2) only if you need
|
||||
to use regular expression matching.
|
||||
|
||||
* In test docstrings, state the expected behavior that each test demonstrates.
|
||||
Don't include preambles such as "Tests that" or "Ensures that".
|
||||
|
||||
Reserve ticket references for obscure issues where the ticket has additional
|
||||
details that can't be easily described in docstrings or comments. Include the
|
||||
ticket number at the end of a sentence like this::
|
||||
|
||||
def test_foo():
|
||||
"""
|
||||
A test docstring looks like this (#123456).
|
||||
"""
|
||||
...
|
||||
|
||||
.. _coding-style-imports:
|
||||
|
||||
Imports
|
||||
|
@ -134,7 +134,7 @@ class ChangeListTests(TestCase):
|
||||
|
||||
def test_result_list_set_empty_value_display_on_admin_site(self):
|
||||
"""
|
||||
Test that empty value display can be set on AdminSite
|
||||
Empty value display can be set on AdminSite.
|
||||
"""
|
||||
new_child = Child.objects.create(name='name', parent=None)
|
||||
request = self.factory.get('/child/')
|
||||
@ -155,7 +155,7 @@ class ChangeListTests(TestCase):
|
||||
|
||||
def test_result_list_set_empty_value_display_in_model_admin(self):
|
||||
"""
|
||||
Test that empty value display can be set in ModelAdmin or individual fields.
|
||||
Empty value display can be set in ModelAdmin or individual fields.
|
||||
"""
|
||||
new_child = Child.objects.create(name='name', parent=None)
|
||||
request = self.factory.get('/child/')
|
||||
@ -174,8 +174,8 @@ class ChangeListTests(TestCase):
|
||||
|
||||
def test_result_list_html(self):
|
||||
"""
|
||||
Verifies that inclusion tag result_list generates a table when with
|
||||
default ModelAdmin settings.
|
||||
Inclusion tag result_list generates a table when with default
|
||||
ModelAdmin settings.
|
||||
"""
|
||||
new_parent = Parent.objects.create(name='parent')
|
||||
new_child = Child.objects.create(name='name', parent=new_parent)
|
||||
@ -672,10 +672,9 @@ class ChangeListTests(TestCase):
|
||||
|
||||
def test_deterministic_order_for_unordered_model(self):
|
||||
"""
|
||||
Ensure that the primary key is systematically used in the ordering of
|
||||
the changelist's results to guarantee a deterministic order, even
|
||||
when the Model doesn't have any default ordering defined.
|
||||
Refs #17198.
|
||||
The primary key is used in the ordering of the changelist's results to
|
||||
guarantee a deterministic order, even when the model doesn't have any
|
||||
default ordering defined (#17198).
|
||||
"""
|
||||
superuser = self._create_superuser('superuser')
|
||||
|
||||
@ -717,10 +716,9 @@ class ChangeListTests(TestCase):
|
||||
|
||||
def test_deterministic_order_for_model_ordered_by_its_manager(self):
|
||||
"""
|
||||
Ensure that the primary key is systematically used in the ordering of
|
||||
the changelist's results to guarantee a deterministic order, even
|
||||
when the Model has a manager that defines a default ordering.
|
||||
Refs #17198.
|
||||
The primary key is used in the ordering of the changelist's results to
|
||||
guarantee a deterministic order, even when the model has a manager that
|
||||
defines a default ordering (#17198).
|
||||
"""
|
||||
superuser = self._create_superuser('superuser')
|
||||
|
||||
@ -887,7 +885,7 @@ class SeleniumTests(AdminSeleniumTestCase):
|
||||
|
||||
def test_add_row_selection(self):
|
||||
"""
|
||||
Ensure that the status line for selected rows gets updated correctly (#22038)
|
||||
The status line for selected rows gets updated correctly (#22038).
|
||||
"""
|
||||
self.admin_login(username='super', password='secret')
|
||||
self.selenium.get(self.live_server_url + reverse('admin:auth_user_changelist'))
|
||||
|
@ -165,16 +165,15 @@ class SystemChecksTestCase(SimpleTestCase):
|
||||
|
||||
def test_custom_get_form_with_fieldsets(self):
|
||||
"""
|
||||
Ensure that the fieldsets checks are skipped when the ModelAdmin.get_form() method
|
||||
The fieldsets checks are skipped when the ModelAdmin.get_form() method
|
||||
is overridden.
|
||||
Refs #19445.
|
||||
"""
|
||||
errors = ValidFormFieldsets(Song, AdminSite()).check()
|
||||
self.assertEqual(errors, [])
|
||||
|
||||
def test_fieldsets_fields_non_tuple(self):
|
||||
"""
|
||||
Tests for a tuple/list for the first fieldset's fields.
|
||||
The first fieldset's fields must be a list/tuple.
|
||||
"""
|
||||
class NotATupleAdmin(admin.ModelAdmin):
|
||||
list_display = ["pk", "title"]
|
||||
@ -197,7 +196,7 @@ class SystemChecksTestCase(SimpleTestCase):
|
||||
|
||||
def test_nonfirst_fieldset(self):
|
||||
"""
|
||||
Tests for a tuple/list for the second fieldset's fields.
|
||||
The second fieldset's fields must be a list/tuple.
|
||||
"""
|
||||
class NotATupleAdmin(admin.ModelAdmin):
|
||||
fieldsets = [
|
||||
@ -309,7 +308,7 @@ class SystemChecksTestCase(SimpleTestCase):
|
||||
|
||||
def test_generic_inline_model_admin_non_generic_model(self):
|
||||
"""
|
||||
Ensure that a model without a GenericForeignKey raises problems if it's included
|
||||
A model without a GenericForeignKey raises problems if it's included
|
||||
in an GenericInlineModelAdmin definition.
|
||||
"""
|
||||
class BookInline(GenericStackedInline):
|
||||
|
@ -68,9 +68,6 @@ class AdminCustomUrlsTest(TestCase):
|
||||
self.assertContains(response, 'Action added through a popup')
|
||||
|
||||
def test_admin_URLs_no_clash(self):
|
||||
"""
|
||||
Test that some admin URLs work correctly.
|
||||
"""
|
||||
# Should get the change_view for model instance with PK 'add', not show
|
||||
# the add_view
|
||||
url = reverse('admin_custom_urls:%s_action_change' % Action._meta.app_label, args=(quote('add'),))
|
||||
@ -89,10 +86,8 @@ class AdminCustomUrlsTest(TestCase):
|
||||
|
||||
def test_post_save_add_redirect(self):
|
||||
"""
|
||||
Ensures that ModelAdmin.response_post_save_add() controls the
|
||||
redirection after the 'Save' button has been pressed when adding a
|
||||
new object.
|
||||
Refs 8001, 18310, 19505.
|
||||
ModelAdmin.response_post_save_add() controls the redirection after
|
||||
the 'Save' button has been pressed when adding a new object.
|
||||
"""
|
||||
post_data = {'name': 'John Doe'}
|
||||
self.assertEqual(Person.objects.count(), 0)
|
||||
@ -104,10 +99,8 @@ class AdminCustomUrlsTest(TestCase):
|
||||
|
||||
def test_post_save_change_redirect(self):
|
||||
"""
|
||||
Ensures that ModelAdmin.response_post_save_change() controls the
|
||||
redirection after the 'Save' button has been pressed when editing an
|
||||
existing object.
|
||||
Refs 8001, 18310, 19505.
|
||||
ModelAdmin.response_post_save_change() controls the redirection after
|
||||
the 'Save' button has been pressed when editing an existing object.
|
||||
"""
|
||||
Person.objects.create(name='John Doe')
|
||||
self.assertEqual(Person.objects.count(), 1)
|
||||
@ -118,8 +111,8 @@ class AdminCustomUrlsTest(TestCase):
|
||||
|
||||
def test_post_url_continue(self):
|
||||
"""
|
||||
Ensures that the ModelAdmin.response_add()'s parameter `post_url_continue`
|
||||
controls the redirection after an object has been created.
|
||||
The ModelAdmin.response_add()'s parameter `post_url_continue` controls
|
||||
the redirection after an object has been created.
|
||||
"""
|
||||
post_data = {'name': 'SuperFast', '_continue': '1'}
|
||||
self.assertEqual(Car.objects.count(), 0)
|
||||
|
@ -891,7 +891,7 @@ class ListFiltersTests(TestCase):
|
||||
|
||||
def test_filter_with_failing_queryset(self):
|
||||
"""
|
||||
Ensure that when a filter's queryset method fails, it fails loudly and
|
||||
When a filter's queryset method fails, it fails loudly and
|
||||
the corresponding exception doesn't get swallowed (#17828).
|
||||
"""
|
||||
modeladmin = DecadeFilterBookAdminWithFailingQueryset(Book, site)
|
||||
@ -941,8 +941,8 @@ class ListFiltersTests(TestCase):
|
||||
|
||||
def test_parameter_ends_with__in__or__isnull(self):
|
||||
"""
|
||||
Ensure that a SimpleListFilter's parameter name is not mistaken for a
|
||||
model field if it ends with '__isnull' or '__in' (#17091).
|
||||
A SimpleListFilter's parameter name is not mistaken for a model field
|
||||
if it ends with '__isnull' or '__in' (#17091).
|
||||
"""
|
||||
# When it ends with '__in' -----------------------------------------
|
||||
modeladmin = DecadeFilterBookAdminParameterEndsWith__In(Book, site)
|
||||
|
@ -107,8 +107,8 @@ class TestInline(TestDataMixin, TestCase):
|
||||
|
||||
def test_tabular_non_field_errors(self):
|
||||
"""
|
||||
Ensure that non_field_errors are displayed correctly, including the
|
||||
right value for colspan. Refs #13510.
|
||||
non_field_errors are displayed correctly, including the correct value
|
||||
for colspan.
|
||||
"""
|
||||
data = {
|
||||
'title_set-TOTAL_FORMS': 1,
|
||||
@ -153,9 +153,8 @@ class TestInline(TestDataMixin, TestCase):
|
||||
|
||||
def test_help_text(self):
|
||||
"""
|
||||
Ensure that the inlines' model field help texts are displayed when
|
||||
using both the stacked and tabular layouts.
|
||||
Ref #8190.
|
||||
The inlines' model field help texts are displayed when using both the
|
||||
stacked and tabular layouts.
|
||||
"""
|
||||
response = self.client.get(reverse('admin:admin_inlines_holder4_add'))
|
||||
self.assertContains(response, '<div class="help">Awesome stacked help text is awesome.</div>', 4)
|
||||
@ -191,8 +190,7 @@ class TestInline(TestDataMixin, TestCase):
|
||||
|
||||
def test_non_related_name_inline(self):
|
||||
"""
|
||||
Ensure that multiple inlines with related_name='+' have correct form
|
||||
prefixes. Bug #16838.
|
||||
Multiple inlines with related_name='+' have correct form prefixes.
|
||||
"""
|
||||
response = self.client.get(reverse('admin:admin_inlines_capofamiglia_add'))
|
||||
self.assertContains(response, '<input type="hidden" name="-1-0-id" id="id_-1-0-id" />', html=True)
|
||||
@ -221,8 +219,8 @@ class TestInline(TestDataMixin, TestCase):
|
||||
@override_settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True)
|
||||
def test_localize_pk_shortcut(self):
|
||||
"""
|
||||
Ensure that the "View on Site" link is correct for locales that use
|
||||
thousand separators
|
||||
The "View on Site" link is correct for locales that use thousand
|
||||
separators.
|
||||
"""
|
||||
holder = Holder.objects.create(pk=123456789, dummy=42)
|
||||
inner = Inner.objects.create(pk=987654321, holder=holder, dummy=42, readonly='')
|
||||
@ -232,8 +230,8 @@ class TestInline(TestDataMixin, TestCase):
|
||||
|
||||
def test_custom_pk_shortcut(self):
|
||||
"""
|
||||
Ensure that the "View on Site" link is correct for models with a
|
||||
custom primary key field. Bug #18433.
|
||||
The "View on Site" link is correct for models with a custom primary key
|
||||
field.
|
||||
"""
|
||||
parent = ParentModelWithCustomPk.objects.create(my_own_pk="foo", name="Foo")
|
||||
child1 = ChildModel1.objects.create(my_own_pk="bar", name="Bar", parent=parent)
|
||||
@ -246,8 +244,7 @@ class TestInline(TestDataMixin, TestCase):
|
||||
|
||||
def test_create_inlines_on_inherited_model(self):
|
||||
"""
|
||||
Ensure that an object can be created with inlines when it inherits
|
||||
another class. Bug #19524.
|
||||
An object can be created with inlines when it inherits another class.
|
||||
"""
|
||||
data = {
|
||||
'name': 'Martian',
|
||||
@ -285,7 +282,7 @@ class TestInline(TestDataMixin, TestCase):
|
||||
|
||||
def test_min_num(self):
|
||||
"""
|
||||
Ensure that min_num and extra determine number of forms.
|
||||
min_num and extra determine number of forms.
|
||||
"""
|
||||
class MinNumInline(TabularInline):
|
||||
model = BinaryTree
|
||||
@ -309,9 +306,6 @@ class TestInline(TestDataMixin, TestCase):
|
||||
self.assertContains(response, total_forms)
|
||||
|
||||
def test_custom_min_num(self):
|
||||
"""
|
||||
Ensure that get_min_num is called and used correctly.
|
||||
"""
|
||||
bt_head = BinaryTree.objects.create(name="Tree Head")
|
||||
BinaryTree.objects.create(name="First Child", parent=bt_head)
|
||||
|
||||
@ -741,8 +735,7 @@ class SeleniumTests(AdminSeleniumTestCase):
|
||||
|
||||
def test_add_stackeds(self):
|
||||
"""
|
||||
Ensure that the "Add another XXX" link correctly adds items to the
|
||||
stacked formset.
|
||||
The "Add another XXX" link correctly adds items to the stacked formset.
|
||||
"""
|
||||
self.admin_login(username='super', password='secret')
|
||||
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_holder4_add'))
|
||||
@ -781,14 +774,12 @@ class SeleniumTests(AdminSeleniumTestCase):
|
||||
|
||||
def test_add_inlines(self):
|
||||
"""
|
||||
Ensure that the "Add another XXX" link correctly adds items to the
|
||||
inline form.
|
||||
The "Add another XXX" link correctly adds items to the inline form.
|
||||
"""
|
||||
self.admin_login(username='super', password='secret')
|
||||
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_profilecollection_add'))
|
||||
|
||||
# Check that there's only one inline to start with and that it has the
|
||||
# correct ID.
|
||||
# There's only one inline to start with and it has the correct ID.
|
||||
self.assertEqual(len(self.selenium.find_elements_by_css_selector(
|
||||
'.dynamic-profile_set')), 1)
|
||||
self.assertEqual(self.selenium.find_elements_by_css_selector(
|
||||
@ -802,8 +793,8 @@ class SeleniumTests(AdminSeleniumTestCase):
|
||||
# Add an inline
|
||||
self.selenium.find_element_by_link_text('Add another Profile').click()
|
||||
|
||||
# Check that the inline has been added, that it has the right id, and
|
||||
# that it contains the right fields.
|
||||
# The inline has been added, it has the right id, and it contains the
|
||||
# correct fields.
|
||||
self.assertEqual(len(self.selenium.find_elements_by_css_selector('.dynamic-profile_set')), 2)
|
||||
self.assertEqual(self.selenium.find_elements_by_css_selector(
|
||||
'.dynamic-profile_set')[1].get_attribute('id'), 'profile_set-1')
|
||||
@ -833,7 +824,7 @@ class SeleniumTests(AdminSeleniumTestCase):
|
||||
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
||||
self.wait_page_loaded()
|
||||
|
||||
# Check that the objects have been created in the database
|
||||
# The objects have been created in the database
|
||||
self.assertEqual(ProfileCollection.objects.all().count(), 1)
|
||||
self.assertEqual(Profile.objects.all().count(), 3)
|
||||
|
||||
@ -864,7 +855,7 @@ class SeleniumTests(AdminSeleniumTestCase):
|
||||
'form#profilecollection_form tr.dynamic-profile_set#profile_set-1 td.delete a').click()
|
||||
self.selenium.find_element_by_css_selector(
|
||||
'form#profilecollection_form tr.dynamic-profile_set#profile_set-2 td.delete a').click()
|
||||
# Verify that they're gone and that the IDs have been re-sequenced
|
||||
# The rows are gone and the IDs have been re-sequenced
|
||||
self.assertEqual(len(self.selenium.find_elements_by_css_selector(
|
||||
'#profile_set-group table tr.dynamic-profile_set')), 3)
|
||||
self.assertEqual(len(self.selenium.find_elements_by_css_selector(
|
||||
|
@ -156,7 +156,7 @@ class TestRelatedFieldsAdminOrdering(TestCase):
|
||||
self.check_ordering_of_field_choices([self.b1, self.b2])
|
||||
|
||||
def test_custom_queryset_still_wins(self):
|
||||
"""Test that custom queryset has still precedence (#21405)"""
|
||||
"""Custom queryset has still precedence (#21405)"""
|
||||
class SongAdmin(admin.ModelAdmin):
|
||||
# Exclude one of the two Bands from the querysets
|
||||
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
||||
|
@ -1428,8 +1428,8 @@ class ManageTestserver(AdminScriptTestCase):
|
||||
|
||||
##########################################################################
|
||||
# COMMAND PROCESSING TESTS
|
||||
# Check that user-space commands are correctly handled - in particular,
|
||||
# that arguments to the commands are correctly parsed and processed.
|
||||
# user-space commands are correctly handled - in particular, arguments to
|
||||
# the commands are correctly parsed and processed.
|
||||
##########################################################################
|
||||
|
||||
class CommandTypes(AdminScriptTestCase):
|
||||
@ -1671,7 +1671,7 @@ class CommandTypes(AdminScriptTestCase):
|
||||
|
||||
def test_run_from_argv_non_ascii_error(self):
|
||||
"""
|
||||
Test that non-ASCII message of CommandError does not raise any
|
||||
Non-ASCII message of CommandError does not raise any
|
||||
UnicodeDecodeError in run_from_argv.
|
||||
"""
|
||||
def raise_command_error(*args, **kwargs):
|
||||
|
@ -72,7 +72,7 @@ class NestedObjectsTests(TestCase):
|
||||
|
||||
def test_on_delete_do_nothing(self):
|
||||
"""
|
||||
Check that the nested collector doesn't query for DO_NOTHING objects.
|
||||
The nested collector doesn't query for DO_NOTHING objects.
|
||||
"""
|
||||
n = NestedObjects(using=DEFAULT_DB_ALIAS)
|
||||
objs = [Event.objects.create()]
|
||||
@ -83,9 +83,9 @@ class NestedObjectsTests(TestCase):
|
||||
|
||||
def test_relation_on_abstract(self):
|
||||
"""
|
||||
#21846 -- Check that `NestedObjects.collect()` doesn't trip
|
||||
(AttributeError) on the special notation for relations on abstract
|
||||
models (related_name that contains %(app_label)s and/or %(class)s).
|
||||
NestedObjects.collect() doesn't trip (AttributeError) on the special
|
||||
notation for relations on abstract models (related_name that contains
|
||||
%(app_label)s and/or %(class)s) (#21846).
|
||||
"""
|
||||
n = NestedObjects(using=DEFAULT_DB_ALIAS)
|
||||
Car.objects.create()
|
||||
|
@ -108,7 +108,6 @@ class ArticleAdmin(admin.ModelAdmin):
|
||||
)
|
||||
|
||||
def changelist_view(self, request):
|
||||
"Test that extra_context works"
|
||||
return super(ArticleAdmin, self).changelist_view(
|
||||
request, extra_context={
|
||||
'extra_var': 'Hello!'
|
||||
@ -163,7 +162,6 @@ class CustomArticleAdmin(admin.ModelAdmin):
|
||||
delete_selected_confirmation_template = 'custom_admin/delete_selected_confirmation.html'
|
||||
|
||||
def changelist_view(self, request):
|
||||
"Test that extra_context works"
|
||||
return super(CustomArticleAdmin, self).changelist_view(
|
||||
request, extra_context={
|
||||
'extra_var': 'Hello!'
|
||||
|
@ -213,8 +213,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||
|
||||
def test_admin_static_template_tag(self):
|
||||
"""
|
||||
Test that admin_static.static is pointing to the collectstatic version
|
||||
(as django.contrib.collectstatic is in installed apps).
|
||||
admin_static.static points to the collectstatic version
|
||||
(as django.contrib.collectstatic is in INSTALLED_APPS).
|
||||
"""
|
||||
old_url = staticfiles_storage.base_url
|
||||
staticfiles_storage.base_url = '/test/'
|
||||
@ -486,8 +486,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||
self.assertContentBefore(response, link1, link2)
|
||||
|
||||
def test_multiple_sort_same_field(self):
|
||||
# Check that we get the columns we expect if we have two columns
|
||||
# that correspond to the same ordering field
|
||||
# The changelist displays the correct columns if two columns correspond
|
||||
# to the same ordering field.
|
||||
dt = datetime.datetime.now()
|
||||
p1 = Podcast.objects.create(name="A", release_date=dt)
|
||||
p2 = Podcast.objects.create(name="B", release_date=dt - datetime.timedelta(10))
|
||||
@ -517,9 +517,9 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||
|
||||
def test_sort_indicators_admin_order(self):
|
||||
"""
|
||||
Ensures that the admin shows default sort indicators for all
|
||||
kinds of 'ordering' fields: field names, method on the model
|
||||
admin and model itself, and other callables. See #17252.
|
||||
The admin shows default sort indicators for all kinds of 'ordering'
|
||||
fields: field names, method on the model admin and model itself, and
|
||||
other callables. See #17252.
|
||||
"""
|
||||
models = [(AdminOrderedField, 'adminorderedfield'),
|
||||
(AdminOrderedModelMethod, 'adminorderedmodelmethod'),
|
||||
@ -857,9 +857,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||
|
||||
def test_change_view_with_show_delete_extra_context(self):
|
||||
"""
|
||||
Ensured that the 'show_delete' context variable in the admin's change
|
||||
view actually controls the display of the delete button.
|
||||
Refs #10057.
|
||||
The 'show_delete' context variable in the admin's change view controls
|
||||
the display of the delete button.
|
||||
"""
|
||||
instance = UndeletableObject.objects.create(name='foo')
|
||||
response = self.client.get(reverse('admin:admin_views_undeletableobject_change', args=(instance.pk,)))
|
||||
@ -867,11 +866,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||
|
||||
def test_allows_attributeerror_to_bubble_up(self):
|
||||
"""
|
||||
Ensure that AttributeErrors are allowed to bubble when raised inside
|
||||
a change list view.
|
||||
|
||||
Requires a model to be created so there's something to be displayed
|
||||
|
||||
AttributeErrors are allowed to bubble when raised inside a change list
|
||||
view. Requires a model to be created so there's something to display.
|
||||
Refs: #16655, #18593, and #18747
|
||||
"""
|
||||
Simple.objects.create()
|
||||
@ -881,9 +877,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||
def test_changelist_with_no_change_url(self):
|
||||
"""
|
||||
ModelAdmin.changelist_view shouldn't result in a NoReverseMatch if url
|
||||
for change_view is removed from get_urls
|
||||
|
||||
Regression test for #20934
|
||||
for change_view is removed from get_urls (#20934).
|
||||
"""
|
||||
UnchangeableObject.objects.create()
|
||||
response = self.client.get(reverse('admin:admin_views_unchangeableobject_changelist'))
|
||||
@ -977,7 +971,7 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase):
|
||||
|
||||
def test_extended_bodyclass_template_change_form(self):
|
||||
"""
|
||||
Ensure that the admin/change_form.html template uses block.super in the
|
||||
The admin/change_form.html template uses block.super in the
|
||||
bodyclass block.
|
||||
"""
|
||||
response = self.client.get(reverse('admin:admin_views_section_add'))
|
||||
@ -997,15 +991,14 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase):
|
||||
|
||||
def test_extended_bodyclass_template_index(self):
|
||||
"""
|
||||
Ensure that the admin/index.html template uses block.super in the
|
||||
bodyclass block.
|
||||
The admin/index.html template uses block.super in the bodyclass block.
|
||||
"""
|
||||
response = self.client.get(reverse('admin:index'))
|
||||
self.assertContains(response, 'bodyclass_consistency_check ')
|
||||
|
||||
def test_extended_bodyclass_change_list(self):
|
||||
"""
|
||||
Ensure that the admin/change_list.html' template uses block.super
|
||||
The admin/change_list.html' template uses block.super
|
||||
in the bodyclass block.
|
||||
"""
|
||||
response = self.client.get(reverse('admin:admin_views_article_changelist'))
|
||||
@ -1013,7 +1006,7 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase):
|
||||
|
||||
def test_extended_bodyclass_template_login(self):
|
||||
"""
|
||||
Ensure that the admin/login.html template uses block.super in the
|
||||
The admin/login.html template uses block.super in the
|
||||
bodyclass block.
|
||||
"""
|
||||
self.client.logout()
|
||||
@ -1022,7 +1015,7 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase):
|
||||
|
||||
def test_extended_bodyclass_template_delete_confirmation(self):
|
||||
"""
|
||||
Ensure that the admin/delete_confirmation.html template uses
|
||||
The admin/delete_confirmation.html template uses
|
||||
block.super in the bodyclass block.
|
||||
"""
|
||||
group = Group.objects.create(name="foogroup")
|
||||
@ -1031,7 +1024,7 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase):
|
||||
|
||||
def test_extended_bodyclass_template_delete_selected_confirmation(self):
|
||||
"""
|
||||
Ensure that the admin/delete_selected_confirmation.html template uses
|
||||
The admin/delete_selected_confirmation.html template uses
|
||||
block.super in bodyclass block.
|
||||
"""
|
||||
group = Group.objects.create(name="foogroup")
|
||||
@ -1047,8 +1040,7 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase):
|
||||
|
||||
def test_filter_with_custom_template(self):
|
||||
"""
|
||||
Ensure that one can use a custom template to render an admin filter.
|
||||
Refs #17515.
|
||||
A custom template can be used to render an admin filter.
|
||||
"""
|
||||
response = self.client.get(reverse('admin:admin_views_color2_changelist'))
|
||||
self.assertTemplateUsed(response, 'custom_filter_template.html')
|
||||
@ -1078,7 +1070,7 @@ class AdminViewFormUrlTest(TestCase):
|
||||
|
||||
def test_change_form_URL_has_correct_value(self):
|
||||
"""
|
||||
Tests whether change_view has form_url in response.context
|
||||
change_view has form_url in response.context
|
||||
"""
|
||||
response = self.client.get(
|
||||
reverse('admin:admin_views_section_change', args=(self.s1.pk,), current_app=self.current_app)
|
||||
@ -1088,10 +1080,8 @@ class AdminViewFormUrlTest(TestCase):
|
||||
|
||||
def test_initial_data_can_be_overridden(self):
|
||||
"""
|
||||
Tests that the behavior for setting initial
|
||||
form data can be overridden in the ModelAdmin class.
|
||||
|
||||
Usually, the initial value is set via the GET params.
|
||||
The behavior for setting initial form data can be overridden in the
|
||||
ModelAdmin class. Usually, the initial value is set via the GET params.
|
||||
"""
|
||||
response = self.client.get(
|
||||
reverse('admin:admin_views_restaurant_add', current_app=self.current_app),
|
||||
@ -1115,9 +1105,7 @@ class AdminJavaScriptTest(TestCase):
|
||||
|
||||
def test_js_minified_only_if_debug_is_false(self):
|
||||
"""
|
||||
Ensure that the minified versions of the JS files are only used when
|
||||
DEBUG is False.
|
||||
Refs #17521.
|
||||
The minified versions of the JS files are only used when DEBUG is False.
|
||||
"""
|
||||
with override_settings(DEBUG=False):
|
||||
response = self.client.get(reverse('admin:admin_views_section_add'))
|
||||
@ -1157,7 +1145,7 @@ class SaveAsTests(TestCase):
|
||||
self.client.force_login(self.superuser)
|
||||
|
||||
def test_save_as_duplication(self):
|
||||
"""Ensure save as actually creates a new person"""
|
||||
"""'save as' creates a new person"""
|
||||
post_data = {'_saveasnew': '', 'name': 'John M', 'gender': 1, 'age': 42}
|
||||
response = self.client.post(reverse('admin:admin_views_person_change', args=(self.per1.pk,)), post_data)
|
||||
self.assertEqual(len(Person.objects.filter(name='John M')), 1)
|
||||
@ -1179,7 +1167,7 @@ class SaveAsTests(TestCase):
|
||||
|
||||
def test_save_as_new_with_validation_errors(self):
|
||||
"""
|
||||
Ensure that when you click "Save as new" and have a validation error,
|
||||
When you click "Save as new" and have a validation error,
|
||||
you only see the "Save as new" button and not the other save buttons,
|
||||
and that only the "Save as" button is visible.
|
||||
"""
|
||||
@ -1609,7 +1597,7 @@ class AdminViewPermissionsTest(TestCase):
|
||||
self.assertEqual(mail.outbox[0].subject, 'Greetings from a created object')
|
||||
self.client.get(reverse('admin:logout'))
|
||||
|
||||
# Check that the addition was logged correctly
|
||||
# The addition was logged correctly
|
||||
addition_log = LogEntry.objects.all()[0]
|
||||
new_article = Article.objects.last()
|
||||
article_ct = ContentType.objects.get_for_model(Article)
|
||||
@ -1968,7 +1956,7 @@ class AdminViewPermissionsTest(TestCase):
|
||||
|
||||
def test_has_module_permission(self):
|
||||
"""
|
||||
Ensure that has_module_permission() returns True for all users who
|
||||
has_module_permission() returns True for all users who
|
||||
have any permission for that module (add, change, or delete), so that
|
||||
the module is displayed on the admin index page.
|
||||
"""
|
||||
@ -1997,9 +1985,8 @@ class AdminViewPermissionsTest(TestCase):
|
||||
|
||||
def test_overriding_has_module_permission(self):
|
||||
"""
|
||||
Ensure that overriding has_module_permission() has the desired effect.
|
||||
In this case, it always returns False, so the module should not be
|
||||
displayed on the admin index page for any users.
|
||||
If has_module_permission() always returns False, the module shouldn't
|
||||
be displayed on the admin index page for any users.
|
||||
"""
|
||||
articles = Article._meta.verbose_name_plural.title()
|
||||
sections = Section._meta.verbose_name_plural.title()
|
||||
@ -2438,9 +2425,6 @@ class SecureViewTests(TestCase):
|
||||
"""
|
||||
|
||||
def test_secure_view_shows_login_if_not_logged_in(self):
|
||||
"""
|
||||
Ensure that we see the admin login form.
|
||||
"""
|
||||
secure_url = reverse('secure_view')
|
||||
response = self.client.get(secure_url)
|
||||
self.assertRedirects(response, '%s?next=%s' % (reverse('admin:login'), secure_url))
|
||||
@ -2450,7 +2434,7 @@ class SecureViewTests(TestCase):
|
||||
|
||||
def test_staff_member_required_decorator_works_with_argument(self):
|
||||
"""
|
||||
Ensure that staff_member_required decorator works with an argument
|
||||
Staff_member_required decorator works with an argument
|
||||
(redirect_field_name).
|
||||
"""
|
||||
secure_url = '/test_admin/admin/secure-view2/'
|
||||
@ -2518,7 +2502,7 @@ class AdminViewUnicodeTest(TestCase):
|
||||
|
||||
def test_unicode_delete(self):
|
||||
"""
|
||||
Ensure that the delete_view handles non-ASCII characters
|
||||
The delete_view handles non-ASCII characters
|
||||
"""
|
||||
delete_dict = {'post': 'yes'}
|
||||
delete_url = reverse('admin:admin_views_book_delete', args=(self.b1.pk,))
|
||||
@ -2664,9 +2648,10 @@ class AdminViewListEditable(TestCase):
|
||||
self.assertIs(Person.objects.get(name="John Mauchly").alive, False)
|
||||
|
||||
def test_non_field_errors(self):
|
||||
''' Ensure that non field errors are displayed for each of the
|
||||
forms in the changelist's formset. Refs #13126.
|
||||
'''
|
||||
"""
|
||||
Non-field errors are displayed for each of the forms in the
|
||||
changelist's formset.
|
||||
"""
|
||||
fd1 = FoodDelivery.objects.create(reference='123', driver='bill', restaurant='thai')
|
||||
fd2 = FoodDelivery.objects.create(reference='456', driver='bill', restaurant='india')
|
||||
fd3 = FoodDelivery.objects.create(reference='789', driver='bill', restaurant='pizza')
|
||||
@ -2747,7 +2732,7 @@ class AdminViewListEditable(TestCase):
|
||||
"form-0-alive": "1",
|
||||
"form-0-gender": "2",
|
||||
|
||||
# Ensure that the form processing understands this as a list_editable "Save"
|
||||
# The form processing understands this as a list_editable "Save"
|
||||
# and not an action "Go".
|
||||
"_save": "Save",
|
||||
}
|
||||
@ -2802,7 +2787,7 @@ class AdminViewListEditable(TestCase):
|
||||
"form-3-id": "4",
|
||||
"form-3-collector": "1",
|
||||
|
||||
# Ensure that the form processing understands this as a list_editable "Save"
|
||||
# The form processing understands this as a list_editable "Save"
|
||||
# and not an action "Go".
|
||||
"_save": "Save",
|
||||
}
|
||||
@ -2810,7 +2795,7 @@ class AdminViewListEditable(TestCase):
|
||||
# Successful post will redirect
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# Check that the order values have been applied to the right objects
|
||||
# The order values have been applied to the right objects
|
||||
self.assertEqual(Category.objects.get(id=1).order, 14)
|
||||
self.assertEqual(Category.objects.get(id=2).order, 13)
|
||||
self.assertEqual(Category.objects.get(id=3).order, 1)
|
||||
@ -2818,8 +2803,7 @@ class AdminViewListEditable(TestCase):
|
||||
|
||||
def test_list_editable_pagination(self):
|
||||
"""
|
||||
Ensure that pagination works for list_editable items.
|
||||
Refs #16819.
|
||||
Pagination works for list_editable items.
|
||||
"""
|
||||
UnorderedObject.objects.create(id=1, name='Unordered object #1')
|
||||
UnorderedObject.objects.create(id=2, name='Unordered object #2')
|
||||
@ -2897,11 +2881,10 @@ class AdminViewListEditable(TestCase):
|
||||
self.assertEqual(response.context['cl'].list_editable, ())
|
||||
|
||||
def test_pk_hidden_fields(self):
|
||||
""" Ensure that hidden pk fields aren't displayed in the table body and
|
||||
that their corresponding human-readable value is displayed instead.
|
||||
Note that the hidden pk fields are in fact be displayed but
|
||||
separately (not in the table), and only once.
|
||||
Refs #12475.
|
||||
"""
|
||||
hidden pk fields aren't displayed in the table body and their
|
||||
corresponding human-readable value is displayed instead. The hidden pk
|
||||
fields are displayed but separately (not in the table) and only once.
|
||||
"""
|
||||
story1 = Story.objects.create(title='The adventures of Guido', content='Once upon a time in Djangoland...')
|
||||
story2 = Story.objects.create(
|
||||
@ -2991,15 +2974,15 @@ class AdminSearchTest(TestCase):
|
||||
self.client.force_login(self.superuser)
|
||||
|
||||
def test_search_on_sibling_models(self):
|
||||
"Check that a search that mentions sibling models"
|
||||
"A search that mentions sibling models"
|
||||
response = self.client.get(reverse('admin:admin_views_recommendation_changelist') + '?q=bar')
|
||||
# confirm the search returned 1 object
|
||||
self.assertContains(response, "\n1 recommendation\n")
|
||||
|
||||
def test_with_fk_to_field(self):
|
||||
"""
|
||||
Ensure that the to_field GET parameter is preserved when a search
|
||||
is performed. Refs #10918.
|
||||
The to_field GET parameter is preserved when a search is performed.
|
||||
Refs #10918.
|
||||
"""
|
||||
response = self.client.get(reverse('admin:auth_user_changelist') + '?q=joe&%s=id' % TO_FIELD_VAR)
|
||||
self.assertContains(response, "\n1 user\n")
|
||||
@ -3082,7 +3065,9 @@ class AdminInheritedInlinesTest(TestCase):
|
||||
self.client.force_login(self.superuser)
|
||||
|
||||
def test_inline(self):
|
||||
"Ensure that inline models which inherit from a common parent are correctly handled by admin."
|
||||
"""
|
||||
Inline models which inherit from a common parent are correctly handled.
|
||||
"""
|
||||
foo_user = "foo username"
|
||||
bar_user = "bar username"
|
||||
|
||||
@ -3300,8 +3285,8 @@ class AdminActionsTest(TestCase):
|
||||
|
||||
def test_default_redirect(self):
|
||||
"""
|
||||
Test that actions which don't return an HttpResponse are redirected to
|
||||
the same page, retaining the querystring (which may contain changelist
|
||||
Actions which don't return an HttpResponse are redirected to the same
|
||||
page, retaining the querystring (which may contain changelist
|
||||
information).
|
||||
"""
|
||||
action_data = {
|
||||
@ -3338,8 +3323,7 @@ class AdminActionsTest(TestCase):
|
||||
|
||||
def test_actions_ordering(self):
|
||||
"""
|
||||
Ensure that actions are ordered as expected.
|
||||
Refs #15964.
|
||||
Actions are ordered as expected.
|
||||
"""
|
||||
response = self.client.get(reverse('admin:admin_views_externalsubscriber_changelist'))
|
||||
self.assertContains(response, '''<label>Action: <select name="action" required>
|
||||
@ -3364,7 +3348,7 @@ action)</option>
|
||||
self.assertNotContains(response, '<input type="checkbox" class="action-select"')
|
||||
|
||||
def test_model_without_action_still_has_jquery(self):
|
||||
"Tests that a ModelAdmin without any actions still gets jQuery included in page"
|
||||
"A ModelAdmin without any actions still gets jQuery included in page"
|
||||
response = self.client.get(reverse('admin:admin_views_oldsubscriber_changelist'))
|
||||
self.assertIsNone(response.context["action_form"])
|
||||
self.assertContains(
|
||||
@ -3373,14 +3357,14 @@ action)</option>
|
||||
)
|
||||
|
||||
def test_action_column_class(self):
|
||||
"Tests that the checkbox column class is present in the response"
|
||||
"The checkbox column class is present in the response"
|
||||
response = self.client.get(reverse('admin:admin_views_subscriber_changelist'))
|
||||
self.assertIsNotNone(response.context["action_form"])
|
||||
self.assertContains(response, 'action-checkbox-column')
|
||||
|
||||
def test_multiple_actions_form(self):
|
||||
"""
|
||||
Test that actions come from the form whose submit button was pressed (#10618).
|
||||
Actions come from the form whose submit button was pressed (#10618).
|
||||
"""
|
||||
action_data = {
|
||||
ACTION_CHECKBOX_NAME: [1],
|
||||
@ -3501,7 +3485,7 @@ class TestCustomChangeList(TestCase):
|
||||
self.assertEqual(response.status_code, 302) # redirect somewhere
|
||||
# Hit the page once to get messages out of the queue message list
|
||||
response = self.client.get(reverse('admin:admin_views_gadget_changelist'))
|
||||
# Ensure that data is still not visible on the page
|
||||
# Data is still not visible on the page
|
||||
response = self.client.get(reverse('admin:admin_views_gadget_changelist'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertNotContains(response, 'First Gadget')
|
||||
@ -3765,8 +3749,7 @@ class AdminCustomQuerysetTest(TestCase):
|
||||
|
||||
def test_history_view_custom_qs(self):
|
||||
"""
|
||||
Ensure that custom querysets are considered for the admin history view.
|
||||
Refs #21013.
|
||||
Custom querysets are considered for the admin history view.
|
||||
"""
|
||||
self.client.post(reverse('admin:login'), self.super_login)
|
||||
FilteredManager.objects.create(pk=1)
|
||||
@ -3806,7 +3789,7 @@ class AdminInlineFileUploadTest(TestCase):
|
||||
|
||||
def test_inline_file_upload_edit_validation_error_post(self):
|
||||
"""
|
||||
Test that inline file uploads correctly display prior data (#10002).
|
||||
Inline file uploads correctly display prior data (#10002).
|
||||
"""
|
||||
post_data = {
|
||||
"name": "Test Gallery",
|
||||
@ -3936,7 +3919,7 @@ class AdminInlineTests(TestCase):
|
||||
self.assertEqual(Widget.objects.all()[0].name, "Widget 1")
|
||||
widget_id = Widget.objects.all()[0].id
|
||||
|
||||
# Check that the PK link exists on the rendered form
|
||||
# The PK link exists on the rendered form
|
||||
response = self.client.get(collector_url)
|
||||
self.assertContains(response, 'name="widget_set-0-id"')
|
||||
|
||||
@ -3968,7 +3951,7 @@ class AdminInlineTests(TestCase):
|
||||
self.assertEqual(Grommet.objects.count(), 1)
|
||||
self.assertEqual(Grommet.objects.all()[0].name, "Grommet 1")
|
||||
|
||||
# Check that the PK link exists on the rendered form
|
||||
# The PK link exists on the rendered form
|
||||
response = self.client.get(collector_url)
|
||||
self.assertContains(response, 'name="grommet_set-0-code"')
|
||||
|
||||
@ -4001,7 +3984,7 @@ class AdminInlineTests(TestCase):
|
||||
self.assertEqual(DooHickey.objects.count(), 1)
|
||||
self.assertEqual(DooHickey.objects.all()[0].name, "Doohickey 1")
|
||||
|
||||
# Check that the PK link exists on the rendered form
|
||||
# The PK link exists on the rendered form
|
||||
response = self.client.get(collector_url)
|
||||
self.assertContains(response, 'name="doohickey_set-0-code"')
|
||||
|
||||
@ -4034,7 +4017,7 @@ class AdminInlineTests(TestCase):
|
||||
self.assertEqual(Whatsit.objects.count(), 1)
|
||||
self.assertEqual(Whatsit.objects.all()[0].name, "Whatsit 1")
|
||||
|
||||
# Check that the PK link exists on the rendered form
|
||||
# The PK link exists on the rendered form
|
||||
response = self.client.get(collector_url)
|
||||
self.assertContains(response, 'name="whatsit_set-0-index"')
|
||||
|
||||
@ -4067,7 +4050,7 @@ class AdminInlineTests(TestCase):
|
||||
self.assertEqual(FancyDoodad.objects.all()[0].name, "Fancy Doodad 1")
|
||||
doodad_pk = FancyDoodad.objects.all()[0].pk
|
||||
|
||||
# Check that the PK link exists on the rendered form
|
||||
# The PK link exists on the rendered form
|
||||
response = self.client.get(collector_url)
|
||||
self.assertContains(response, 'name="fancydoodad_set-0-doodad_ptr"')
|
||||
|
||||
@ -4090,8 +4073,9 @@ class AdminInlineTests(TestCase):
|
||||
self.assertEqual(FancyDoodad.objects.all()[0].name, "Fancy Doodad 1 Updated")
|
||||
|
||||
def test_ordered_inline(self):
|
||||
"""Check that an inline with an editable ordering fields is
|
||||
updated correctly. Regression for #10922"""
|
||||
"""
|
||||
An inline with an editable ordering fields is updated correctly.
|
||||
"""
|
||||
# Create some objects with an initial ordering
|
||||
Category.objects.create(id=1, order=1, collector=self.collector)
|
||||
Category.objects.create(id=2, order=2, collector=self.collector)
|
||||
@ -4139,7 +4123,7 @@ class AdminInlineTests(TestCase):
|
||||
# Successful post will redirect
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# Check that the order values have been applied to the right objects
|
||||
# The order values have been applied to the right objects
|
||||
self.assertEqual(self.collector.category_set.count(), 4)
|
||||
self.assertEqual(Category.objects.get(id=1).order, 14)
|
||||
self.assertEqual(Category.objects.get(id=2).order, 13)
|
||||
@ -4269,8 +4253,8 @@ class SeleniumTests(AdminSeleniumTestCase):
|
||||
|
||||
def test_prepopulated_fields(self):
|
||||
"""
|
||||
Ensure that the JavaScript-automated prepopulated fields work with the
|
||||
main form and with stacked and tabular inlines.
|
||||
The JavaScript-automated prepopulated fields work with the main form
|
||||
and with stacked and tabular inlines.
|
||||
Refs #13068, #9264, #9983, #9784.
|
||||
"""
|
||||
self.admin_login(username='super', password='secret', login_url=reverse('admin:index'))
|
||||
@ -4382,9 +4366,8 @@ class SeleniumTests(AdminSeleniumTestCase):
|
||||
|
||||
def test_populate_existing_object(self):
|
||||
"""
|
||||
Ensure that the prepopulation works for existing objects too, as long
|
||||
as the original field is empty.
|
||||
Refs #19082.
|
||||
The prepopulation works for existing objects too, as long as
|
||||
the original field is empty (#19082).
|
||||
"""
|
||||
# Slugs are empty to start with.
|
||||
item = MainPrepopulated.objects.create(
|
||||
@ -4422,7 +4405,7 @@ class SeleniumTests(AdminSeleniumTestCase):
|
||||
|
||||
def test_collapsible_fieldset(self):
|
||||
"""
|
||||
Test that the 'collapse' class in fieldsets definition allows to
|
||||
The 'collapse' class in fieldsets definition allows to
|
||||
show/hide the appropriate field section.
|
||||
"""
|
||||
self.admin_login(username='super', password='secret', login_url=reverse('admin:index'))
|
||||
@ -4614,7 +4597,7 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase):
|
||||
self.assertContains(response, "Unknown coolness.")
|
||||
self.assertContains(response, "foo")
|
||||
|
||||
# Checks that multiline text in a readonly field gets <br /> tags
|
||||
# Multiline text in a readonly field gets <br /> tags
|
||||
self.assertContains(response, "Multiline<br />test<br />string")
|
||||
self.assertContains(response, "<p>Multiline<br />html<br />content</p>", html=True)
|
||||
self.assertContains(response, "InlineMultiline<br />test<br />string")
|
||||
@ -5093,8 +5076,7 @@ class CSSTest(TestCase):
|
||||
@ignore_warnings(category=RemovedInDjango20Warning) # for allow_tags deprecation
|
||||
def test_field_prefix_css_classes(self):
|
||||
"""
|
||||
Ensure that fields have a CSS class name with a 'field-' prefix.
|
||||
Refs #16371.
|
||||
Fields have a CSS class name with a 'field-' prefix.
|
||||
"""
|
||||
response = self.client.get(reverse('admin:admin_views_post_add'))
|
||||
|
||||
@ -5113,9 +5095,8 @@ class CSSTest(TestCase):
|
||||
|
||||
def test_index_css_classes(self):
|
||||
"""
|
||||
Ensure that CSS class names are used for each app and model on the
|
||||
admin index pages.
|
||||
Refs #17050.
|
||||
CSS class names are used for each app and model on the admin index
|
||||
pages (#17050).
|
||||
"""
|
||||
# General index page
|
||||
response = self.client.get(reverse('admin:index'))
|
||||
@ -5278,8 +5259,8 @@ class DateHierarchyTests(TestCase):
|
||||
formats.reset_format_cache()
|
||||
|
||||
def assert_non_localized_year(self, response, year):
|
||||
"""Ensure that the year is not localized with
|
||||
USE_THOUSAND_SEPARATOR. Refs #15234.
|
||||
"""
|
||||
The year is not localized with USE_THOUSAND_SEPARATOR (#15234).
|
||||
"""
|
||||
self.assertNotContains(response, formats.number_format(year))
|
||||
|
||||
@ -5299,7 +5280,7 @@ class DateHierarchyTests(TestCase):
|
||||
|
||||
def test_empty(self):
|
||||
"""
|
||||
Ensure that no date hierarchy links display with empty changelist.
|
||||
No date hierarchy links display with empty changelist.
|
||||
"""
|
||||
response = self.client.get(
|
||||
reverse('admin:admin_views_podcast_changelist'))
|
||||
@ -5309,7 +5290,7 @@ class DateHierarchyTests(TestCase):
|
||||
|
||||
def test_single(self):
|
||||
"""
|
||||
Ensure that single day-level date hierarchy appears for single object.
|
||||
Single day-level date hierarchy appears for single object.
|
||||
"""
|
||||
DATE = datetime.date(2000, 6, 30)
|
||||
Podcast.objects.create(release_date=DATE)
|
||||
@ -5320,7 +5301,7 @@ class DateHierarchyTests(TestCase):
|
||||
|
||||
def test_within_month(self):
|
||||
"""
|
||||
Ensure that day-level links appear for changelist within single month.
|
||||
day-level links appear for changelist within single month.
|
||||
"""
|
||||
DATES = (datetime.date(2000, 6, 30),
|
||||
datetime.date(2000, 6, 15),
|
||||
@ -5335,7 +5316,7 @@ class DateHierarchyTests(TestCase):
|
||||
|
||||
def test_within_year(self):
|
||||
"""
|
||||
Ensure that month-level links appear for changelist within single year.
|
||||
month-level links appear for changelist within single year.
|
||||
"""
|
||||
DATES = (datetime.date(2000, 1, 30),
|
||||
datetime.date(2000, 3, 15),
|
||||
@ -5352,7 +5333,7 @@ class DateHierarchyTests(TestCase):
|
||||
|
||||
def test_multiple_years(self):
|
||||
"""
|
||||
Ensure that year-level links appear for year-spanning changelist.
|
||||
year-level links appear for year-spanning changelist.
|
||||
"""
|
||||
DATES = (datetime.date(2001, 1, 30),
|
||||
datetime.date(2003, 3, 15),
|
||||
@ -5411,7 +5392,7 @@ class DateHierarchyTests(TestCase):
|
||||
@override_settings(ROOT_URLCONF='admin_views.urls')
|
||||
class AdminCustomSaveRelatedTests(TestCase):
|
||||
"""
|
||||
Ensure that one can easily customize the way related objects are saved.
|
||||
One can easily customize the way related objects are saved.
|
||||
Refs #16115.
|
||||
"""
|
||||
|
||||
@ -5985,7 +5966,7 @@ class AdminViewOnSiteTests(TestCase):
|
||||
)
|
||||
|
||||
def test_check(self):
|
||||
"Ensure that the view_on_site value is either a boolean or a callable"
|
||||
"The view_on_site value is either a boolean or a callable"
|
||||
try:
|
||||
admin = CityAdmin(City, AdminSite())
|
||||
CityAdmin.view_on_site = True
|
||||
@ -6007,24 +5988,24 @@ class AdminViewOnSiteTests(TestCase):
|
||||
CityAdmin.view_on_site = True
|
||||
|
||||
def test_false(self):
|
||||
"Ensure that the 'View on site' button is not displayed if view_on_site is False"
|
||||
"The 'View on site' button is not displayed if view_on_site is False"
|
||||
response = self.client.get(reverse('admin:admin_views_restaurant_change', args=(self.r1.pk,)))
|
||||
content_type_pk = ContentType.objects.get_for_model(Restaurant).pk
|
||||
self.assertNotContains(response, reverse('admin:view_on_site', args=(content_type_pk, 1)))
|
||||
|
||||
def test_true(self):
|
||||
"Ensure that the default behavior is followed if view_on_site is True"
|
||||
"The default behavior is followed if view_on_site is True"
|
||||
response = self.client.get(reverse('admin:admin_views_city_change', args=(self.c1.pk,)))
|
||||
content_type_pk = ContentType.objects.get_for_model(City).pk
|
||||
self.assertContains(response, reverse('admin:view_on_site', args=(content_type_pk, self.c1.pk)))
|
||||
|
||||
def test_callable(self):
|
||||
"Ensure that the right link is displayed if view_on_site is a callable"
|
||||
"The right link is displayed if view_on_site is a callable"
|
||||
response = self.client.get(reverse('admin:admin_views_worker_change', args=(self.w1.pk,)))
|
||||
self.assertContains(response, '"/worker/%s/%s/"' % (self.w1.surname, self.w1.name))
|
||||
|
||||
def test_missing_get_absolute_url(self):
|
||||
"Ensure None is returned if model doesn't have get_absolute_url"
|
||||
"None is returned if model doesn't have get_absolute_url"
|
||||
model_admin = ModelAdmin(Worker, None)
|
||||
self.assertIsNone(model_admin.get_view_on_site_url(Worker()))
|
||||
|
||||
@ -6056,26 +6037,26 @@ class InlineAdminViewOnSiteTest(TestCase):
|
||||
self.client.force_login(self.superuser)
|
||||
|
||||
def test_false(self):
|
||||
"Ensure that the 'View on site' button is not displayed if view_on_site is False"
|
||||
"The 'View on site' button is not displayed if view_on_site is False"
|
||||
response = self.client.get(reverse('admin:admin_views_state_change', args=(self.s1.pk,)))
|
||||
content_type_pk = ContentType.objects.get_for_model(City).pk
|
||||
self.assertNotContains(response, reverse('admin:view_on_site', args=(content_type_pk, self.c1.pk)))
|
||||
|
||||
def test_true(self):
|
||||
"Ensure that the 'View on site' button is displayed if view_on_site is True"
|
||||
"The 'View on site' button is displayed if view_on_site is True"
|
||||
response = self.client.get(reverse('admin:admin_views_city_change', args=(self.c1.pk,)))
|
||||
content_type_pk = ContentType.objects.get_for_model(Restaurant).pk
|
||||
self.assertContains(response, reverse('admin:view_on_site', args=(content_type_pk, self.r1.pk)))
|
||||
|
||||
def test_callable(self):
|
||||
"Ensure that the right link is displayed if view_on_site is a callable"
|
||||
"The right link is displayed if view_on_site is a callable"
|
||||
response = self.client.get(reverse('admin:admin_views_restaurant_change', args=(self.r1.pk,)))
|
||||
self.assertContains(response, '"/worker_inline/%s/%s/"' % (self.w1.surname, self.w1.name))
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF='admin_views.urls')
|
||||
class TestETagWithAdminView(SimpleTestCase):
|
||||
# See https://code.djangoproject.com/ticket/16003
|
||||
# The admin is compatible with ETags (#16003).
|
||||
|
||||
def test_admin(self):
|
||||
with self.settings(USE_ETAGS=False):
|
||||
|
@ -61,16 +61,7 @@ class AdminFormfieldForDBFieldTests(SimpleTestCase):
|
||||
else:
|
||||
widget = ff.widget
|
||||
|
||||
# Check that we got a field of the right type
|
||||
self.assertTrue(
|
||||
isinstance(widget, widgetclass),
|
||||
"Wrong widget for %s.%s: expected %s, got %s" % (
|
||||
model.__class__.__name__,
|
||||
fieldname,
|
||||
widgetclass,
|
||||
type(widget),
|
||||
)
|
||||
)
|
||||
self.assertIsInstance(widget, widgetclass)
|
||||
|
||||
# Return the formfield so that other tests can continue
|
||||
return ff
|
||||
@ -131,7 +122,7 @@ class AdminFormfieldForDBFieldTests(SimpleTestCase):
|
||||
|
||||
def test_formfield_overrides_widget_instances(self):
|
||||
"""
|
||||
Test that widget instances in formfield_overrides are not shared between
|
||||
Widget instances in formfield_overrides are not shared between
|
||||
different fields. (#19423)
|
||||
"""
|
||||
class BandAdmin(admin.ModelAdmin):
|
||||
@ -279,10 +270,6 @@ class FilteredSelectMultipleWidgetTest(SimpleTestCase):
|
||||
|
||||
class AdminDateWidgetTest(SimpleTestCase):
|
||||
def test_attrs(self):
|
||||
"""
|
||||
Ensure that user-supplied attrs are used.
|
||||
Refs #12073.
|
||||
"""
|
||||
w = widgets.AdminDateWidget()
|
||||
self.assertHTMLEqual(
|
||||
w.render('test', datetime(2007, 12, 1, 9, 30)),
|
||||
@ -298,10 +285,6 @@ class AdminDateWidgetTest(SimpleTestCase):
|
||||
|
||||
class AdminTimeWidgetTest(SimpleTestCase):
|
||||
def test_attrs(self):
|
||||
"""
|
||||
Ensure that user-supplied attrs are used.
|
||||
Refs #12073.
|
||||
"""
|
||||
w = widgets.AdminTimeWidget()
|
||||
self.assertHTMLEqual(
|
||||
w.render('test', datetime(2007, 12, 1, 9, 30)),
|
||||
@ -475,8 +458,8 @@ class ForeignKeyRawIdWidgetTest(TestCase):
|
||||
)
|
||||
|
||||
def test_relations_to_non_primary_key(self):
|
||||
# Check that ForeignKeyRawIdWidget works with fields which aren't
|
||||
# related to the model's primary key.
|
||||
# ForeignKeyRawIdWidget works with fields which aren't related to
|
||||
# the model's primary key.
|
||||
apple = models.Inventory.objects.create(barcode=86, name='Apple')
|
||||
models.Inventory.objects.create(barcode=22, name='Pear')
|
||||
core = models.Inventory.objects.create(
|
||||
@ -641,9 +624,7 @@ class DateTimePickerSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||
|
||||
def test_show_hide_date_time_picker_widgets(self):
|
||||
"""
|
||||
Ensure that pressing the ESC key closes the date and time picker
|
||||
widgets.
|
||||
Refs #17064.
|
||||
Pressing the ESC key closes the date and time picker widgets.
|
||||
"""
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
@ -652,23 +633,23 @@ class DateTimePickerSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||
self.selenium.get(self.live_server_url + reverse('admin:admin_widgets_member_add'))
|
||||
|
||||
# First, with the date picker widget ---------------------------------
|
||||
# Check that the date picker is hidden
|
||||
# The date picker is hidden
|
||||
self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')
|
||||
# Click the calendar icon
|
||||
self.selenium.find_element_by_id('calendarlink0').click()
|
||||
# Check that the date picker is visible
|
||||
# The date picker is visible
|
||||
self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'block')
|
||||
# Press the ESC key
|
||||
self.selenium.find_element_by_tag_name('body').send_keys([Keys.ESCAPE])
|
||||
# Check that the date picker is hidden again
|
||||
# The date picker is hidden again
|
||||
self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')
|
||||
|
||||
# Then, with the time picker widget ----------------------------------
|
||||
# Check that the time picker is hidden
|
||||
# The time picker is hidden
|
||||
self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')
|
||||
# Click the time icon
|
||||
self.selenium.find_element_by_id('clocklink0').click()
|
||||
# Check that the time picker is visible
|
||||
# The time picker is visible
|
||||
self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'block')
|
||||
self.assertEqual(
|
||||
[
|
||||
@ -679,7 +660,7 @@ class DateTimePickerSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||
)
|
||||
# Press the ESC key
|
||||
self.selenium.find_element_by_tag_name('body').send_keys([Keys.ESCAPE])
|
||||
# Check that the time picker is hidden again
|
||||
# The time picker is hidden again
|
||||
self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')
|
||||
|
||||
def test_calendar_nonday_class(self):
|
||||
@ -753,8 +734,8 @@ class DateTimePickerSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||
|
||||
def test_calendar_show_date_from_input(self):
|
||||
"""
|
||||
Ensure that the calendar show the date from the input field for every
|
||||
locale supported by django.
|
||||
The calendar shows the date from the input field for every locale
|
||||
supported by Django.
|
||||
"""
|
||||
self.admin_login(username='super', password='secret', login_url='/')
|
||||
|
||||
@ -795,7 +776,7 @@ class DateTimePickerShortcutsSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||
|
||||
def test_date_time_picker_shortcuts(self):
|
||||
"""
|
||||
Ensure that date/time/datetime picker shortcuts work in the current time zone.
|
||||
date/time/datetime picker shortcuts work in the current time zone.
|
||||
Refs #20663.
|
||||
|
||||
This test case is fairly tricky, it relies on selenium still running the browser
|
||||
@ -826,7 +807,7 @@ class DateTimePickerShortcutsSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||
for shortcut in shortcuts:
|
||||
shortcut.find_element_by_tag_name('a').click()
|
||||
|
||||
# Check that there is a time zone mismatch warning.
|
||||
# There is a time zone mismatch warning.
|
||||
# Warning: This would effectively fail if the TIME_ZONE defined in the
|
||||
# settings has the same UTC offset as "Asia/Singapore" because the
|
||||
# mismatch warning would be rightfully missing from the page.
|
||||
@ -1034,8 +1015,8 @@ class HorizontalVerticalFilterSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||
|
||||
def test_filter(self):
|
||||
"""
|
||||
Ensure that typing in the search box filters out options displayed in
|
||||
the 'from' box.
|
||||
Typing in the search box filters out options displayed in the 'from'
|
||||
box.
|
||||
"""
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
@ -1076,8 +1057,7 @@ class HorizontalVerticalFilterSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||
])
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Check that choosing a filtered option sends it properly to the
|
||||
# 'to' box.
|
||||
# Choosing a filtered option sends it properly to the 'to' box.
|
||||
input.send_keys('a')
|
||||
self.assertSelectOptions(from_box, [str(self.arthur.id), str(self.jason.id)])
|
||||
self.get_select_option(from_box, str(self.jason.id)).click()
|
||||
@ -1101,8 +1081,8 @@ class HorizontalVerticalFilterSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||
self.assertSelectOptions(to_box, [str(self.peter.id), str(self.jason.id)])
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Check that pressing enter on a filtered option sends it properly
|
||||
# to the 'to' box.
|
||||
# Pressing enter on a filtered option sends it properly to
|
||||
# the 'to' box.
|
||||
self.get_select_option(to_box, str(self.jason.id)).click()
|
||||
self.selenium.find_element_by_id(remove_link).click()
|
||||
input.send_keys('ja')
|
||||
@ -1137,7 +1117,7 @@ class HorizontalVerticalFilterSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||
str(self.jason.id), str(self.jenny.id), str(self.john.id),
|
||||
]
|
||||
expected_selected_values = [str(self.lisa.id), str(self.peter.id)]
|
||||
# Check that everything is still in place
|
||||
# Everything is still in place
|
||||
self.assertSelectOptions('#id_students_from', expected_unselected_values)
|
||||
self.assertSelectOptions('#id_students_to', expected_selected_values)
|
||||
self.assertSelectOptions('#id_alumni_from', expected_unselected_values)
|
||||
|
@ -816,7 +816,7 @@ class AggregateTestCase(TestCase):
|
||||
|
||||
def test_dates_with_aggregation(self):
|
||||
"""
|
||||
Test that .dates() returns a distinct set of dates when applied to a
|
||||
.dates() returns a distinct set of dates when applied to a
|
||||
QuerySet with aggregation.
|
||||
|
||||
Refs #18056. Previously, .dates() would return distinct (date_kind,
|
||||
@ -847,8 +847,7 @@ class AggregateTestCase(TestCase):
|
||||
|
||||
def test_ticket17424(self):
|
||||
"""
|
||||
Check that doing exclude() on a foreign model after annotate()
|
||||
doesn't crash.
|
||||
Doing exclude() on a foreign model after annotate() doesn't crash.
|
||||
"""
|
||||
all_books = list(Book.objects.values_list('pk', flat=True).order_by('pk'))
|
||||
annotated_books = Book.objects.order_by('pk').annotate(one=Count("id"))
|
||||
@ -868,7 +867,7 @@ class AggregateTestCase(TestCase):
|
||||
|
||||
def test_ticket12886(self):
|
||||
"""
|
||||
Check that aggregation over sliced queryset works correctly.
|
||||
Aggregation over sliced queryset works correctly.
|
||||
"""
|
||||
qs = Book.objects.all().order_by('-rating')[0:3]
|
||||
vals = qs.aggregate(average_top3_rating=Avg('rating'))['average_top3_rating']
|
||||
@ -876,8 +875,8 @@ class AggregateTestCase(TestCase):
|
||||
|
||||
def test_ticket11881(self):
|
||||
"""
|
||||
Check that subqueries do not needlessly contain ORDER BY, SELECT FOR UPDATE
|
||||
or select_related() stuff.
|
||||
Subqueries do not needlessly contain ORDER BY, SELECT FOR UPDATE or
|
||||
select_related() stuff.
|
||||
"""
|
||||
qs = Book.objects.all().select_for_update().order_by(
|
||||
'pk').select_related('publisher').annotate(max_pk=Max('pk'))
|
||||
|
@ -112,7 +112,7 @@ class AggregationTests(TestCase):
|
||||
Regression test for #12822: DatabaseError: aggregates not allowed in
|
||||
WHERE clause
|
||||
|
||||
Tests that the subselect works and returns results equivalent to a
|
||||
The subselect works and returns results equivalent to a
|
||||
query with the IDs listed.
|
||||
|
||||
Before the corresponding fix for this bug, this test passed in 1.1 and
|
||||
@ -310,14 +310,14 @@ class AggregationTests(TestCase):
|
||||
'name': 'The Definitive Guide to Django: Web Development Done Right',
|
||||
})
|
||||
|
||||
# Check that all of the objects are getting counted (allow_nulls) and
|
||||
# that values respects the amount of objects
|
||||
# All of the objects are getting counted (allow_nulls) and that values
|
||||
# respects the amount of objects
|
||||
self.assertEqual(
|
||||
len(Author.objects.annotate(Avg('friends__age')).values()),
|
||||
9
|
||||
)
|
||||
|
||||
# Check that consecutive calls to annotate accumulate in the query
|
||||
# Consecutive calls to annotate accumulate in the query
|
||||
qs = (
|
||||
Book.objects
|
||||
.values('price')
|
||||
@ -676,8 +676,7 @@ class AggregationTests(TestCase):
|
||||
# Regression for #15709 - Ensure each group_by field only exists once
|
||||
# per query
|
||||
qstr = str(Book.objects.values('publisher').annotate(max_pages=Max('pages')).order_by().query)
|
||||
# Check that there is just one GROUP BY clause (zero commas means at
|
||||
# most one clause)
|
||||
# There is just one GROUP BY clause (zero commas means at most one clause).
|
||||
self.assertEqual(qstr[qstr.index('GROUP BY'):].count(', '), 0)
|
||||
|
||||
def test_duplicate_alias(self):
|
||||
@ -930,7 +929,7 @@ class AggregationTests(TestCase):
|
||||
self.assertEqual(list(qs), list(Book.objects.values_list("pk", flat=True)))
|
||||
|
||||
def test_having_group_by(self):
|
||||
# Test that when a field occurs on the LHS of a HAVING clause that it
|
||||
# When a field occurs on the LHS of a HAVING clause that it
|
||||
# appears correctly in the GROUP BY clause
|
||||
qs = Book.objects.values_list("name").annotate(
|
||||
n_authors=Count("authors")
|
||||
@ -1123,13 +1122,13 @@ class AggregationTests(TestCase):
|
||||
|
||||
def test_annotate_joins(self):
|
||||
"""
|
||||
Test that the base table's join isn't promoted to LOUTER. This could
|
||||
The base table's join isn't promoted to LOUTER. This could
|
||||
cause the query generation to fail if there is an exclude() for fk-field
|
||||
in the query, too. Refs #19087.
|
||||
"""
|
||||
qs = Book.objects.annotate(n=Count('pk'))
|
||||
self.assertIs(qs.query.alias_map['aggregation_regress_book'].join_type, None)
|
||||
# Check that the query executes without problems.
|
||||
# The query executes without problems.
|
||||
self.assertEqual(len(qs.exclude(publisher=-1)), 6)
|
||||
|
||||
@skipUnlessAnyDBFeature('allows_group_by_pk', 'allows_group_by_selected_pks')
|
||||
@ -1145,8 +1144,6 @@ class AggregationTests(TestCase):
|
||||
self.assertIn('id', group_by[0][0])
|
||||
self.assertNotIn('name', group_by[0][0])
|
||||
self.assertNotIn('age', group_by[0][0])
|
||||
|
||||
# Ensure that we get correct results.
|
||||
self.assertEqual(
|
||||
[(a.name, a.num_contacts) for a in results.order_by('name')],
|
||||
[
|
||||
@ -1171,8 +1168,6 @@ class AggregationTests(TestCase):
|
||||
self.assertIn('id', grouping[0][0])
|
||||
self.assertNotIn('name', grouping[0][0])
|
||||
self.assertNotIn('age', grouping[0][0])
|
||||
|
||||
# Ensure that we get correct results.
|
||||
self.assertEqual(
|
||||
[(a.name, a.num_contacts) for a in results.order_by('name')],
|
||||
[
|
||||
@ -1199,8 +1194,6 @@ class AggregationTests(TestCase):
|
||||
self.assertIn('id', grouping[0][0])
|
||||
self.assertNotIn('name', grouping[0][0])
|
||||
self.assertNotIn('contact', grouping[0][0])
|
||||
|
||||
# Ensure that we get correct results.
|
||||
self.assertEqual(
|
||||
[(b.name, b.num_authors) for b in results.order_by('name')],
|
||||
[
|
||||
@ -1295,7 +1288,7 @@ class AggregationTests(TestCase):
|
||||
)
|
||||
|
||||
def test_name_expressions(self):
|
||||
# Test that aggregates are spotted correctly from F objects.
|
||||
# Aggregates are spotted correctly from F objects.
|
||||
# Note that Adrian's age is 34 in the fixtures, and he has one book
|
||||
# so both conditions match one author.
|
||||
qs = Author.objects.annotate(Count('book')).filter(
|
||||
@ -1318,7 +1311,7 @@ class AggregationTests(TestCase):
|
||||
|
||||
def test_ticket_11293_q_immutable(self):
|
||||
"""
|
||||
Check that splitting a q object to parts for where/having doesn't alter
|
||||
Splitting a q object to parts for where/having doesn't alter
|
||||
the original q-object.
|
||||
"""
|
||||
q1 = Q(isbn='')
|
||||
@ -1329,8 +1322,7 @@ class AggregationTests(TestCase):
|
||||
|
||||
def test_fobj_group_by(self):
|
||||
"""
|
||||
Check that an F() object referring to related column works correctly
|
||||
in group by.
|
||||
An F() object referring to related column works correctly in group by.
|
||||
"""
|
||||
qs = Book.objects.annotate(
|
||||
account=Count('authors')
|
||||
|
@ -343,7 +343,7 @@ class NonAggregateAnnotationTestCase(TestCase):
|
||||
|
||||
def test_null_annotation(self):
|
||||
"""
|
||||
Test that annotating None onto a model round-trips
|
||||
Annotating None onto a model round-trips
|
||||
"""
|
||||
book = Book.objects.annotate(no_value=Value(None, output_field=IntegerField())).first()
|
||||
self.assertIsNone(book.no_value)
|
||||
@ -372,9 +372,9 @@ class NonAggregateAnnotationTestCase(TestCase):
|
||||
|
||||
def test_column_field_ordering(self):
|
||||
"""
|
||||
Test that columns are aligned in the correct order for
|
||||
resolve_columns. This test will fail on mysql if column
|
||||
ordering is out. Column fields should be aligned as:
|
||||
Columns are aligned in the correct order for resolve_columns. This test
|
||||
will fail on MySQL if column ordering is out. Column fields should be
|
||||
aligned as:
|
||||
1. extra_select
|
||||
2. model_fields
|
||||
3. annotation_fields
|
||||
|
@ -40,7 +40,7 @@ class AppsTests(SimpleTestCase):
|
||||
|
||||
def test_singleton_master(self):
|
||||
"""
|
||||
Ensures that only one master registry can exist.
|
||||
Only one master registry can exist.
|
||||
"""
|
||||
with self.assertRaises(RuntimeError):
|
||||
Apps(installed_apps=None)
|
||||
@ -179,7 +179,7 @@ class AppsTests(SimpleTestCase):
|
||||
|
||||
def test_models_py(self):
|
||||
"""
|
||||
Tests that the models in the models.py file were loaded correctly.
|
||||
The models in the models.py file were loaded correctly.
|
||||
"""
|
||||
self.assertEqual(apps.get_model("apps", "TotallyNormal"), TotallyNormal)
|
||||
with self.assertRaises(LookupError):
|
||||
@ -282,7 +282,7 @@ class AppsTests(SimpleTestCase):
|
||||
# and LazyModelC shouldn't be waited on until LazyModelB exists.
|
||||
self.assertSetEqual(set(apps._pending_operations) - initial_pending, {('apps', 'lazyb')})
|
||||
|
||||
# Test that multiple operations can wait on the same model
|
||||
# Multiple operations can wait on the same model
|
||||
apps.lazy_model_operation(test_func, ('apps', 'lazyb'))
|
||||
|
||||
class LazyB(models.Model):
|
||||
|
@ -295,7 +295,7 @@ class CustomPermissionsUserModelBackendTest(BaseModelBackendTest, TestCase):
|
||||
@override_settings(AUTH_USER_MODEL='auth_tests.CustomUser')
|
||||
class CustomUserModelBackendAuthenticateTest(TestCase):
|
||||
"""
|
||||
Tests that the model backend can accept a credentials kwarg labeled with
|
||||
The model backend can accept a credentials kwarg labeled with
|
||||
custom user model's USERNAME_FIELD.
|
||||
"""
|
||||
|
||||
@ -440,7 +440,7 @@ class AnonymousUserBackendTest(SimpleTestCase):
|
||||
@override_settings(AUTHENTICATION_BACKENDS=[])
|
||||
class NoBackendsTest(TestCase):
|
||||
"""
|
||||
Tests that an appropriate error is raised if no auth backends are provided.
|
||||
An appropriate error is raised if no auth backends are provided.
|
||||
"""
|
||||
def setUp(self):
|
||||
self.user = User.objects.create_user('test', 'test@example.com', 'test')
|
||||
@ -487,7 +487,7 @@ class PermissionDeniedBackend(object):
|
||||
|
||||
class PermissionDeniedBackendTest(TestCase):
|
||||
"""
|
||||
Tests that other backends are not checked once a backend raises PermissionDenied
|
||||
Other backends are not checked once a backend raises PermissionDenied
|
||||
"""
|
||||
backend = 'auth_tests.test_auth_backends.PermissionDeniedBackend'
|
||||
|
||||
@ -547,27 +547,22 @@ class ChangedBackendSettingsTest(TestCase):
|
||||
TEST_EMAIL = 'test@example.com'
|
||||
|
||||
def setUp(self):
|
||||
User.objects.create_user(self.TEST_USERNAME,
|
||||
self.TEST_EMAIL,
|
||||
self.TEST_PASSWORD)
|
||||
User.objects.create_user(self.TEST_USERNAME, self.TEST_EMAIL, self.TEST_PASSWORD)
|
||||
|
||||
@override_settings(AUTHENTICATION_BACKENDS=[backend])
|
||||
def test_changed_backend_settings(self):
|
||||
"""
|
||||
Tests that removing a backend configured in AUTHENTICATION_BACKENDS
|
||||
make already logged-in users disconnect.
|
||||
Removing a backend configured in AUTHENTICATION_BACKENDS makes already
|
||||
logged-in users disconnect.
|
||||
"""
|
||||
|
||||
# Get a session for the test user
|
||||
self.assertTrue(self.client.login(
|
||||
username=self.TEST_USERNAME,
|
||||
password=self.TEST_PASSWORD)
|
||||
)
|
||||
|
||||
# Prepare a request object
|
||||
request = HttpRequest()
|
||||
request.session = self.client.session
|
||||
|
||||
# Remove NewModelBackend
|
||||
with self.settings(AUTHENTICATION_BACKENDS=[
|
||||
'django.contrib.auth.backends.ModelBackend']):
|
||||
@ -591,9 +586,7 @@ class TypeErrorBackend(object):
|
||||
|
||||
class TypeErrorBackendTest(TestCase):
|
||||
"""
|
||||
Tests that a TypeError within a backend is propagated properly.
|
||||
|
||||
Regression test for ticket #18171
|
||||
A TypeError within a backend is propagated properly (#18171).
|
||||
"""
|
||||
backend = 'auth_tests.test_auth_backends.TypeErrorBackend'
|
||||
|
||||
@ -608,17 +601,12 @@ class TypeErrorBackendTest(TestCase):
|
||||
|
||||
class ImproperlyConfiguredUserModelTest(TestCase):
|
||||
"""
|
||||
Tests that an exception from within get_user_model is propagated and doesn't
|
||||
raise an UnboundLocalError.
|
||||
|
||||
Regression test for ticket #21439
|
||||
An exception from within get_user_model() is propagated and doesn't
|
||||
raise an UnboundLocalError (#21439).
|
||||
"""
|
||||
def setUp(self):
|
||||
self.user1 = User.objects.create_user('test', 'test@example.com', 'test')
|
||||
self.client.login(
|
||||
username='test',
|
||||
password='test'
|
||||
)
|
||||
self.client.login(username='test', password='test')
|
||||
|
||||
@override_settings(AUTH_USER_MODEL='thismodel.doesntexist')
|
||||
def test_does_not_shadow_exception(self):
|
||||
|
@ -16,7 +16,7 @@ from .models import CustomUser
|
||||
|
||||
class BasicTestCase(TestCase):
|
||||
def test_user(self):
|
||||
"Check that users can be created and can set their password"
|
||||
"Users can be created and can set their password"
|
||||
u = User.objects.create_user('testuser', 'test@example.com', 'testpw')
|
||||
self.assertTrue(u.has_usable_password())
|
||||
self.assertFalse(u.check_password('bad'))
|
||||
@ -77,7 +77,7 @@ class BasicTestCase(TestCase):
|
||||
self.assertEqual(str(warns[0].message), deprecation_message)
|
||||
|
||||
def test_user_no_email(self):
|
||||
"Check that users can be created without an email"
|
||||
"Users can be created without an email"
|
||||
u = User.objects.create_user('testuser1')
|
||||
self.assertEqual(u.email, '')
|
||||
|
||||
|
@ -41,7 +41,7 @@ class PermWrapperTests(SimpleTestCase):
|
||||
|
||||
def test_permwrapper_in(self):
|
||||
"""
|
||||
Test that 'something' in PermWrapper works as expected.
|
||||
'something' in PermWrapper works as expected.
|
||||
"""
|
||||
perms = PermWrapper(MockUser())
|
||||
# Works for modules and full permissions.
|
||||
@ -72,7 +72,7 @@ class AuthContextProcessorTests(TestCase):
|
||||
@override_settings(MIDDLEWARE=AUTH_MIDDLEWARE)
|
||||
def test_session_not_accessed(self):
|
||||
"""
|
||||
Tests that the session is not accessed simply by including
|
||||
The session is not accessed simply by including
|
||||
the auth context processor
|
||||
"""
|
||||
response = self.client.get('/auth_processor_no_attr_access/')
|
||||
@ -87,7 +87,7 @@ class AuthContextProcessorTests(TestCase):
|
||||
@override_settings(MIDDLEWARE=AUTH_MIDDLEWARE)
|
||||
def test_session_is_accessed(self):
|
||||
"""
|
||||
Tests that the session is accessed if the auth context processor
|
||||
The session is accessed if the auth context processor
|
||||
is used and relevant attributes accessed.
|
||||
"""
|
||||
response = self.client.get('/auth_processor_attr_access/')
|
||||
@ -130,7 +130,7 @@ class AuthContextProcessorTests(TestCase):
|
||||
|
||||
def test_user_attrs(self):
|
||||
"""
|
||||
Test that the lazy objects returned behave just like the wrapped objects.
|
||||
The lazy objects returned behave just like the wrapped objects.
|
||||
"""
|
||||
# These are 'functional' level tests for common use cases. Direct
|
||||
# testing of the implementation (SimpleLazyObject) is in the 'utils'
|
||||
|
@ -17,7 +17,7 @@ class LoginRequiredTestCase(AuthViewsTestCase):
|
||||
|
||||
def testCallable(self):
|
||||
"""
|
||||
Check that login_required is assignable to callable objects.
|
||||
login_required is assignable to callable objects.
|
||||
"""
|
||||
class CallableView(object):
|
||||
def __call__(self, *args, **kwargs):
|
||||
@ -26,7 +26,7 @@ class LoginRequiredTestCase(AuthViewsTestCase):
|
||||
|
||||
def testView(self):
|
||||
"""
|
||||
Check that login_required is assignable to normal views.
|
||||
login_required is assignable to normal views.
|
||||
"""
|
||||
def normal_view(request):
|
||||
pass
|
||||
@ -34,8 +34,8 @@ class LoginRequiredTestCase(AuthViewsTestCase):
|
||||
|
||||
def testLoginRequired(self, view_url='/login_required/', login_url=None):
|
||||
"""
|
||||
Check that login_required works on a simple view wrapped in a
|
||||
login_required decorator.
|
||||
login_required works on a simple view wrapped in a login_required
|
||||
decorator.
|
||||
"""
|
||||
if login_url is None:
|
||||
login_url = settings.LOGIN_URL
|
||||
@ -48,8 +48,8 @@ class LoginRequiredTestCase(AuthViewsTestCase):
|
||||
|
||||
def testLoginRequiredNextUrl(self):
|
||||
"""
|
||||
Check that login_required works on a simple view wrapped in a
|
||||
login_required decorator with a login_url set.
|
||||
login_required works on a simple view wrapped in a login_required
|
||||
decorator with a login_url set.
|
||||
"""
|
||||
self.testLoginRequired(view_url='/login_required_login_url/', login_url='/somewhere/')
|
||||
|
||||
|
@ -195,12 +195,12 @@ class PasswordResetTest(AuthViewsTestCase):
|
||||
self.assertContains(response, "The password reset link was invalid")
|
||||
|
||||
def test_confirm_invalid_user(self):
|
||||
# Ensure that we get a 200 response for a non-existent user, not a 404
|
||||
# We get a 200 response for a non-existent user, not a 404
|
||||
response = self.client.get('/reset/123456/1-1/')
|
||||
self.assertContains(response, "The password reset link was invalid")
|
||||
|
||||
def test_confirm_overflow_user(self):
|
||||
# Ensure that we get a 200 response for a base36 user id that overflows int
|
||||
# We get a 200 response for a base36 user id that overflows int
|
||||
response = self.client.get('/reset/zzzzzzzzzzzzz/1-1/')
|
||||
self.assertContains(response, "The password reset link was invalid")
|
||||
|
||||
|
@ -745,7 +745,7 @@ class PasswordResetFormTest(TestDataMixin, TestCase):
|
||||
|
||||
def test_inactive_user(self):
|
||||
"""
|
||||
Test that inactive user cannot receive password reset email.
|
||||
Inactive user cannot receive password reset email.
|
||||
"""
|
||||
(user, username, email) = self.create_dummy_user()
|
||||
user.is_active = False
|
||||
|
@ -24,7 +24,7 @@ class ModWsgiHandlerTestCase(TransactionTestCase):
|
||||
|
||||
def test_check_password(self):
|
||||
"""
|
||||
Verify that check_password returns the correct values as per
|
||||
check_password() returns the correct values as per
|
||||
https://modwsgi.readthedocs.io/en/develop/user-guides/access-control-mechanisms.html#apache-authentication-provider
|
||||
"""
|
||||
User.objects.create_user('test', 'test@example.com', 'test')
|
||||
@ -45,11 +45,10 @@ class ModWsgiHandlerTestCase(TransactionTestCase):
|
||||
@override_settings(AUTH_USER_MODEL='auth_tests.CustomUser')
|
||||
def test_check_password_custom_user(self):
|
||||
"""
|
||||
Verify that check_password returns the correct values as per
|
||||
check_password() returns the correct values as per
|
||||
https://modwsgi.readthedocs.io/en/develop/user-guides/access-control-mechanisms.html#apache-authentication-provider
|
||||
with custom user installed
|
||||
with a custom user installed.
|
||||
"""
|
||||
|
||||
CustomUser._default_manager.create_user('test@example.com', '1990-01-01', 'test')
|
||||
|
||||
# User not in database
|
||||
@ -63,7 +62,7 @@ class ModWsgiHandlerTestCase(TransactionTestCase):
|
||||
|
||||
def test_groups_for_user(self):
|
||||
"""
|
||||
Check that groups_for_user returns correct values as per
|
||||
groups_for_user() returns correct values as per
|
||||
https://modwsgi.readthedocs.io/en/develop/user-guides/access-control-mechanisms.html#apache-group-authorisation
|
||||
"""
|
||||
user1 = User.objects.create_user('test', 'test@example.com', 'test')
|
||||
|
@ -161,7 +161,7 @@ class TestUtilsHashPass(SimpleTestCase):
|
||||
self.assertFalse(check_password('lètmeinz', encoded))
|
||||
self.assertEqual(identify_hasher(encoded).algorithm, "bcrypt_sha256")
|
||||
|
||||
# Verify that password truncation no longer works
|
||||
# password truncation no longer works
|
||||
password = (
|
||||
'VSK0UYV6FFQVZ0KG88DYN9WADAADZO1CTSIVDJUNZSUML6IBX7LN7ZS3R5'
|
||||
'JGB3RGZ7VI7G7DJQ9NI8BQFSRPTG6UWTTVESA5ZPUN'
|
||||
@ -210,7 +210,7 @@ class TestUtilsHashPass(SimpleTestCase):
|
||||
def setter(password):
|
||||
state['upgraded'] = True
|
||||
|
||||
# Check that no upgrade is triggered.
|
||||
# No upgrade is triggered.
|
||||
self.assertTrue(check_password('letmein', encoded, setter, 'bcrypt'))
|
||||
self.assertFalse(state['upgraded'])
|
||||
|
||||
@ -353,7 +353,7 @@ class TestUtilsHashPass(SimpleTestCase):
|
||||
def setter(password):
|
||||
state['upgraded'] = True
|
||||
|
||||
# Check that no upgrade is triggered
|
||||
# No upgrade is triggered
|
||||
self.assertTrue(check_password('letmein', encoded, setter))
|
||||
self.assertFalse(state['upgraded'])
|
||||
|
||||
@ -401,7 +401,7 @@ class TestUtilsHashPass(SimpleTestCase):
|
||||
algo, iterations, salt, hash = encoded.split('$', 3)
|
||||
self.assertEqual(iterations, '1')
|
||||
|
||||
# Check that no upgrade is triggered
|
||||
# No upgrade is triggered
|
||||
self.assertTrue(check_password('letmein', encoded, setter))
|
||||
self.assertFalse(state['upgraded'])
|
||||
|
||||
@ -513,7 +513,7 @@ class TestUtilsHashPassArgon2(SimpleTestCase):
|
||||
def setter(password):
|
||||
state['upgraded'] = True
|
||||
|
||||
# Check that no upgrade is triggered.
|
||||
# No upgrade is triggered.
|
||||
self.assertTrue(check_password('letmein', encoded, setter, 'argon2'))
|
||||
self.assertFalse(state['upgraded'])
|
||||
|
||||
|
@ -186,8 +186,8 @@ class LoginRequiredMixinTests(TestCase):
|
||||
|
||||
def test_login_required(self):
|
||||
"""
|
||||
Check that login_required works on a simple view wrapped in a
|
||||
login_required decorator.
|
||||
login_required works on a simple view wrapped in a login_required
|
||||
decorator.
|
||||
"""
|
||||
class AView(LoginRequiredMixin, EmptyResponseView):
|
||||
pass
|
||||
|
@ -189,9 +189,7 @@ class AbstractUserTestCase(TestCase):
|
||||
from_email="from@domain.com",
|
||||
**kwargs
|
||||
)
|
||||
# Test that one message has been sent.
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
# Verify that test email contains the correct attributes:
|
||||
message = mail.outbox[0]
|
||||
self.assertEqual(message.subject, "Subject here")
|
||||
self.assertEqual(message.body, "This is a message")
|
||||
|
@ -77,7 +77,7 @@ class RemoteUserTest(TestCase):
|
||||
**{self.header: self.known_user})
|
||||
self.assertEqual(response.context['user'].username, 'knownuser')
|
||||
self.assertEqual(User.objects.count(), num_users)
|
||||
# Test that a different user passed in the headers causes the new user
|
||||
# A different user passed in the headers causes the new user
|
||||
# to be logged in.
|
||||
response = self.client.get('/remote_user/',
|
||||
**{self.header: self.known_user2})
|
||||
@ -86,7 +86,7 @@ class RemoteUserTest(TestCase):
|
||||
|
||||
def test_last_login(self):
|
||||
"""
|
||||
Tests that a user's last_login is set the first time they make a
|
||||
A user's last_login is set the first time they make a
|
||||
request but not updated in subsequent requests with the same session.
|
||||
"""
|
||||
user = User.objects.create(username='knownuser')
|
||||
@ -110,7 +110,7 @@ class RemoteUserTest(TestCase):
|
||||
|
||||
def test_header_disappears(self):
|
||||
"""
|
||||
Tests that a logged in user is logged out automatically when
|
||||
A logged in user is logged out automatically when
|
||||
the REMOTE_USER header disappears during the same browser session.
|
||||
"""
|
||||
User.objects.create(username='knownuser')
|
||||
@ -131,7 +131,7 @@ class RemoteUserTest(TestCase):
|
||||
|
||||
def test_user_switch_forces_new_login(self):
|
||||
"""
|
||||
Tests that if the username in the header changes between requests
|
||||
If the username in the header changes between requests
|
||||
that the original user is logged out
|
||||
"""
|
||||
User.objects.create(username='knownuser')
|
||||
@ -142,7 +142,7 @@ class RemoteUserTest(TestCase):
|
||||
# During the session, the REMOTE_USER changes to a different user.
|
||||
response = self.client.get('/remote_user/',
|
||||
**{self.header: "newnewuser"})
|
||||
# Ensure that the current user is not the prior remote_user
|
||||
# The current user is not the prior remote_user.
|
||||
# In backends that create a new user, username is "newnewuser"
|
||||
# In backends that do not create new users, it is '' (anonymous user)
|
||||
self.assertNotEqual(response.context['user'].username, 'knownuser')
|
||||
|
@ -68,7 +68,7 @@ class SignalTestCase(TestCase):
|
||||
self.assertEqual(self.logged_out[0].username, 'testclient')
|
||||
|
||||
def test_update_last_login(self):
|
||||
"""Ensure that only `last_login` is updated in `update_last_login`"""
|
||||
"""Only `last_login` is updated in `update_last_login`"""
|
||||
user = self.u3
|
||||
old_last_login = user.last_login
|
||||
|
||||
|
@ -11,9 +11,6 @@ from django.utils.six import PY3
|
||||
class TokenGeneratorTest(TestCase):
|
||||
|
||||
def test_make_token(self):
|
||||
"""
|
||||
Ensure that we can make a token and that it is valid
|
||||
"""
|
||||
user = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw')
|
||||
p0 = PasswordResetTokenGenerator()
|
||||
tk1 = p0.make_token(user)
|
||||
@ -21,7 +18,7 @@ class TokenGeneratorTest(TestCase):
|
||||
|
||||
def test_10265(self):
|
||||
"""
|
||||
Ensure that the token generated for a user created in the same request
|
||||
The token generated for a user created in the same request
|
||||
will work correctly.
|
||||
"""
|
||||
# See ticket #10265
|
||||
@ -34,7 +31,7 @@ class TokenGeneratorTest(TestCase):
|
||||
|
||||
def test_timeout(self):
|
||||
"""
|
||||
Ensure we can use the token after n days, but no greater.
|
||||
The token is valid after n days, but no greater.
|
||||
"""
|
||||
# Uses a mocked version of PasswordResetTokenGenerator so we can change
|
||||
# the value of 'today'
|
||||
@ -57,7 +54,7 @@ class TokenGeneratorTest(TestCase):
|
||||
@unittest.skipIf(PY3, "Unnecessary test with Python 3")
|
||||
def test_date_length(self):
|
||||
"""
|
||||
Make sure we don't allow overly long dates, causing a potential DoS.
|
||||
Overly long dates, which are a potential DoS vector, aren't allowed.
|
||||
"""
|
||||
user = User.objects.create_user('ima1337h4x0r', 'test4@example.com', 'p4ssw0rd')
|
||||
p0 = PasswordResetTokenGenerator()
|
||||
|
@ -233,18 +233,17 @@ class PasswordResetTest(AuthViewsTestCase):
|
||||
self.assertContains(response, "The password reset link was invalid")
|
||||
|
||||
def test_confirm_invalid_user(self):
|
||||
# Ensure that we get a 200 response for a non-existent user, not a 404
|
||||
# A non-existent user returns a 200 response, not a 404.
|
||||
response = self.client.get('/reset/123456/1-1/')
|
||||
self.assertContains(response, "The password reset link was invalid")
|
||||
|
||||
def test_confirm_overflow_user(self):
|
||||
# Ensure that we get a 200 response for a base36 user id that overflows int
|
||||
# A base36 user id that overflows int returns a 200 response.
|
||||
response = self.client.get('/reset/zzzzzzzzzzzzz/1-1/')
|
||||
self.assertContains(response, "The password reset link was invalid")
|
||||
|
||||
def test_confirm_invalid_post(self):
|
||||
# Same as test_confirm_invalid, but trying
|
||||
# to do a POST instead.
|
||||
# Same as test_confirm_invalid, but trying to do a POST instead.
|
||||
url, path = self._test_confirm_start()
|
||||
path = path[:-5] + ("0" * 4) + path[-1]
|
||||
|
||||
@ -311,14 +310,12 @@ class PasswordResetTest(AuthViewsTestCase):
|
||||
def test_confirm_display_user_from_form(self):
|
||||
url, path = self._test_confirm_start()
|
||||
response = self.client.get(path)
|
||||
|
||||
# #16919 -- The ``password_reset_confirm`` view should pass the user
|
||||
# object to the ``SetPasswordForm``, even on GET requests.
|
||||
# For this test, we render ``{{ form.user }}`` in the template
|
||||
# ``registration/password_reset_confirm.html`` so that we can test this.
|
||||
# The password_reset_confirm() view passes the user object to the
|
||||
# SetPasswordForm``, even on GET requests (#16919). For this test,
|
||||
# {{ form.user }}`` is rendered in the template
|
||||
# registration/password_reset_confirm.html.
|
||||
username = User.objects.get(email='staffmember@example.com').username
|
||||
self.assertContains(response, "Hello, %s." % username)
|
||||
|
||||
# However, the view should NOT pass any user object on a form if the
|
||||
# password reset link was invalid.
|
||||
response = self.client.get('/reset/zzzzzzzzzzzzz/1-1/')
|
||||
@ -978,7 +975,7 @@ class LogoutTest(AuthViewsTestCase):
|
||||
self.confirm_logged_out()
|
||||
|
||||
def test_logout_preserve_language(self):
|
||||
"""Check that language stored in session is preserved after logout"""
|
||||
"""Language stored in session is preserved after logout"""
|
||||
# Create a new session with language
|
||||
engine = import_module(settings.SESSION_ENGINE)
|
||||
session = engine.SessionStore()
|
||||
|
@ -61,7 +61,7 @@ class DummyBackendTest(SimpleTestCase):
|
||||
|
||||
def test_no_databases(self):
|
||||
"""
|
||||
Test that empty DATABASES setting default to the dummy backend.
|
||||
Empty DATABASES setting default to the dummy backend.
|
||||
"""
|
||||
DATABASES = {}
|
||||
conns = ConnectionHandler(DATABASES)
|
||||
@ -74,7 +74,7 @@ class DummyBackendTest(SimpleTestCase):
|
||||
class OracleTests(unittest.TestCase):
|
||||
|
||||
def test_quote_name(self):
|
||||
# Check that '%' chars are escaped for query execution.
|
||||
# '%' chars are escaped for query execution.
|
||||
name = '"SOME%NAME"'
|
||||
quoted_name = connection.ops.quote_name(name)
|
||||
self.assertEqual(quoted_name % (), name)
|
||||
@ -122,7 +122,7 @@ class OracleTests(unittest.TestCase):
|
||||
# NLS parameters as per #18465.
|
||||
with connection.cursor() as cursor:
|
||||
query = "select 1 from dual where '1936-12-29 00:00' < sysdate"
|
||||
# Test that the query succeeds without errors - pre #18465 this
|
||||
# The query succeeds without errors - pre #18465 this
|
||||
# wasn't the case.
|
||||
cursor.execute(query)
|
||||
self.assertEqual(cursor.fetchone()[0], 1)
|
||||
@ -135,8 +135,8 @@ class SQLiteTests(TestCase):
|
||||
|
||||
def test_autoincrement(self):
|
||||
"""
|
||||
Check that auto_increment fields are created with the AUTOINCREMENT
|
||||
keyword in order to be monotonically increasing. Refs #10164.
|
||||
auto_increment fields are created with the AUTOINCREMENT keyword
|
||||
in order to be monotonically increasing. Refs #10164.
|
||||
"""
|
||||
with connection.schema_editor(collect_sql=True) as editor:
|
||||
editor.create_model(models.Square)
|
||||
@ -211,7 +211,7 @@ class PostgreSQLTests(TestCase):
|
||||
|
||||
def test_nodb_connection(self):
|
||||
"""
|
||||
Test that the _nodb_connection property fallbacks to the default connection
|
||||
The _nodb_connection property fallbacks to the default connection
|
||||
database when access to the 'postgres' database is not granted.
|
||||
"""
|
||||
def mocked_connect(self):
|
||||
@ -378,10 +378,7 @@ class DateQuotingTest(TestCase):
|
||||
def test_django_date_trunc(self):
|
||||
"""
|
||||
Test the custom ``django_date_trunc method``, in particular against
|
||||
fields which clash with strings passed to it (e.g. 'year') - see
|
||||
#12818__.
|
||||
|
||||
__: http://code.djangoproject.com/ticket/12818
|
||||
fields which clash with strings passed to it (e.g. 'year') (#12818).
|
||||
"""
|
||||
updated = datetime.datetime(2010, 2, 20)
|
||||
models.SchoolClass.objects.create(year=2009, last_updated=updated)
|
||||
@ -391,9 +388,7 @@ class DateQuotingTest(TestCase):
|
||||
def test_django_date_extract(self):
|
||||
"""
|
||||
Test the custom ``django_date_extract method``, in particular against fields
|
||||
which clash with strings passed to it (e.g. 'day') - see #12818__.
|
||||
|
||||
__: http://code.djangoproject.com/ticket/12818
|
||||
which clash with strings passed to it (e.g. 'day') (#12818).
|
||||
"""
|
||||
updated = datetime.datetime(2010, 2, 20)
|
||||
models.SchoolClass.objects.create(year=2009, last_updated=updated)
|
||||
@ -420,7 +415,7 @@ class LastExecutedQueryTest(TestCase):
|
||||
|
||||
def test_query_encoding(self):
|
||||
"""
|
||||
Test that last_executed_query() returns an Unicode string
|
||||
last_executed_query() returns an Unicode string
|
||||
"""
|
||||
data = models.RawData.objects.filter(raw_data=b'\x00\x46 \xFE').extra(select={'föö': 1})
|
||||
sql, params = data.query.sql_with_params()
|
||||
@ -431,8 +426,7 @@ class LastExecutedQueryTest(TestCase):
|
||||
@unittest.skipUnless(connection.vendor == 'sqlite',
|
||||
"This test is specific to SQLite.")
|
||||
def test_no_interpolation_on_sqlite(self):
|
||||
# Regression for #17158
|
||||
# This shouldn't raise an exception
|
||||
# This shouldn't raise an exception (##17158)
|
||||
query = "SELECT strftime('%Y', 'now');"
|
||||
connection.cursor().execute(query)
|
||||
self.assertEqual(connection.queries[-1]['sql'], query)
|
||||
@ -729,7 +723,7 @@ class BackendTestCase(TransactionTestCase):
|
||||
|
||||
def test_database_operations_init(self):
|
||||
"""
|
||||
Test that DatabaseOperations initialization doesn't query the database.
|
||||
DatabaseOperations initialization doesn't query the database.
|
||||
See #17656.
|
||||
"""
|
||||
with self.assertNumQueries(0):
|
||||
@ -741,7 +735,7 @@ class BackendTestCase(TransactionTestCase):
|
||||
self.assertIn(connection.features.can_introspect_foreign_keys, (True, False))
|
||||
|
||||
def test_duplicate_table_error(self):
|
||||
""" Test that creating an existing table returns a DatabaseError """
|
||||
""" Creating an existing table returns a DatabaseError """
|
||||
cursor = connection.cursor()
|
||||
query = 'CREATE TABLE %s (id INTEGER);' % models.Article._meta.db_table
|
||||
with self.assertRaises(DatabaseError):
|
||||
@ -749,7 +743,7 @@ class BackendTestCase(TransactionTestCase):
|
||||
|
||||
def test_cursor_contextmanager(self):
|
||||
"""
|
||||
Test that cursors can be used as a context manager
|
||||
Cursors can be used as a context manager
|
||||
"""
|
||||
with connection.cursor() as cursor:
|
||||
self.assertIsInstance(cursor, CursorWrapper)
|
||||
@ -774,9 +768,7 @@ class BackendTestCase(TransactionTestCase):
|
||||
@skipUnlessDBFeature('test_db_allows_multiple_connections')
|
||||
def test_is_usable_after_database_disconnects(self):
|
||||
"""
|
||||
Test that is_usable() doesn't crash when the database disconnects.
|
||||
|
||||
Regression for #21553.
|
||||
is_usable() doesn't crash when the database disconnects (#21553).
|
||||
"""
|
||||
# Open a connection to the database.
|
||||
with connection.cursor():
|
||||
@ -816,9 +808,7 @@ class BackendTestCase(TransactionTestCase):
|
||||
@override_settings(DEBUG=True)
|
||||
def test_queries_limit(self):
|
||||
"""
|
||||
Test that the backend doesn't store an unlimited number of queries.
|
||||
|
||||
Regression for #12581.
|
||||
The backend doesn't store an unlimited number of queries (#12581).
|
||||
"""
|
||||
old_queries_limit = BaseDatabaseWrapper.queries_limit
|
||||
BaseDatabaseWrapper.queries_limit = 3
|
||||
@ -995,9 +985,8 @@ class ThreadTests(TransactionTestCase):
|
||||
|
||||
def test_default_connection_thread_local(self):
|
||||
"""
|
||||
Ensure that the default connection (i.e. django.db.connection) is
|
||||
different for each thread.
|
||||
Refs #17258.
|
||||
The default connection (i.e. django.db.connection) is different for
|
||||
each thread (#17258).
|
||||
"""
|
||||
# Map connections by id because connections with identical aliases
|
||||
# have the same hash.
|
||||
@ -1019,7 +1008,7 @@ class ThreadTests(TransactionTestCase):
|
||||
t = threading.Thread(target=runner)
|
||||
t.start()
|
||||
t.join()
|
||||
# Check that each created connection got different inner connection.
|
||||
# Each created connection got different inner connection.
|
||||
self.assertEqual(
|
||||
len(set(conn.connection for conn in connections_dict.values())),
|
||||
3)
|
||||
@ -1032,8 +1021,7 @@ class ThreadTests(TransactionTestCase):
|
||||
|
||||
def test_connections_thread_local(self):
|
||||
"""
|
||||
Ensure that the connections are different for each thread.
|
||||
Refs #17258.
|
||||
The connections are different for each thread (#17258).
|
||||
"""
|
||||
# Map connections by id because connections with identical aliases
|
||||
# have the same hash.
|
||||
@ -1062,8 +1050,7 @@ class ThreadTests(TransactionTestCase):
|
||||
|
||||
def test_pass_connection_between_threads(self):
|
||||
"""
|
||||
Ensure that a connection can be passed from one thread to the other.
|
||||
Refs #17258.
|
||||
A connection can be passed from one thread to the other (#17258).
|
||||
"""
|
||||
models.Person.objects.create(first_name="John", last_name="Doe")
|
||||
|
||||
@ -1101,9 +1088,8 @@ class ThreadTests(TransactionTestCase):
|
||||
|
||||
def test_closing_non_shared_connections(self):
|
||||
"""
|
||||
Ensure that a connection that is not explicitly shareable cannot be
|
||||
closed by another thread.
|
||||
Refs #17258.
|
||||
A connection that is not explicitly shareable cannot be closed by
|
||||
another thread (#17258).
|
||||
"""
|
||||
# First, without explicitly enabling the connection for sharing.
|
||||
exceptions = set()
|
||||
|
@ -331,7 +331,7 @@ class ModelTest(TestCase):
|
||||
|
||||
def test_create_relation_with_ugettext_lazy(self):
|
||||
"""
|
||||
Test that ugettext_lazy objects work when saving model instances
|
||||
ugettext_lazy objects work when saving model instances
|
||||
through various methods. Refs #10498.
|
||||
"""
|
||||
notlazy = 'test'
|
||||
@ -640,9 +640,8 @@ class SelectOnSaveTests(TestCase):
|
||||
|
||||
def test_select_on_save_lying_update(self):
|
||||
"""
|
||||
Test that select_on_save works correctly if the database
|
||||
doesn't return correct information about matched rows from
|
||||
UPDATE.
|
||||
select_on_save works correctly if the database doesn't return correct
|
||||
information about matched rows from UPDATE.
|
||||
"""
|
||||
# Change the manager to not return "row matched" for update().
|
||||
# We are going to change the Article's _base_manager class
|
||||
|
@ -7,8 +7,7 @@ from unittest import TestCase
|
||||
from wsgiref import simple_server
|
||||
|
||||
# If data is too large, socket will choke, so write chunks no larger than 32MB
|
||||
# at a time. The rationale behind the 32MB can be found on Django's Trac:
|
||||
# https://code.djangoproject.com/ticket/5596#comment:4
|
||||
# at a time. The rationale behind the 32MB can be found in #5596#comment:4.
|
||||
MAX_SOCKET_CHUNK_SIZE = 32 * 1024 * 1024 # 32 MB
|
||||
|
||||
|
||||
@ -80,7 +79,7 @@ def wsgi_app_file_wrapper(environ, start_response):
|
||||
|
||||
class WSGIFileWrapperTests(TestCase):
|
||||
"""
|
||||
Test that the wsgi.file_wrapper works for the builting server.
|
||||
The wsgi.file_wrapper works for the builting server.
|
||||
|
||||
Tests for #9659: wsgi.file_wrapper in the builtin server.
|
||||
We need to mock a couple of handlers and keep track of what
|
||||
@ -134,7 +133,7 @@ def send_big_data_app(environ, start_response):
|
||||
|
||||
class ServerHandlerChunksProperly(TestCase):
|
||||
"""
|
||||
Test that the ServerHandler chunks data properly.
|
||||
The ServerHandler chunks data properly.
|
||||
|
||||
Tests for #18972: The logic that performs the math to break data into
|
||||
32MB (MAX_SOCKET_CHUNK_SIZE) chunks was flawed, BUT it didn't actually
|
||||
|
46
tests/cache/tests.py
vendored
46
tests/cache/tests.py
vendored
@ -506,11 +506,11 @@ class BaseCacheTests(object):
|
||||
self.assertIsNone(cache.get("key2"))
|
||||
|
||||
def test_long_timeout(self):
|
||||
'''
|
||||
Using a timeout greater than 30 days makes memcached think
|
||||
it is an absolute expiration timestamp instead of a relative
|
||||
offset. Test that we honour this convention. Refs #12399.
|
||||
'''
|
||||
"""
|
||||
Followe memcached's convention where a timeout greater than 30 days is
|
||||
treated as an absolute expiration timestamp instead of a relative
|
||||
offset (#12399).
|
||||
"""
|
||||
cache.set('key1', 'eggs', 60 * 60 * 24 * 30 + 1) # 30 days + 1 second
|
||||
self.assertEqual(cache.get('key1'), 'eggs')
|
||||
|
||||
@ -522,9 +522,9 @@ class BaseCacheTests(object):
|
||||
self.assertEqual(cache.get('key4'), 'lobster bisque')
|
||||
|
||||
def test_forever_timeout(self):
|
||||
'''
|
||||
"""
|
||||
Passing in None into timeout results in a value that is cached forever
|
||||
'''
|
||||
"""
|
||||
cache.set('key1', 'eggs', None)
|
||||
self.assertEqual(cache.get('key1'), 'eggs')
|
||||
|
||||
@ -539,9 +539,9 @@ class BaseCacheTests(object):
|
||||
self.assertEqual(cache.get('key4'), 'lobster bisque')
|
||||
|
||||
def test_zero_timeout(self):
|
||||
'''
|
||||
"""
|
||||
Passing in zero into timeout results in a value that is not cached
|
||||
'''
|
||||
"""
|
||||
cache.set('key1', 'eggs', 0)
|
||||
self.assertIsNone(cache.get('key1'))
|
||||
|
||||
@ -1115,7 +1115,7 @@ class LocMemCacheTests(BaseCacheTests, TestCase):
|
||||
},
|
||||
})
|
||||
def test_multiple_caches(self):
|
||||
"Check that multiple locmem caches are isolated"
|
||||
"Multiple locmem caches are isolated"
|
||||
cache.set('value', 42)
|
||||
self.assertEqual(caches['default'].get('value'), 42)
|
||||
self.assertIsNone(caches['other'].get('value'))
|
||||
@ -1432,10 +1432,9 @@ NEVER_EXPIRING_CACHES_SETTINGS['default']['TIMEOUT'] = None
|
||||
|
||||
|
||||
class DefaultNonExpiringCacheKeyTests(SimpleTestCase):
|
||||
"""Tests that verify that settings having Cache arguments with a TIMEOUT
|
||||
set to `None` will create Caches that will set non-expiring keys.
|
||||
|
||||
This fixes ticket #22085.
|
||||
"""
|
||||
Settings having Cache arguments with a TIMEOUT=None create Caches that will
|
||||
set non-expiring keys.
|
||||
"""
|
||||
def setUp(self):
|
||||
# The 5 minute (300 seconds) default expiration time for keys is
|
||||
@ -1449,8 +1448,8 @@ class DefaultNonExpiringCacheKeyTests(SimpleTestCase):
|
||||
def test_default_expiration_time_for_keys_is_5_minutes(self):
|
||||
"""The default expiration time of a cache key is 5 minutes.
|
||||
|
||||
This value is defined inside the __init__() method of the
|
||||
:class:`django.core.cache.backends.base.BaseCache` type.
|
||||
This value is defined in
|
||||
django.core.cache.backends.base.BaseCache.__init__().
|
||||
"""
|
||||
self.assertEqual(300, self.DEFAULT_TIMEOUT)
|
||||
|
||||
@ -1563,7 +1562,7 @@ class CacheUtils(SimpleTestCase):
|
||||
'views.decorators.cache.cache_page.settingsprefix.GET.'
|
||||
'18a03f9c9649f7d684af5db3524f5c99.d41d8cd98f00b204e9800998ecf8427e'
|
||||
)
|
||||
# Verify that a specified key_prefix is taken into account.
|
||||
# A specified key_prefix is taken into account.
|
||||
key_prefix = 'localprefix'
|
||||
learn_cache_key(request, response, key_prefix=key_prefix)
|
||||
self.assertEqual(
|
||||
@ -1579,8 +1578,7 @@ class CacheUtils(SimpleTestCase):
|
||||
self.assertIsNone(get_cache_key(request))
|
||||
# Set headers to an empty list.
|
||||
learn_cache_key(request, response)
|
||||
# Verify that the querystring is taken into account.
|
||||
|
||||
# The querystring is taken into account.
|
||||
self.assertEqual(
|
||||
get_cache_key(request),
|
||||
'views.decorators.cache.cache_page.settingsprefix.GET.'
|
||||
@ -1898,12 +1896,12 @@ class CacheI18nTest(TestCase):
|
||||
request._cache_update_cache = True
|
||||
set_cache(request, 'en', en_message)
|
||||
get_cache_data = FetchFromCacheMiddleware().process_request(request)
|
||||
# Check that we can recover the cache
|
||||
# The cache can be recovered
|
||||
self.assertIsNotNone(get_cache_data)
|
||||
self.assertEqual(get_cache_data.content, en_message.encode())
|
||||
# Check that we use etags
|
||||
# ETags are used.
|
||||
self.assertTrue(get_cache_data.has_header('ETag'))
|
||||
# Check that we can disable etags
|
||||
# ETags can be disabled.
|
||||
with self.settings(USE_ETAGS=False):
|
||||
request._cache_update_cache = True
|
||||
set_cache(request, 'en', en_message)
|
||||
@ -2229,7 +2227,7 @@ class TestWithTemplateResponse(SimpleTestCase):
|
||||
'views.decorators.cache.cache_page.settingsprefix.GET.'
|
||||
'58a0a05c8a5620f813686ff969c26853.d41d8cd98f00b204e9800998ecf8427e'
|
||||
)
|
||||
# Verify that a specified key_prefix is taken into account.
|
||||
# A specified key_prefix is taken into account.
|
||||
learn_cache_key(request, response, key_prefix=key_prefix)
|
||||
self.assertEqual(
|
||||
get_cache_key(request, key_prefix=key_prefix),
|
||||
@ -2245,7 +2243,7 @@ class TestWithTemplateResponse(SimpleTestCase):
|
||||
self.assertIsNone(get_cache_key(request))
|
||||
# Set headers to an empty list.
|
||||
learn_cache_key(request, response)
|
||||
# Verify that the querystring is taken into account.
|
||||
# The querystring is taken into account.
|
||||
self.assertEqual(
|
||||
get_cache_key(request),
|
||||
'views.decorators.cache.cache_page.settingsprefix.GET.'
|
||||
|
@ -166,11 +166,10 @@ class ContentTypesTests(TestCase):
|
||||
@override_settings(ALLOWED_HOSTS=['example.com'])
|
||||
def test_shortcut_view(self):
|
||||
"""
|
||||
Check that the shortcut view (used for the admin "view on site"
|
||||
functionality) returns a complete URL regardless of whether the sites
|
||||
framework is installed
|
||||
The shortcut view (used for the admin "view on site" functionality)
|
||||
returns a complete URL regardless of whether the sites framework is
|
||||
installed.
|
||||
"""
|
||||
|
||||
request = HttpRequest()
|
||||
request.META = {
|
||||
"SERVER_NAME": "Example.com",
|
||||
@ -192,10 +191,9 @@ class ContentTypesTests(TestCase):
|
||||
|
||||
def test_shortcut_view_without_get_absolute_url(self):
|
||||
"""
|
||||
Check that the shortcut view (used for the admin "view on site"
|
||||
functionality) returns 404 when get_absolute_url is not defined.
|
||||
The shortcut view (used for the admin "view on site" functionality)
|
||||
returns 404 when get_absolute_url is not defined.
|
||||
"""
|
||||
|
||||
request = HttpRequest()
|
||||
request.META = {
|
||||
"SERVER_NAME": "Example.com",
|
||||
@ -209,9 +207,8 @@ class ContentTypesTests(TestCase):
|
||||
|
||||
def test_shortcut_view_with_broken_get_absolute_url(self):
|
||||
"""
|
||||
Check that the shortcut view does not catch an AttributeError raised
|
||||
by the model's get_absolute_url method.
|
||||
Refs #8997.
|
||||
The shortcut view does not catch an AttributeError raised by
|
||||
the model's get_absolute_url() method (#8997).
|
||||
"""
|
||||
request = HttpRequest()
|
||||
request.META = {
|
||||
@ -226,9 +223,9 @@ class ContentTypesTests(TestCase):
|
||||
|
||||
def test_missing_model(self):
|
||||
"""
|
||||
Ensures that displaying content types in admin (or anywhere) doesn't
|
||||
break on leftover content type records in the DB for which no model
|
||||
is defined anymore.
|
||||
Displaying content types in admin (or anywhere) doesn't break on
|
||||
leftover content type records in the DB for which no model is defined
|
||||
anymore.
|
||||
"""
|
||||
ct = ContentType.objects.create(
|
||||
app_label='contenttypes',
|
||||
|
@ -466,8 +466,8 @@ class ContentTypesMultidbTestCase(TestCase):
|
||||
|
||||
def test_multidb(self):
|
||||
"""
|
||||
Test that, when using multiple databases, we use the db_for_read (see
|
||||
#20401).
|
||||
When using multiple databases, ContentType.objects.get_for_model() uses
|
||||
db_for_read().
|
||||
"""
|
||||
ContentType.objects.clear_cache()
|
||||
|
||||
|
@ -23,7 +23,7 @@ class RequestContextProcessorTests(SimpleTestCase):
|
||||
|
||||
def test_request_attributes(self):
|
||||
"""
|
||||
Test that the request object is available in the template and that its
|
||||
The request object is available in the template and that its
|
||||
attributes can't be overridden by GET and POST parameters (#3828).
|
||||
"""
|
||||
url = '/request_attrs/'
|
||||
|
@ -180,7 +180,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_process_response_get_token_not_used(self):
|
||||
"""
|
||||
Check that if get_token() is not called, the view middleware does not
|
||||
If get_token() is not called, the view middleware does not
|
||||
add a cookie.
|
||||
"""
|
||||
# This is important to make pages cacheable. Pages which do call
|
||||
@ -201,8 +201,8 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
# Check the request processing
|
||||
def test_process_request_no_csrf_cookie(self):
|
||||
"""
|
||||
Check that if no CSRF cookies is present, the middleware rejects the
|
||||
incoming request. This will stop login CSRF.
|
||||
If no CSRF cookies is present, the middleware rejects the incoming
|
||||
request. This will stop login CSRF.
|
||||
"""
|
||||
with patch_logger('django.security.csrf', 'warning') as logger_calls:
|
||||
req = self._get_POST_no_csrf_cookie_request()
|
||||
@ -212,8 +212,8 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_process_request_csrf_cookie_no_token(self):
|
||||
"""
|
||||
Check that if a CSRF cookie is present but no token, the middleware
|
||||
rejects the incoming request.
|
||||
If a CSRF cookie is present but no token, the middleware rejects
|
||||
the incoming request.
|
||||
"""
|
||||
with patch_logger('django.security.csrf', 'warning') as logger_calls:
|
||||
req = self._get_POST_csrf_cookie_request()
|
||||
@ -223,7 +223,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_process_request_csrf_cookie_and_token(self):
|
||||
"""
|
||||
Check that if both a cookie and a token is present, the middleware lets it through.
|
||||
If both a cookie and a token is present, the middleware lets it through.
|
||||
"""
|
||||
req = self._get_POST_request_with_token()
|
||||
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
|
||||
@ -231,8 +231,8 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_process_request_csrf_cookie_no_token_exempt_view(self):
|
||||
"""
|
||||
Check that if a CSRF cookie is present and no token, but the csrf_exempt
|
||||
decorator has been applied to the view, the middleware lets it through
|
||||
If a CSRF cookie is present and no token, but the csrf_exempt decorator
|
||||
has been applied to the view, the middleware lets it through
|
||||
"""
|
||||
req = self._get_POST_csrf_cookie_request()
|
||||
req2 = CsrfViewMiddleware().process_view(req, csrf_exempt(post_form_view), (), {})
|
||||
@ -240,7 +240,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_csrf_token_in_header(self):
|
||||
"""
|
||||
Check that we can pass in the token in a header instead of in the form
|
||||
The token may be passed in a header instead of in the form.
|
||||
"""
|
||||
req = self._get_POST_csrf_cookie_request()
|
||||
req.META['HTTP_X_CSRFTOKEN'] = self._csrf_id
|
||||
@ -259,7 +259,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_put_and_delete_rejected(self):
|
||||
"""
|
||||
Tests that HTTP PUT and DELETE methods have protection
|
||||
HTTP PUT and DELETE methods have protection
|
||||
"""
|
||||
req = TestingHttpRequest()
|
||||
req.method = 'PUT'
|
||||
@ -277,8 +277,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_put_and_delete_allowed(self):
|
||||
"""
|
||||
Tests that HTTP PUT and DELETE methods can get through with
|
||||
X-CSRFToken and a cookie
|
||||
HTTP PUT and DELETE can get through with X-CSRFToken and a cookie.
|
||||
"""
|
||||
req = self._get_GET_csrf_cookie_request()
|
||||
req.method = 'PUT'
|
||||
@ -295,7 +294,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
# Tests for the template tag method
|
||||
def test_token_node_no_csrf_cookie(self):
|
||||
"""
|
||||
Check that CsrfTokenNode works when no CSRF cookie is set
|
||||
CsrfTokenNode works when no CSRF cookie is set.
|
||||
"""
|
||||
req = self._get_GET_no_csrf_cookie_request()
|
||||
resp = token_view(req)
|
||||
@ -306,7 +305,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_token_node_empty_csrf_cookie(self):
|
||||
"""
|
||||
Check that we get a new token if the csrf_cookie is the empty string
|
||||
A new token is sent if the csrf_cookie is the empty string.
|
||||
"""
|
||||
req = self._get_GET_no_csrf_cookie_request()
|
||||
req.COOKIES[settings.CSRF_COOKIE_NAME] = b""
|
||||
@ -319,7 +318,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_token_node_with_csrf_cookie(self):
|
||||
"""
|
||||
Check that CsrfTokenNode works when a CSRF cookie is set
|
||||
CsrfTokenNode works when a CSRF cookie is set.
|
||||
"""
|
||||
req = self._get_GET_csrf_cookie_request()
|
||||
CsrfViewMiddleware().process_view(req, token_view, (), {})
|
||||
@ -328,7 +327,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_get_token_for_exempt_view(self):
|
||||
"""
|
||||
Check that get_token still works for a view decorated with 'csrf_exempt'.
|
||||
get_token still works for a view decorated with 'csrf_exempt'.
|
||||
"""
|
||||
req = self._get_GET_csrf_cookie_request()
|
||||
CsrfViewMiddleware().process_view(req, csrf_exempt(token_view), (), {})
|
||||
@ -337,7 +336,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_get_token_for_requires_csrf_token_view(self):
|
||||
"""
|
||||
Check that get_token works for a view decorated solely with requires_csrf_token
|
||||
get_token() works for a view decorated solely with requires_csrf_token.
|
||||
"""
|
||||
req = self._get_GET_csrf_cookie_request()
|
||||
resp = requires_csrf_token(token_view)(req)
|
||||
@ -345,7 +344,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
|
||||
def test_token_node_with_new_csrf_cookie(self):
|
||||
"""
|
||||
Check that CsrfTokenNode works when a CSRF cookie is created by
|
||||
CsrfTokenNode works when a CSRF cookie is created by
|
||||
the middleware (when one was not already present)
|
||||
"""
|
||||
req = self._get_GET_no_csrf_cookie_request()
|
||||
@ -389,7 +388,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase):
|
||||
@override_settings(DEBUG=True, ALLOWED_HOSTS=['www.example.com'])
|
||||
def test_https_bad_referer(self):
|
||||
"""
|
||||
Test that a POST HTTPS request with a bad referer is rejected
|
||||
A POST HTTPS request with a bad referer is rejected
|
||||
"""
|
||||
req = self._get_POST_request_with_token()
|
||||
req._is_secure_override = True
|
||||
|
@ -72,7 +72,7 @@ class CustomManagerTests(TestCase):
|
||||
self.assertQuerysetEqual(queryset, ["Bugs Bunny"], six.text_type)
|
||||
self.assertIs(queryset._filter_CustomQuerySet, True)
|
||||
|
||||
# Test that specialized querysets inherit from our custom queryset.
|
||||
# Specialized querysets inherit from our custom queryset.
|
||||
queryset = manager.values_list('first_name', flat=True).filter()
|
||||
self.assertEqual(list(queryset), [six.text_type("Bugs")])
|
||||
self.assertIs(queryset._filter_CustomQuerySet, True)
|
||||
@ -283,7 +283,7 @@ class CustomManagerTests(TestCase):
|
||||
Person.objects.create(first_name="Bugs", last_name="Bunny", fun=True, favorite_book=self.b1)
|
||||
droopy = Person.objects.create(first_name="Droopy", last_name="Dog", fun=False, favorite_book=self.b1)
|
||||
|
||||
# Check that the fun manager DOESN'T remove boring people.
|
||||
# The fun manager DOESN'T remove boring people.
|
||||
self.b1.favorite_books(manager='fun_people').remove(droopy, bulk=bulk)
|
||||
self.assertQuerysetEqual(
|
||||
self.b1.favorite_books(manager='boring_people').all(), [
|
||||
@ -292,7 +292,7 @@ class CustomManagerTests(TestCase):
|
||||
lambda c: c.first_name,
|
||||
ordered=False,
|
||||
)
|
||||
# Check that the boring manager DOES remove boring people.
|
||||
# The boring manager DOES remove boring people.
|
||||
self.b1.favorite_books(manager='boring_people').remove(droopy, bulk=bulk)
|
||||
self.assertQuerysetEqual(
|
||||
self.b1.favorite_books(manager='boring_people').all(), [
|
||||
@ -303,7 +303,7 @@ class CustomManagerTests(TestCase):
|
||||
droopy.favorite_book = self.b1
|
||||
droopy.save()
|
||||
|
||||
# Check that the fun manager ONLY clears fun people.
|
||||
# The fun manager ONLY clears fun people.
|
||||
self.b1.favorite_books(manager='fun_people').clear(bulk=bulk)
|
||||
self.assertQuerysetEqual(
|
||||
self.b1.favorite_books(manager='boring_people').all(), [
|
||||
@ -363,7 +363,7 @@ class CustomManagerTests(TestCase):
|
||||
Person.objects.create(first_name="Bugs", last_name="Bunny", fun=True, favorite_thing=self.b1)
|
||||
droopy = Person.objects.create(first_name="Droopy", last_name="Dog", fun=False, favorite_thing=self.b1)
|
||||
|
||||
# Check that the fun manager DOESN'T remove boring people.
|
||||
# The fun manager DOESN'T remove boring people.
|
||||
self.b1.favorite_things(manager='fun_people').remove(droopy, bulk=bulk)
|
||||
self.assertQuerysetEqual(
|
||||
self.b1.favorite_things(manager='boring_people').all(), [
|
||||
@ -373,7 +373,7 @@ class CustomManagerTests(TestCase):
|
||||
ordered=False,
|
||||
)
|
||||
|
||||
# Check that the boring manager DOES remove boring people.
|
||||
# The boring manager DOES remove boring people.
|
||||
self.b1.favorite_things(manager='boring_people').remove(droopy, bulk=bulk)
|
||||
self.assertQuerysetEqual(
|
||||
self.b1.favorite_things(manager='boring_people').all(), [
|
||||
@ -384,7 +384,7 @@ class CustomManagerTests(TestCase):
|
||||
droopy.favorite_thing = self.b1
|
||||
droopy.save()
|
||||
|
||||
# Check that the fun manager ONLY clears fun people.
|
||||
# The fun manager ONLY clears fun people.
|
||||
self.b1.favorite_things(manager='fun_people').clear(bulk=bulk)
|
||||
self.assertQuerysetEqual(
|
||||
self.b1.favorite_things(manager='boring_people').all(), [
|
||||
@ -444,7 +444,7 @@ class CustomManagerTests(TestCase):
|
||||
droopy = Person.objects.create(first_name="Droopy", last_name="Dog", fun=False)
|
||||
self.b1.authors.add(droopy)
|
||||
|
||||
# Check that the fun manager DOESN'T remove boring people.
|
||||
# The fun manager DOESN'T remove boring people.
|
||||
self.b1.authors(manager='fun_people').remove(droopy)
|
||||
self.assertQuerysetEqual(
|
||||
self.b1.authors(manager='boring_people').all(), [
|
||||
@ -454,7 +454,7 @@ class CustomManagerTests(TestCase):
|
||||
ordered=False,
|
||||
)
|
||||
|
||||
# Check that the boring manager DOES remove boring people.
|
||||
# The boring manager DOES remove boring people.
|
||||
self.b1.authors(manager='boring_people').remove(droopy)
|
||||
self.assertQuerysetEqual(
|
||||
self.b1.authors(manager='boring_people').all(), [
|
||||
@ -464,7 +464,7 @@ class CustomManagerTests(TestCase):
|
||||
)
|
||||
self.b1.authors.add(droopy)
|
||||
|
||||
# Check that the fun manager ONLY clears fun people.
|
||||
# The fun manager ONLY clears fun people.
|
||||
self.b1.authors(manager='fun_people').clear()
|
||||
self.assertQuerysetEqual(
|
||||
self.b1.authors(manager='boring_people').all(), [
|
||||
|
@ -87,8 +87,7 @@ class DecoratorsTest(TestCase):
|
||||
|
||||
def test_attributes(self):
|
||||
"""
|
||||
Tests that django decorators set certain attributes of the wrapped
|
||||
function.
|
||||
Built-in decorators set certain attributes of the wrapped function.
|
||||
"""
|
||||
self.assertEqual(fully_decorated.__name__, 'fully_decorated')
|
||||
self.assertEqual(fully_decorated.__doc__, 'Expected __doc__')
|
||||
@ -96,8 +95,7 @@ class DecoratorsTest(TestCase):
|
||||
|
||||
def test_user_passes_test_composition(self):
|
||||
"""
|
||||
Test that the user_passes_test decorator can be applied multiple times
|
||||
(#9474).
|
||||
The user_passes_test decorator can be applied multiple times (#9474).
|
||||
"""
|
||||
def test1(user):
|
||||
user.decorators_applied.append('test1')
|
||||
@ -126,10 +124,7 @@ class DecoratorsTest(TestCase):
|
||||
|
||||
self.assertEqual(response, ['test2', 'test1'])
|
||||
|
||||
def test_cache_page_new_style(self):
|
||||
"""
|
||||
Test that we can call cache_page the new way
|
||||
"""
|
||||
def test_cache_page(self):
|
||||
def my_view(request):
|
||||
return "response"
|
||||
my_view_cached = cache_page(123)(my_view)
|
||||
|
@ -227,8 +227,7 @@ class TestDefer2(AssertionMixin, TestCase):
|
||||
"""
|
||||
When an inherited model is fetched from the DB, its PK is also fetched.
|
||||
When getting the PK of the parent model it is useful to use the already
|
||||
fetched parent model PK if it happens to be available. Tests that this
|
||||
is done.
|
||||
fetched parent model PK if it happens to be available.
|
||||
"""
|
||||
s1 = Secondary.objects.create(first="x1", second="y1")
|
||||
bc = BigChild.objects.create(name="b1", value="foo", related=s1,
|
||||
|
@ -83,7 +83,7 @@ class OnDeleteTests(TestCase):
|
||||
|
||||
def test_do_nothing_qscount(self):
|
||||
"""
|
||||
Test that a models.DO_NOTHING relation doesn't trigger a query.
|
||||
A models.DO_NOTHING relation doesn't trigger a query.
|
||||
"""
|
||||
b = Base.objects.create()
|
||||
with self.assertNumQueries(1):
|
||||
|
@ -349,9 +349,9 @@ class BasicExpressionsTests(TestCase):
|
||||
self.assertSequenceEqual(qs, [e2, e3])
|
||||
|
||||
def test_ticket_18375_join_reuse(self):
|
||||
# Test that reverse multijoin F() references and the lookup target
|
||||
# the same join. Pre #18375 the F() join was generated first, and the
|
||||
# lookup couldn't reuse that join.
|
||||
# Reverse multijoin F() references and the lookup target the same join.
|
||||
# Pre #18375 the F() join was generated first and the lookup couldn't
|
||||
# reuse that join.
|
||||
qs = Employee.objects.filter(
|
||||
company_ceo_set__num_chairs=F('company_ceo_set__num_employees'))
|
||||
self.assertEqual(str(qs.query).count('JOIN'), 1)
|
||||
@ -379,7 +379,7 @@ class BasicExpressionsTests(TestCase):
|
||||
self.assertEqual(str(qs.query).count('JOIN'), 1)
|
||||
|
||||
def test_ticket_18375_chained_filters(self):
|
||||
# Test that F() expressions do not reuse joins from previous filter.
|
||||
# F() expressions do not reuse joins from previous filter.
|
||||
qs = Employee.objects.filter(
|
||||
company_ceo_set__num_employees=F('pk')
|
||||
).filter(
|
||||
@ -553,7 +553,7 @@ class ExpressionsTests(TestCase):
|
||||
|
||||
def test_patterns_escape(self):
|
||||
r"""
|
||||
Test that special characters (e.g. %, _ and \) stored in database are
|
||||
Special characters (e.g. %, _ and \) stored in database are
|
||||
properly escaped when using a pattern lookup with an expression
|
||||
refs #16731
|
||||
"""
|
||||
@ -585,7 +585,7 @@ class ExpressionsTests(TestCase):
|
||||
|
||||
def test_insensitive_patterns_escape(self):
|
||||
r"""
|
||||
Test that special characters (e.g. %, _ and \) stored in database are
|
||||
Special characters (e.g. %, _ and \) stored in database are
|
||||
properly escaped when using a case insensitive pattern lookup with an
|
||||
expression -- refs #16731
|
||||
"""
|
||||
|
@ -395,7 +395,7 @@ class ExtraRegressTests(TestCase):
|
||||
|
||||
def test_regression_17877(self):
|
||||
"""
|
||||
Ensure that extra WHERE clauses get correctly ANDed, even when they
|
||||
Extra WHERE clauses get correctly ANDed, even when they
|
||||
contain OR operations.
|
||||
"""
|
||||
# Test Case 1: should appear in queryset.
|
||||
|
@ -161,7 +161,7 @@ class FileStorageTests(SimpleTestCase):
|
||||
self.assertTrue(timezone.is_aware(dt))
|
||||
self.assertEqual(now.tzname(), dt.tzname())
|
||||
|
||||
# Check that the three timezones are indeed distinct.
|
||||
# The three timezones are indeed distinct.
|
||||
naive_now = datetime.now()
|
||||
algiers_offset = now_in_algiers.tzinfo.utcoffset(naive_now)
|
||||
django_offset = timezone.get_current_timezone().utcoffset(naive_now)
|
||||
@ -192,7 +192,7 @@ class FileStorageTests(SimpleTestCase):
|
||||
# dt should be naive, in system (+1) TZ
|
||||
self.assertTrue(timezone.is_naive(dt))
|
||||
|
||||
# Check that the three timezones are indeed distinct.
|
||||
# The three timezones are indeed distinct.
|
||||
naive_now = datetime.now()
|
||||
algiers_offset = now_in_algiers.tzinfo.utcoffset(naive_now)
|
||||
django_offset = timezone.get_current_timezone().utcoffset(naive_now)
|
||||
@ -484,7 +484,7 @@ class FileStorageTests(SimpleTestCase):
|
||||
with self.storage.open('raced/test.file') as f:
|
||||
self.assertEqual(f.read(), b'saved with race')
|
||||
|
||||
# Check that OSErrors aside from EEXIST are still raised.
|
||||
# OSErrors aside from EEXIST are still raised.
|
||||
with self.assertRaises(OSError):
|
||||
self.storage.save('error/test.file', ContentFile('not saved'))
|
||||
finally:
|
||||
@ -520,7 +520,7 @@ class FileStorageTests(SimpleTestCase):
|
||||
self.storage.delete('raced.file')
|
||||
self.assertFalse(self.storage.exists('normal.file'))
|
||||
|
||||
# Check that OSErrors aside from ENOENT are still raised.
|
||||
# OSErrors aside from ENOENT are still raised.
|
||||
self.storage.save('error.file', ContentFile('delete with error'))
|
||||
with self.assertRaises(OSError):
|
||||
self.storage.delete('error.file')
|
||||
@ -988,8 +988,9 @@ class ContentFileStorageTestCase(unittest.TestCase):
|
||||
|
||||
def test_content_saving(self):
|
||||
"""
|
||||
Test that ContentFile can be saved correctly with the filesystem storage,
|
||||
both if it was initialized with string or unicode content"""
|
||||
ContentFile can be saved correctly with the filesystem storage,
|
||||
if it was initialized with either bytes or unicode content.
|
||||
"""
|
||||
self.storage.save('bytes.txt', ContentFile(b"content"))
|
||||
self.storage.save('unicode.txt', ContentFile("español"))
|
||||
|
||||
|
@ -450,7 +450,7 @@ class FileUploadTests(TestCase):
|
||||
})
|
||||
|
||||
request = response.wsgi_request
|
||||
# Check that the files got actually parsed.
|
||||
# The files were parsed.
|
||||
self.assertTrue(hasattr(request, '_files'))
|
||||
|
||||
file = request._files['file']
|
||||
@ -469,7 +469,7 @@ class FileUploadTests(TestCase):
|
||||
})
|
||||
|
||||
request = response.wsgi_request
|
||||
# Check that the fd closing logic doesn't trigger parsing of the stream
|
||||
# The fd closing logic doesn't trigger parsing of the stream
|
||||
self.assertFalse(hasattr(request, '_files'))
|
||||
|
||||
def test_file_error_blocking(self):
|
||||
|
@ -17,8 +17,7 @@ from .uploadhandler import ErroringUploadHandler, QuotaUploadHandler
|
||||
|
||||
def file_upload_view(request):
|
||||
"""
|
||||
Check that a file upload can be updated into the POST dictionary without
|
||||
going pear-shaped.
|
||||
A file upload can be updated into the POST dictionary.
|
||||
"""
|
||||
form_data = request.POST.copy()
|
||||
form_data.update(request.FILES)
|
||||
|
@ -173,14 +173,14 @@ class ContentFileTestCase(unittest.TestCase):
|
||||
|
||||
def test_content_file_custom_name(self):
|
||||
"""
|
||||
Test that the constructor of ContentFile accepts 'name' (#16590).
|
||||
The constructor of ContentFile accepts 'name' (#16590).
|
||||
"""
|
||||
name = "I can have a name too!"
|
||||
self.assertEqual(ContentFile(b"content", name=name).name, name)
|
||||
|
||||
def test_content_file_input_type(self):
|
||||
"""
|
||||
Test that ContentFile can accept both bytes and unicode and that the
|
||||
ContentFile can accept both bytes and unicode and that the
|
||||
retrieved content is of the same type.
|
||||
"""
|
||||
self.assertIsInstance(ContentFile(b"content").read(), bytes)
|
||||
@ -192,7 +192,7 @@ class ContentFileTestCase(unittest.TestCase):
|
||||
|
||||
class DimensionClosingBug(unittest.TestCase):
|
||||
"""
|
||||
Test that get_image_dimensions() properly closes files (#8817)
|
||||
get_image_dimensions() properly closes files (#8817)
|
||||
"""
|
||||
@unittest.skipUnless(Image, "Pillow not installed")
|
||||
def test_not_closing_of_files(self):
|
||||
@ -242,7 +242,7 @@ class DimensionClosingBug(unittest.TestCase):
|
||||
|
||||
class InconsistentGetImageDimensionsBug(unittest.TestCase):
|
||||
"""
|
||||
Test that get_image_dimensions() works properly after various calls
|
||||
get_image_dimensions() works properly after various calls
|
||||
using a file handler (#11158)
|
||||
"""
|
||||
@unittest.skipUnless(Image, "Pillow not installed")
|
||||
|
12
tests/fixtures/tests.py
vendored
12
tests/fixtures/tests.py
vendored
@ -29,7 +29,7 @@ class TestCaseFixtureLoadingTests(TestCase):
|
||||
fixtures = ['fixture1.json', 'fixture2.json']
|
||||
|
||||
def testClassFixtures(self):
|
||||
"Check that test case has installed 3 fixture objects"
|
||||
"Test case has installed 3 fixture objects"
|
||||
self.assertEqual(Article.objects.count(), 3)
|
||||
self.assertQuerysetEqual(Article.objects.all(), [
|
||||
'<Article: Django conquers world!>',
|
||||
@ -45,7 +45,7 @@ class SubclassTestCaseFixtureLoadingTests(TestCaseFixtureLoadingTests):
|
||||
fixtures = []
|
||||
|
||||
def testClassFixtures(self):
|
||||
"Check that there were no fixture objects installed"
|
||||
"There were no fixture objects installed"
|
||||
self.assertEqual(Article.objects.count(), 0)
|
||||
|
||||
|
||||
@ -563,9 +563,8 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
|
||||
|
||||
def test_loaddata_error_message(self):
|
||||
"""
|
||||
Verifies that loading a fixture which contains an invalid object
|
||||
outputs an error message which contains the pk of the object
|
||||
that triggered the error.
|
||||
Loading a fixture which contains an invalid object outputs an error
|
||||
message which contains the pk of the object that triggered the error.
|
||||
"""
|
||||
# MySQL needs a little prodding to reject invalid data.
|
||||
# This won't affect other tests because the database connection
|
||||
@ -577,9 +576,6 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
|
||||
self.assertIn("Could not load fixtures.Article(pk=1):", cm.exception.args[0])
|
||||
|
||||
def test_loaddata_app_option(self):
|
||||
"""
|
||||
Verifies that the --app option works.
|
||||
"""
|
||||
with self.assertRaisesMessage(CommandError, "No fixture named 'db_fixture_1' found."):
|
||||
management.call_command('loaddata', 'db_fixture_1', verbosity=0, app_label="someotherapp")
|
||||
self.assertQuerysetEqual(Article.objects.all(), [])
|
||||
|
@ -212,7 +212,7 @@ class TestFixtures(TestCase):
|
||||
@override_settings(SERIALIZATION_MODULES={'unkn': 'unexistent.path'})
|
||||
def test_unimportable_serializer(self):
|
||||
"""
|
||||
Test that failing serializer import raises the proper error
|
||||
Failing serializer import raises the proper error
|
||||
"""
|
||||
with six.assertRaisesRegex(self, ImportError, r"No module named.*unexistent"):
|
||||
management.call_command(
|
||||
@ -363,8 +363,8 @@ class TestFixtures(TestCase):
|
||||
def test_dumpdata_uses_default_manager(self):
|
||||
"""
|
||||
Regression for #11286
|
||||
Ensure that dumpdata honors the default manager
|
||||
Dump the current contents of the database as a JSON fixture
|
||||
Dumpdata honors the default manager. Dump the current contents of
|
||||
the database as a JSON fixture
|
||||
"""
|
||||
management.call_command(
|
||||
'loaddata',
|
||||
@ -617,8 +617,7 @@ class NaturalKeyFixtureTests(TestCase):
|
||||
|
||||
def test_nk_on_serialize(self):
|
||||
"""
|
||||
Check that natural key requirements are taken into account
|
||||
when serializing models
|
||||
Natural key requirements are taken into account when serializing models.
|
||||
"""
|
||||
management.call_command(
|
||||
'loaddata',
|
||||
@ -651,10 +650,8 @@ class NaturalKeyFixtureTests(TestCase):
|
||||
|
||||
def test_dependency_sorting(self):
|
||||
"""
|
||||
Now lets check the dependency sorting explicitly
|
||||
It doesn't matter what order you mention the models
|
||||
Store *must* be serialized before then Person, and both
|
||||
must be serialized before Book.
|
||||
It doesn't matter what order you mention the models, Store *must* be
|
||||
serialized before then Person, and both must be serialized before Book.
|
||||
"""
|
||||
sorted_deps = serializers.sort_dependencies(
|
||||
[('fixtures_regress', [Book, Person, Store])]
|
||||
@ -762,8 +759,7 @@ class NaturalKeyFixtureTests(TestCase):
|
||||
|
||||
def test_normal_pk(self):
|
||||
"""
|
||||
Check that normal primary keys still work
|
||||
on a model with natural key capabilities
|
||||
Normal primary keys work on a model with natural key capabilities.
|
||||
"""
|
||||
management.call_command(
|
||||
'loaddata',
|
||||
@ -900,7 +896,7 @@ class TestTicket11101(TransactionTestCase):
|
||||
|
||||
@skipUnlessDBFeature('supports_transactions')
|
||||
def test_ticket_11101(self):
|
||||
"""Test that fixtures can be rolled back (ticket #11101)."""
|
||||
"""Fixtures can be rolled back (ticket #11101)."""
|
||||
with transaction.atomic():
|
||||
management.call_command(
|
||||
'loaddata',
|
||||
|
@ -17,7 +17,7 @@ class RestrictedConditionsTests(TestCase):
|
||||
|
||||
def test_restrictions_with_no_joining_columns(self):
|
||||
"""
|
||||
Test that it's possible to create a working related field that doesn't
|
||||
It's possible to create a working related field that doesn't
|
||||
use any joining columns, as long as an extra restriction is supplied.
|
||||
"""
|
||||
a = SlugPage.objects.get(slug='a')
|
||||
|
@ -398,7 +398,6 @@ class MultiColumnFKTests(TestCase):
|
||||
|
||||
@skipUnlessDBFeature('has_bulk_insert')
|
||||
def test_batch_create_foreign_object(self):
|
||||
""" See: https://code.djangoproject.com/ticket/21566 """
|
||||
objs = [Person(name="abcd_%s" % i, person_country=self.usa) for i in range(0, 5)]
|
||||
Person.objects.bulk_create(objs, 10)
|
||||
|
||||
|
@ -8,7 +8,7 @@ import uuid
|
||||
|
||||
from django.core.exceptions import NON_FIELD_ERRORS
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.core.validators import RegexValidator
|
||||
from django.core.validators import MaxValueValidator, RegexValidator
|
||||
from django.forms import (
|
||||
BooleanField, CharField, CheckboxSelectMultiple, ChoiceField, DateField,
|
||||
DateTimeField, EmailField, FileField, FloatField, Form, HiddenInput,
|
||||
@ -1134,7 +1134,7 @@ value="Should escape < & > and <script>alert('xss')</
|
||||
except ValidationError as e:
|
||||
self._errors = e.update_error_dict(self._errors)
|
||||
|
||||
# Ensure that the newly added list of errors is an instance of ErrorList.
|
||||
# The newly added list of errors is an instance of ErrorList.
|
||||
for field, error_list in self._errors.items():
|
||||
if not isinstance(error_list, self.error_class):
|
||||
self._errors[field] = self.error_class(error_list)
|
||||
@ -1143,7 +1143,7 @@ value="Should escape < & > and <script>alert('xss')</
|
||||
# Trigger validation.
|
||||
self.assertFalse(form.is_valid())
|
||||
|
||||
# Check that update_error_dict didn't lose track of the ErrorDict type.
|
||||
# update_error_dict didn't lose track of the ErrorDict type.
|
||||
self.assertIsInstance(form._errors, forms.ErrorDict)
|
||||
|
||||
self.assertEqual(dict(form.errors), {
|
||||
@ -1325,10 +1325,10 @@ value="Should escape < & > and <script>alert('xss')</
|
||||
self.assertEqual(f['gender'].field.choices, [('f', 'Female'), ('m', 'Male')])
|
||||
|
||||
def test_validators_independence(self):
|
||||
""" Test that we are able to modify a form field validators list without polluting
|
||||
other forms """
|
||||
from django.core.validators import MaxValueValidator
|
||||
|
||||
"""
|
||||
The list of form field validators can be modified without polluting
|
||||
other forms.
|
||||
"""
|
||||
class MyForm(Form):
|
||||
myfield = CharField(max_length=25)
|
||||
|
||||
@ -1931,7 +1931,7 @@ Password: <input type="password" name="password" required /></li>
|
||||
self.assertIn('last_name', p.changed_data)
|
||||
self.assertNotIn('birthday', p.changed_data)
|
||||
|
||||
# Test that field raising ValidationError is always in changed_data
|
||||
# A field raising ValidationError is always in changed_data
|
||||
class PedanticField(forms.Field):
|
||||
def to_python(self, value):
|
||||
raise ValidationError('Whatever')
|
||||
@ -1990,7 +1990,7 @@ Password: <input type="password" name="password" required /></li>
|
||||
|
||||
def test_boundfield_rendering(self):
|
||||
"""
|
||||
Python 2 issue: Test that rendering a BoundField with bytestring content
|
||||
Python 2 issue: Rendering a BoundField with bytestring content
|
||||
doesn't lose it's safe string status (#22950).
|
||||
"""
|
||||
class CustomWidget(TextInput):
|
||||
@ -2937,7 +2937,7 @@ Good luck picking a username that doesn't already exist.</p>
|
||||
|
||||
def test_custom_empty_values(self):
|
||||
"""
|
||||
Test that form fields can customize what is considered as an empty value
|
||||
Form fields can customize what is considered as an empty value
|
||||
for themselves (#19997).
|
||||
"""
|
||||
class CustomJSONField(CharField):
|
||||
|
@ -128,7 +128,7 @@ class FormsFormsetTestCase(SimpleTestCase):
|
||||
|
||||
def test_form_kwargs_formset(self):
|
||||
"""
|
||||
Test that custom kwargs set on the formset instance are passed to the
|
||||
Custom kwargs set on the formset instance are passed to the
|
||||
underlying forms.
|
||||
"""
|
||||
FormSet = formset_factory(CustomKwargForm, extra=2)
|
||||
@ -139,7 +139,7 @@ class FormsFormsetTestCase(SimpleTestCase):
|
||||
|
||||
def test_form_kwargs_formset_dynamic(self):
|
||||
"""
|
||||
Test that form kwargs can be passed dynamically in a formset.
|
||||
Form kwargs can be passed dynamically in a formset.
|
||||
"""
|
||||
class DynamicBaseFormSet(BaseFormSet):
|
||||
def get_form_kwargs(self, index):
|
||||
@ -856,8 +856,7 @@ class FormsFormsetTestCase(SimpleTestCase):
|
||||
<td><input type="text" name="form-1-name" id="id_form-1-name" /></td></tr>"""
|
||||
)
|
||||
|
||||
# Ensure that max_num has no effect when extra is less than max_num.
|
||||
|
||||
# max_num has no effect when extra is less than max_num.
|
||||
LimitedFavoriteDrinkFormSet = formset_factory(FavoriteDrinkForm, extra=1, max_num=2)
|
||||
formset = LimitedFavoriteDrinkFormSet()
|
||||
form_output = []
|
||||
@ -1342,7 +1341,7 @@ class TestIsBoundBehavior(SimpleTestCase):
|
||||
|
||||
class TestEmptyFormSet(SimpleTestCase):
|
||||
def test_empty_formset_is_valid(self):
|
||||
"""Test that an empty formset still calls clean()"""
|
||||
"""An empty formset still calls clean()"""
|
||||
EmptyFsetWontValidateFormset = formset_factory(FavoriteDrinkForm, extra=0, formset=EmptyFsetWontValidate)
|
||||
formset = EmptyFsetWontValidateFormset(
|
||||
data={'form-INITIAL_FORMS': '0', 'form-TOTAL_FORMS': '0'},
|
||||
|
@ -26,7 +26,7 @@ class LocalizedTimeTests(SimpleTestCase):
|
||||
result = f.clean('13:30:05')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip
|
||||
# The parsed result does a round trip
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '13:30:05')
|
||||
|
||||
@ -34,7 +34,7 @@ class LocalizedTimeTests(SimpleTestCase):
|
||||
result = f.clean('13:30')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:00")
|
||||
|
||||
@ -53,7 +53,7 @@ class LocalizedTimeTests(SimpleTestCase):
|
||||
result = f.clean('13:30:05')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '13:30:05')
|
||||
|
||||
@ -61,7 +61,7 @@ class LocalizedTimeTests(SimpleTestCase):
|
||||
result = f.clean('13:30')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:00")
|
||||
|
||||
@ -78,7 +78,7 @@ class LocalizedTimeTests(SimpleTestCase):
|
||||
result = f.clean('13.30.05')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:05")
|
||||
|
||||
@ -86,7 +86,7 @@ class LocalizedTimeTests(SimpleTestCase):
|
||||
result = f.clean('13.30')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:00")
|
||||
|
||||
@ -103,7 +103,7 @@ class LocalizedTimeTests(SimpleTestCase):
|
||||
result = f.clean('13.30.05')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:05")
|
||||
|
||||
@ -111,7 +111,7 @@ class LocalizedTimeTests(SimpleTestCase):
|
||||
result = f.clean('13.30')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:00")
|
||||
|
||||
@ -129,7 +129,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('1:30:05 PM')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip
|
||||
# The parsed result does a round trip
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '01:30:05 PM')
|
||||
|
||||
@ -137,7 +137,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('1:30 PM')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:00 PM")
|
||||
|
||||
@ -152,7 +152,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('1:30:05 PM')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '01:30:05 PM')
|
||||
|
||||
@ -160,7 +160,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('01:30 PM')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:00 PM")
|
||||
|
||||
@ -177,7 +177,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('13.30.05')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:05 PM")
|
||||
|
||||
@ -185,7 +185,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('13.30')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:00 PM")
|
||||
|
||||
@ -202,7 +202,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('13.30.05')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:05 PM")
|
||||
|
||||
@ -210,7 +210,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('13.30')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:00 PM")
|
||||
|
||||
@ -227,7 +227,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('13:30:05')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:05")
|
||||
|
||||
@ -235,7 +235,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('13:30')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:00")
|
||||
|
||||
@ -250,7 +250,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('13:30:05')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:05")
|
||||
|
||||
@ -258,7 +258,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('13:30')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:00")
|
||||
|
||||
@ -273,7 +273,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('1:30:05 PM')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:05")
|
||||
|
||||
@ -281,7 +281,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('1:30 PM')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:00")
|
||||
|
||||
@ -296,7 +296,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('1:30:05 PM')
|
||||
self.assertEqual(result, time(13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:05")
|
||||
|
||||
@ -304,7 +304,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('1:30 PM')
|
||||
self.assertEqual(result, time(13, 30, 0))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "13:30:00")
|
||||
|
||||
@ -331,7 +331,7 @@ class LocalizedDateTests(SimpleTestCase):
|
||||
result = f.clean('21.12.2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip
|
||||
# The parsed result does a round trip
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '21.12.2010')
|
||||
|
||||
@ -339,7 +339,7 @@ class LocalizedDateTests(SimpleTestCase):
|
||||
result = f.clean('21.12.10')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -354,7 +354,7 @@ class LocalizedDateTests(SimpleTestCase):
|
||||
result = f.clean('21.12.2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '21.12.2010')
|
||||
|
||||
@ -362,7 +362,7 @@ class LocalizedDateTests(SimpleTestCase):
|
||||
result = f.clean('21.12.10')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -381,7 +381,7 @@ class LocalizedDateTests(SimpleTestCase):
|
||||
result = f.clean('12.21.2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -389,7 +389,7 @@ class LocalizedDateTests(SimpleTestCase):
|
||||
result = f.clean('12-21-2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -408,7 +408,7 @@ class LocalizedDateTests(SimpleTestCase):
|
||||
result = f.clean('12.21.2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -416,7 +416,7 @@ class LocalizedDateTests(SimpleTestCase):
|
||||
result = f.clean('12-21-2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -434,7 +434,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('21.12.2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip
|
||||
# The parsed result does a round trip
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '21.12.2010')
|
||||
|
||||
@ -442,7 +442,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('21-12-2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -457,7 +457,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('21.12.2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '21.12.2010')
|
||||
|
||||
@ -465,7 +465,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('21-12-2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -482,7 +482,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('12.21.2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -490,7 +490,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('12-21-2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -507,7 +507,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('12.21.2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -515,7 +515,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('12-21-2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010")
|
||||
|
||||
@ -532,7 +532,7 @@ class SimpleDateFormatTests(SimpleTestCase):
|
||||
result = f.clean('2010-12-21')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21")
|
||||
|
||||
@ -540,7 +540,7 @@ class SimpleDateFormatTests(SimpleTestCase):
|
||||
result = f.clean('12/21/2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21")
|
||||
|
||||
@ -555,7 +555,7 @@ class SimpleDateFormatTests(SimpleTestCase):
|
||||
result = f.clean('2010-12-21')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21")
|
||||
|
||||
@ -563,7 +563,7 @@ class SimpleDateFormatTests(SimpleTestCase):
|
||||
result = f.clean('12/21/2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21")
|
||||
|
||||
@ -578,7 +578,7 @@ class SimpleDateFormatTests(SimpleTestCase):
|
||||
result = f.clean('21.12.2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21")
|
||||
|
||||
@ -586,7 +586,7 @@ class SimpleDateFormatTests(SimpleTestCase):
|
||||
result = f.clean('21-12-2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21")
|
||||
|
||||
@ -601,7 +601,7 @@ class SimpleDateFormatTests(SimpleTestCase):
|
||||
result = f.clean('21.12.2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21")
|
||||
|
||||
@ -609,7 +609,7 @@ class SimpleDateFormatTests(SimpleTestCase):
|
||||
result = f.clean('21-12-2010')
|
||||
self.assertEqual(result, date(2010, 12, 21))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21")
|
||||
|
||||
@ -636,7 +636,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
|
||||
result = f.clean('21.12.2010 13:30:05')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip
|
||||
# The parsed result does a round trip
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '21.12.2010 13:30:05')
|
||||
|
||||
@ -644,7 +644,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
|
||||
result = f.clean('21.12.2010 13:30')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010 13:30:00")
|
||||
|
||||
@ -659,7 +659,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
|
||||
result = f.clean('21.12.2010 13:30:05')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '21.12.2010 13:30:05')
|
||||
|
||||
@ -667,7 +667,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
|
||||
result = f.clean('21.12.2010 13:30')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010 13:30:00")
|
||||
|
||||
@ -686,7 +686,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
|
||||
result = f.clean('13.30.05 12.21.2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010 13:30:05")
|
||||
|
||||
@ -694,7 +694,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
|
||||
result = f.clean('13.30 12-21-2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010 13:30:00")
|
||||
|
||||
@ -713,7 +713,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
|
||||
result = f.clean('13.30.05 12.21.2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010 13:30:05")
|
||||
|
||||
@ -721,7 +721,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
|
||||
result = f.clean('13.30 12-21-2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "21.12.2010 13:30:00")
|
||||
|
||||
@ -739,7 +739,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('1:30:05 PM 21/12/2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip
|
||||
# The parsed result does a round trip
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '01:30:05 PM 21/12/2010')
|
||||
|
||||
@ -747,7 +747,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('1:30 PM 21-12-2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:00 PM 21/12/2010")
|
||||
|
||||
@ -762,7 +762,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('1:30:05 PM 21/12/2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, '01:30:05 PM 21/12/2010')
|
||||
|
||||
@ -770,7 +770,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('1:30 PM 21-12-2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:00 PM 21/12/2010")
|
||||
|
||||
@ -787,7 +787,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('12.21.2010 13:30:05')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:05 PM 21/12/2010")
|
||||
|
||||
@ -795,7 +795,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('12-21-2010 13:30')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:00 PM 21/12/2010")
|
||||
|
||||
@ -812,7 +812,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('12.21.2010 13:30:05')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:05 PM 21/12/2010")
|
||||
|
||||
@ -820,7 +820,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
|
||||
result = f.clean('12-21-2010 13:30')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "01:30:00 PM 21/12/2010")
|
||||
|
||||
@ -837,7 +837,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('2010-12-21 13:30:05')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21 13:30:05")
|
||||
|
||||
@ -845,7 +845,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('12/21/2010 13:30:05')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21 13:30:05")
|
||||
|
||||
@ -860,7 +860,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('2010-12-21 13:30:05')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21 13:30:05")
|
||||
|
||||
@ -868,7 +868,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('12/21/2010 13:30:05')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21 13:30:05")
|
||||
|
||||
@ -883,7 +883,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('1:30:05 PM 21.12.2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21 13:30:05")
|
||||
|
||||
@ -891,7 +891,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('1:30 PM 21-12-2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21 13:30:00")
|
||||
|
||||
@ -906,7 +906,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('1:30:05 PM 21.12.2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
|
||||
|
||||
# Check that the parsed result does a round trip to the same format
|
||||
# The parsed result does a round trip to the same format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21 13:30:05")
|
||||
|
||||
@ -914,6 +914,6 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
|
||||
result = f.clean('1:30 PM 21-12-2010')
|
||||
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
|
||||
|
||||
# Check that the parsed result does a round trip to default format
|
||||
# The parsed result does a round trip to default format
|
||||
text = f.widget.format_value(result)
|
||||
self.assertEqual(text, "2010-12-21 13:30:00")
|
||||
|
@ -126,7 +126,7 @@ class FormsMediaTestCase(SimpleTestCase):
|
||||
<script type="text/javascript" src="/path/to/js4"></script>"""
|
||||
)
|
||||
|
||||
# Check that media addition hasn't affected the original objects
|
||||
# media addition hasn't affected the original objects
|
||||
self.assertEqual(
|
||||
str(w1.media),
|
||||
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" />
|
||||
|
@ -38,7 +38,7 @@ class FormsUtilsTestCase(SimpleTestCase):
|
||||
|
||||
def test_flatatt_no_side_effects(self):
|
||||
"""
|
||||
Fixes #23883 -- Check that flatatt does not modify the dict passed in
|
||||
flatatt() does not modify the dict passed in.
|
||||
"""
|
||||
attrs = {'foo': 'bar', 'true': True, 'false': False}
|
||||
attrs_copy = copy.copy(attrs)
|
||||
|
@ -184,7 +184,7 @@ class LiveWidgetTests(AdminSeleniumTestCase):
|
||||
|
||||
def test_textarea_trailing_newlines(self):
|
||||
"""
|
||||
Test that a roundtrip on a ModelForm doesn't alter the TextField value
|
||||
A roundtrip on a ModelForm doesn't alter the TextField value
|
||||
"""
|
||||
article = Article.objects.create(content="\nTst\n")
|
||||
self.selenium.get(self.live_server_url + reverse('article_form', args=[article.pk]))
|
||||
|
@ -80,14 +80,14 @@ class TestModelChoiceField(TestCase):
|
||||
|
||||
class TestTicket14567(TestCase):
|
||||
"""
|
||||
Check that the return values of ModelMultipleChoiceFields are QuerySets
|
||||
The return values of ModelMultipleChoiceFields are QuerySets
|
||||
"""
|
||||
def test_empty_queryset_return(self):
|
||||
"If a model's ManyToManyField has blank=True and is saved with no data, a queryset is returned."
|
||||
option = ChoiceOptionModel.objects.create(name='default')
|
||||
form = OptionalMultiChoiceModelForm({'multi_choice_optional': '', 'multi_choice': [option.pk]})
|
||||
self.assertTrue(form.is_valid())
|
||||
# Check that the empty value is a QuerySet
|
||||
# The empty value is a QuerySet
|
||||
self.assertIsInstance(form.cleaned_data['multi_choice_optional'], models.query.QuerySet)
|
||||
# While we're at it, test whether a QuerySet is returned if there *is* a value.
|
||||
self.assertIsInstance(form.cleaned_data['multi_choice'], models.query.QuerySet)
|
||||
@ -330,7 +330,7 @@ class EmptyLabelTestCase(TestCase):
|
||||
)
|
||||
|
||||
def test_save_empty_label_forms(self):
|
||||
# Test that saving a form with a blank choice results in the expected
|
||||
# Saving a form with a blank choice results in the expected
|
||||
# value being stored in the database.
|
||||
tests = [
|
||||
(EmptyCharLabelNoneChoiceForm, 'choice_string_w_none', None),
|
||||
|
@ -47,8 +47,7 @@ class NullBooleanSelectTest(WidgetTest):
|
||||
@override_settings(USE_L10N=True)
|
||||
def test_l10n(self):
|
||||
"""
|
||||
Ensure that the NullBooleanSelect widget's options are lazily
|
||||
localized (#17190).
|
||||
The NullBooleanSelect widget's options are lazily localized (#17190).
|
||||
"""
|
||||
widget = NullBooleanSelect()
|
||||
|
||||
|
@ -422,7 +422,7 @@ class GenericInlineModelAdminTest(SimpleTestCase):
|
||||
|
||||
def test_custom_form_meta_exclude_with_readonly(self):
|
||||
"""
|
||||
Ensure that the custom ModelForm's `Meta.exclude` is respected when
|
||||
The custom ModelForm's `Meta.exclude` is respected when
|
||||
used in conjunction with `GenericInlineModelAdmin.readonly_fields`
|
||||
and when no `ModelAdmin.exclude` is defined.
|
||||
"""
|
||||
@ -449,7 +449,7 @@ class GenericInlineModelAdminTest(SimpleTestCase):
|
||||
|
||||
def test_custom_form_meta_exclude(self):
|
||||
"""
|
||||
Ensure that the custom ModelForm's `Meta.exclude` is respected by
|
||||
The custom ModelForm's `Meta.exclude` is respected by
|
||||
`GenericInlineModelAdmin.get_formset`, and overridden if
|
||||
`ModelAdmin.exclude` or `GenericInlineModelAdmin.exclude` are defined.
|
||||
Refs #15907.
|
||||
@ -494,7 +494,7 @@ class GenericInlineModelAdminTest(SimpleTestCase):
|
||||
['description', 'keywords', 'id', 'DELETE'])
|
||||
|
||||
def test_get_fieldsets(self):
|
||||
# Test that get_fieldsets is called when figuring out form fields.
|
||||
# get_fieldsets is called when figuring out form fields.
|
||||
# Refs #18681.
|
||||
class MediaForm(ModelForm):
|
||||
class Meta:
|
||||
@ -515,7 +515,7 @@ class GenericInlineModelAdminTest(SimpleTestCase):
|
||||
|
||||
def test_get_formsets_with_inlines_returns_tuples(self):
|
||||
"""
|
||||
Ensure that get_formsets_with_inlines() returns the correct tuples.
|
||||
get_formsets_with_inlines() returns the correct tuples.
|
||||
"""
|
||||
class MediaForm(ModelForm):
|
||||
class Meta:
|
||||
|
@ -327,9 +327,9 @@ class GenericRelationsTests(TestCase):
|
||||
self.assertQuerysetEqual(bacon.tags.all(), [])
|
||||
|
||||
def test_assign_with_queryset(self):
|
||||
# Ensure that querysets used in reverse GFK assignments are pre-evaluated
|
||||
# so their value isn't affected by the clearing operation in
|
||||
# ManyRelatedManager.set() (#19816).
|
||||
# Querysets used in reverse GFK assignments are pre-evaluated so their
|
||||
# value isn't affected by the clearing operation
|
||||
# in ManyRelatedManager.set() (#19816).
|
||||
bacon = Vegetable.objects.create(name="Bacon", is_yucky=False)
|
||||
bacon.tags.create(tag="fatty")
|
||||
bacon.tags.create(tag="salty")
|
||||
@ -342,8 +342,7 @@ class GenericRelationsTests(TestCase):
|
||||
self.assertEqual(1, qs.count())
|
||||
|
||||
def test_generic_relation_related_name_default(self):
|
||||
# Test that GenericRelation by default isn't usable from
|
||||
# the reverse side.
|
||||
# GenericRelation isn't usable from the reverse side by default.
|
||||
with self.assertRaises(FieldError):
|
||||
TaggedItem.objects.filter(vegetable__isnull=True)
|
||||
|
||||
@ -489,7 +488,7 @@ id="id_generic_relations-taggeditem-content_type-object_id-1-id" /></p>""" % tag
|
||||
|
||||
def test_subclasses_with_gen_rel(self):
|
||||
"""
|
||||
Test that concrete model subclasses with generic relations work
|
||||
Concrete model subclasses with generic relations work
|
||||
correctly (ticket 11263).
|
||||
"""
|
||||
granite = Rock.objects.create(name='granite', hardness=5)
|
||||
|
@ -15,10 +15,8 @@ class GenericRelationTests(TestCase):
|
||||
|
||||
def test_inherited_models_content_type(self):
|
||||
"""
|
||||
Test that GenericRelations on inherited classes use the correct content
|
||||
type.
|
||||
GenericRelations on inherited classes use the correct content type.
|
||||
"""
|
||||
|
||||
p = Place.objects.create(name="South Park")
|
||||
r = Restaurant.objects.create(name="Chubby's")
|
||||
l1 = Link.objects.create(content_object=p)
|
||||
@ -28,7 +26,7 @@ class GenericRelationTests(TestCase):
|
||||
|
||||
def test_reverse_relation_pk(self):
|
||||
"""
|
||||
Test that the correct column name is used for the primary key on the
|
||||
The correct column name is used for the primary key on the
|
||||
originating model of a query. See #12664.
|
||||
"""
|
||||
p = Person.objects.create(account=23, name='Chef')
|
||||
@ -52,10 +50,8 @@ class GenericRelationTests(TestCase):
|
||||
|
||||
def test_q_object_or(self):
|
||||
"""
|
||||
Tests that SQL query parameters for generic relations are properly
|
||||
grouped when OR is used.
|
||||
|
||||
Test for bug http://code.djangoproject.com/ticket/11535
|
||||
SQL query parameters for generic relations are properly
|
||||
grouped when OR is used (#11535).
|
||||
|
||||
In this bug the first query (below) works while the second, with the
|
||||
query parameters the same but in reverse order, does not.
|
||||
@ -88,7 +84,7 @@ class GenericRelationTests(TestCase):
|
||||
|
||||
def test_generic_relation_ordering(self):
|
||||
"""
|
||||
Test that ordering over a generic relation does not include extraneous
|
||||
Ordering over a generic relation does not include extraneous
|
||||
duplicate results, nor excludes rows not participating in the relation.
|
||||
"""
|
||||
p1 = Place.objects.create(name="South Park")
|
||||
|
@ -76,14 +76,14 @@ class ViewTest(unittest.TestCase):
|
||||
|
||||
def test_no_init_kwargs(self):
|
||||
"""
|
||||
Test that a view can't be accidentally instantiated before deployment
|
||||
A view can't be accidentally instantiated before deployment
|
||||
"""
|
||||
with self.assertRaises(AttributeError):
|
||||
SimpleView(key='value').as_view()
|
||||
|
||||
def test_no_init_args(self):
|
||||
"""
|
||||
Test that a view can't be accidentally instantiated before deployment
|
||||
A view can't be accidentally instantiated before deployment
|
||||
"""
|
||||
with self.assertRaises(TypeError):
|
||||
SimpleView.as_view('value')
|
||||
@ -133,7 +133,7 @@ class ViewTest(unittest.TestCase):
|
||||
|
||||
def test_invalid_keyword_argument(self):
|
||||
"""
|
||||
Test that view arguments must be predefined on the class and can't
|
||||
View arguments must be predefined on the class and can't
|
||||
be named like a HTTP method.
|
||||
"""
|
||||
# Check each of the allowed method names
|
||||
@ -158,7 +158,7 @@ class ViewTest(unittest.TestCase):
|
||||
|
||||
def test_class_attributes(self):
|
||||
"""
|
||||
Test that the callable returned from as_view() has proper
|
||||
The callable returned from as_view() has proper
|
||||
docstring, name and module.
|
||||
"""
|
||||
self.assertEqual(SimpleView.__doc__, SimpleView.as_view().__doc__)
|
||||
@ -167,14 +167,14 @@ class ViewTest(unittest.TestCase):
|
||||
|
||||
def test_dispatch_decoration(self):
|
||||
"""
|
||||
Test that attributes set by decorators on the dispatch method
|
||||
Attributes set by decorators on the dispatch method
|
||||
are also present on the closure.
|
||||
"""
|
||||
self.assertTrue(DecoratedDispatchView.as_view().is_decorated)
|
||||
|
||||
def test_options(self):
|
||||
"""
|
||||
Test that views respond to HTTP OPTIONS requests with an Allow header
|
||||
Views respond to HTTP OPTIONS requests with an Allow header
|
||||
appropriate for the methods implemented by the view class.
|
||||
"""
|
||||
request = self.rf.options('/')
|
||||
@ -185,7 +185,7 @@ class ViewTest(unittest.TestCase):
|
||||
|
||||
def test_options_for_get_view(self):
|
||||
"""
|
||||
Test that a view implementing GET allows GET and HEAD.
|
||||
A view implementing GET allows GET and HEAD.
|
||||
"""
|
||||
request = self.rf.options('/')
|
||||
view = SimpleView.as_view()
|
||||
@ -194,7 +194,7 @@ class ViewTest(unittest.TestCase):
|
||||
|
||||
def test_options_for_get_and_post_view(self):
|
||||
"""
|
||||
Test that a view implementing GET and POST allows GET, HEAD, and POST.
|
||||
A view implementing GET and POST allows GET, HEAD, and POST.
|
||||
"""
|
||||
request = self.rf.options('/')
|
||||
view = SimplePostView.as_view()
|
||||
@ -203,7 +203,7 @@ class ViewTest(unittest.TestCase):
|
||||
|
||||
def test_options_for_post_view(self):
|
||||
"""
|
||||
Test that a view implementing POST allows POST.
|
||||
A view implementing POST allows POST.
|
||||
"""
|
||||
request = self.rf.options('/')
|
||||
view = PostOnlyView.as_view()
|
||||
|
@ -670,9 +670,8 @@ class DateDetailViewTests(TestDataMixin, TestCase):
|
||||
|
||||
def test_get_object_custom_queryset(self):
|
||||
"""
|
||||
Ensure that custom querysets are used when provided to
|
||||
BaseDateDetailView.get_object()
|
||||
Refs #16918.
|
||||
Custom querysets are used when provided to
|
||||
BaseDateDetailView.get_object().
|
||||
"""
|
||||
res = self.client.get(
|
||||
'/dates/books/get_object_custom_queryset/2006/may/01/%s/' % self.book2.pk)
|
||||
|
@ -59,7 +59,7 @@ class ListViewTests(TestCase):
|
||||
self.assertEqual(list(res.context['author_list'])[-1].name, 'Author 29')
|
||||
|
||||
def test_paginated_queryset_shortdata(self):
|
||||
# Test that short datasets ALSO result in a paginated view.
|
||||
# Short datasets also result in a paginated view.
|
||||
res = self.client.get('/list/authors/paginated/')
|
||||
self.assertEqual(res.status_code, 200)
|
||||
self.assertTemplateUsed(res, 'generic_views/author_list.html')
|
||||
|
@ -51,11 +51,11 @@ class EarliestOrLatestTests(TestCase):
|
||||
self.assertEqual(Article.objects.filter(
|
||||
pub_date__gt=datetime(2005, 7, 26)).earliest('expire_date'), a2)
|
||||
|
||||
# Ensure that earliest() overrides any other ordering specified on the
|
||||
# query. Refs #11283.
|
||||
# earliest() overrides any other ordering specified on the query.
|
||||
# Refs #11283.
|
||||
self.assertEqual(Article.objects.order_by('id').earliest(), a1)
|
||||
|
||||
# Ensure that error is raised if the user forgot to add a get_latest_by
|
||||
# Error is raised if the user forgot to add a get_latest_by
|
||||
# in the Model.Meta
|
||||
Article.objects.model._meta.get_latest_by = None
|
||||
with self.assertRaisesMessage(
|
||||
@ -103,11 +103,10 @@ class EarliestOrLatestTests(TestCase):
|
||||
a3,
|
||||
)
|
||||
|
||||
# Ensure that latest() overrides any other ordering specified on the query. Refs #11283.
|
||||
# latest() overrides any other ordering specified on the query (#11283).
|
||||
self.assertEqual(Article.objects.order_by('id').latest(), a4)
|
||||
|
||||
# Ensure that error is raised if the user forgot to add a get_latest_by
|
||||
# in the Model.Meta
|
||||
# Error is raised if get_latest_by isn't in Model.Meta.
|
||||
Article.objects.model._meta.get_latest_by = None
|
||||
with self.assertRaisesMessage(
|
||||
AssertionError,
|
||||
@ -131,33 +130,19 @@ class TestFirstLast(TestCase):
|
||||
def test_first(self):
|
||||
p1 = Person.objects.create(name="Bob", birthday=datetime(1950, 1, 1))
|
||||
p2 = Person.objects.create(name="Alice", birthday=datetime(1961, 2, 3))
|
||||
self.assertEqual(
|
||||
Person.objects.first(), p1)
|
||||
self.assertEqual(
|
||||
Person.objects.order_by('name').first(), p2)
|
||||
self.assertEqual(
|
||||
Person.objects.filter(birthday__lte=datetime(1955, 1, 1)).first(),
|
||||
p1)
|
||||
self.assertIs(
|
||||
Person.objects.filter(birthday__lte=datetime(1940, 1, 1)).first(),
|
||||
None)
|
||||
self.assertEqual(Person.objects.first(), p1)
|
||||
self.assertEqual(Person.objects.order_by('name').first(), p2)
|
||||
self.assertEqual(Person.objects.filter(birthday__lte=datetime(1955, 1, 1)).first(), p1)
|
||||
self.assertIsNone(Person.objects.filter(birthday__lte=datetime(1940, 1, 1)).first())
|
||||
|
||||
def test_last(self):
|
||||
p1 = Person.objects.create(
|
||||
name="Alice", birthday=datetime(1950, 1, 1))
|
||||
p2 = Person.objects.create(
|
||||
name="Bob", birthday=datetime(1960, 2, 3))
|
||||
p1 = Person.objects.create(name="Alice", birthday=datetime(1950, 1, 1))
|
||||
p2 = Person.objects.create(name="Bob", birthday=datetime(1960, 2, 3))
|
||||
# Note: by default PK ordering.
|
||||
self.assertEqual(
|
||||
Person.objects.last(), p2)
|
||||
self.assertEqual(
|
||||
Person.objects.order_by('-name').last(), p1)
|
||||
self.assertEqual(
|
||||
Person.objects.filter(birthday__lte=datetime(1955, 1, 1)).last(),
|
||||
p1)
|
||||
self.assertIs(
|
||||
Person.objects.filter(birthday__lte=datetime(1940, 1, 1)).last(),
|
||||
None)
|
||||
self.assertEqual(Person.objects.last(), p2)
|
||||
self.assertEqual(Person.objects.order_by('-name').last(), p1)
|
||||
self.assertEqual(Person.objects.filter(birthday__lte=datetime(1955, 1, 1)).last(), p1)
|
||||
self.assertIsNone(Person.objects.filter(birthday__lte=datetime(1940, 1, 1)).last())
|
||||
|
||||
def test_index_error_not_suppressed(self):
|
||||
"""
|
||||
|
@ -345,7 +345,7 @@ class GDALBandTests(SimpleTestCase):
|
||||
self.assertAlmostEqual(self.band.mean, 2.828326634228898)
|
||||
self.assertAlmostEqual(self.band.std, 2.4260526986669095)
|
||||
|
||||
# Check that statistics are persisted into PAM file on band close
|
||||
# Statistics are persisted into PAM file on band close
|
||||
self.band = None
|
||||
self.assertTrue(os.path.isfile(pam_file))
|
||||
finally:
|
||||
|
@ -55,7 +55,7 @@ class GeoAdminTest(TestCase):
|
||||
|
||||
def test_olwidget_has_changed(self):
|
||||
"""
|
||||
Check that changes are accurately noticed by OpenLayersWidget.
|
||||
Changes are accurately noticed by OpenLayersWidget.
|
||||
"""
|
||||
geoadmin = site._registry[City]
|
||||
form = geoadmin.get_changelist_form(None)()
|
||||
|
@ -877,7 +877,7 @@ class GeoQuerySetTest(TestCase):
|
||||
|
||||
def test_within_subquery(self):
|
||||
"""
|
||||
Test that using a queryset inside a geo lookup is working (using a subquery)
|
||||
Using a queryset inside a geo lookup is working (using a subquery)
|
||||
(#14483).
|
||||
"""
|
||||
tex_cities = City.objects.filter(
|
||||
|
@ -27,15 +27,13 @@ class MigrateTests(TransactionTestCase):
|
||||
def test_migrate_gis(self):
|
||||
"""
|
||||
Tests basic usage of the migrate command when a model uses Geodjango
|
||||
fields. Regression test for ticket #22001:
|
||||
https://code.djangoproject.com/ticket/22001
|
||||
fields (#22001).
|
||||
|
||||
It's also used to showcase an error in migrations where spatialite is
|
||||
enabled and geo tables are renamed resulting in unique constraint
|
||||
failure on geometry_columns. Regression for ticket #23030:
|
||||
https://code.djangoproject.com/ticket/23030
|
||||
failure on geometry_columns (#23030).
|
||||
"""
|
||||
# Make sure the right tables exist
|
||||
# The right tables exist
|
||||
self.assertTableExists("gis_migrations_neighborhood")
|
||||
self.assertTableExists("gis_migrations_household")
|
||||
self.assertTableExists("gis_migrations_family")
|
||||
@ -43,7 +41,7 @@ class MigrateTests(TransactionTestCase):
|
||||
self.assertTableExists("gis_migrations_heatmap")
|
||||
# Unmigrate everything
|
||||
call_command("migrate", "gis_migrations", "zero", verbosity=0)
|
||||
# Make sure it's all gone
|
||||
# All tables are gone
|
||||
self.assertTableNotExists("gis_migrations_neighborhood")
|
||||
self.assertTableNotExists("gis_migrations_household")
|
||||
self.assertTableNotExists("gis_migrations_family")
|
||||
|
@ -304,7 +304,7 @@ class LayerMapTest(TestCase):
|
||||
lm.save(silent=True, strict=True)
|
||||
|
||||
def test_textfield(self):
|
||||
"Tests that String content fits also in a TextField"
|
||||
"String content fits also in a TextField"
|
||||
mapping = copy(city_mapping)
|
||||
mapping['name_txt'] = 'Name'
|
||||
lm = LayerMapping(City, city_shp, mapping)
|
||||
|
@ -369,5 +369,4 @@ class CustomGeometryWidgetTest(SimpleTestCase):
|
||||
|
||||
form = PointForm(data={'p': point.json})
|
||||
self.assertTrue(form.is_valid())
|
||||
# Ensure that resulting geometry has srid set
|
||||
self.assertEqual(form.cleaned_data['p'].srid, 4326)
|
||||
|
@ -47,9 +47,9 @@ if HAS_POSTGRES:
|
||||
|
||||
|
||||
@unittest.skipUnless(HAS_POSTGRES, "The psycopg2 driver is needed for these tests")
|
||||
class TestPostgisVersionCheck(unittest.TestCase):
|
||||
class TestPostGISVersionCheck(unittest.TestCase):
|
||||
"""
|
||||
Tests that the postgis version check parses correctly the version numbers
|
||||
The PostGIS version check parses correctly the version numbers
|
||||
"""
|
||||
|
||||
def test_get_version(self):
|
||||
|
@ -46,7 +46,7 @@ class HandlerTests(SimpleTestCase):
|
||||
|
||||
def test_non_ascii_query_string(self):
|
||||
"""
|
||||
Test that non-ASCII query strings are properly decoded (#20530, #22996).
|
||||
Non-ASCII query strings are properly decoded (#20530, #22996).
|
||||
"""
|
||||
environ = RequestFactory().get('/').environ
|
||||
raw_query_strings = [
|
||||
@ -71,7 +71,7 @@ class HandlerTests(SimpleTestCase):
|
||||
self.assertListEqual(got, ['café', 'café', 'caf\ufffd', 'café'])
|
||||
|
||||
def test_non_ascii_cookie(self):
|
||||
"""Test that non-ASCII cookies set in JavaScript are properly decoded (#20557)."""
|
||||
"""Non-ASCII cookies set in JavaScript are properly decoded (#20557)."""
|
||||
environ = RequestFactory().get('/').environ
|
||||
raw_cookie = 'want="café"'
|
||||
if six.PY3:
|
||||
|
@ -498,14 +498,13 @@ class HttpResponseSubclassesTests(SimpleTestCase):
|
||||
def test_redirect(self):
|
||||
response = HttpResponseRedirect('/redirected/')
|
||||
self.assertEqual(response.status_code, 302)
|
||||
# Test that standard HttpResponse init args can be used
|
||||
# Standard HttpResponse init args can be used
|
||||
response = HttpResponseRedirect(
|
||||
'/redirected/',
|
||||
content='The resource has temporarily moved',
|
||||
content_type='text/html',
|
||||
)
|
||||
self.assertContains(response, 'The resource has temporarily moved', status_code=302)
|
||||
# Test that url attribute is right
|
||||
self.assertEqual(response.url, response['Location'])
|
||||
|
||||
def test_redirect_lazy(self):
|
||||
@ -529,7 +528,7 @@ class HttpResponseSubclassesTests(SimpleTestCase):
|
||||
def test_not_allowed(self):
|
||||
response = HttpResponseNotAllowed(['GET'])
|
||||
self.assertEqual(response.status_code, 405)
|
||||
# Test that standard HttpResponse init args can be used
|
||||
# Standard HttpResponse init args can be used
|
||||
response = HttpResponseNotAllowed(['GET'], content='Only the GET method is allowed', content_type='text/html')
|
||||
self.assertContains(response, 'Only the GET method is allowed', status_code=405)
|
||||
|
||||
@ -697,18 +696,14 @@ class FileCloseTests(SimpleTestCase):
|
||||
|
||||
class CookieTests(unittest.TestCase):
|
||||
def test_encode(self):
|
||||
"""
|
||||
Test that we don't output tricky characters in encoded value
|
||||
"""
|
||||
"""Semicolons and commas are encoded."""
|
||||
c = SimpleCookie()
|
||||
c['test'] = "An,awkward;value"
|
||||
self.assertNotIn(";", c.output().rstrip(';')) # IE compat
|
||||
self.assertNotIn(",", c.output().rstrip(';')) # Safari compat
|
||||
|
||||
def test_decode(self):
|
||||
"""
|
||||
Test that we can still preserve semi-colons and commas
|
||||
"""
|
||||
"""Semicolons and commas are decoded."""
|
||||
c = SimpleCookie()
|
||||
c['test'] = "An,awkward;value"
|
||||
c2 = SimpleCookie()
|
||||
@ -718,9 +713,6 @@ class CookieTests(unittest.TestCase):
|
||||
self.assertEqual(c['test'].value, c3['test'])
|
||||
|
||||
def test_decode_2(self):
|
||||
"""
|
||||
Test that we haven't broken normal encoding
|
||||
"""
|
||||
c = SimpleCookie()
|
||||
c['test'] = b"\xf0"
|
||||
c2 = SimpleCookie()
|
||||
@ -731,13 +723,13 @@ class CookieTests(unittest.TestCase):
|
||||
|
||||
def test_nonstandard_keys(self):
|
||||
"""
|
||||
Test that a single non-standard cookie name doesn't affect all cookies. Ticket #13007.
|
||||
A single non-standard cookie name doesn't affect all cookies (#13007).
|
||||
"""
|
||||
self.assertIn('good_cookie', parse_cookie('good_cookie=yes;bad:cookie=yes').keys())
|
||||
|
||||
def test_repeated_nonstandard_keys(self):
|
||||
"""
|
||||
Test that a repeated non-standard name doesn't affect all cookies. Ticket #15852
|
||||
A repeated non-standard name doesn't affect all cookies (#15852).
|
||||
"""
|
||||
self.assertIn('good_cookie', parse_cookie('a:=b; a:=c; good_cookie=yes').keys())
|
||||
|
||||
@ -788,9 +780,6 @@ class CookieTests(unittest.TestCase):
|
||||
self.assertEqual(parse_cookie(' = b ; ; = ; c = ; '), {'': 'b', 'c': ''})
|
||||
|
||||
def test_httponly_after_load(self):
|
||||
"""
|
||||
Test that we can use httponly attribute on cookies that we load
|
||||
"""
|
||||
c = SimpleCookie()
|
||||
c.load("name=val")
|
||||
c['name']['httponly'] = True
|
||||
|
@ -111,8 +111,8 @@ class RequestURLConfTests(SimpleTestCase):
|
||||
@override_settings(ROOT_URLCONF='i18n.patterns.urls.path_unused')
|
||||
class PathUnusedTests(URLTestCaseBase):
|
||||
"""
|
||||
Check that if no i18n_patterns is used in root URLconfs, then no
|
||||
language activation happens based on url prefix.
|
||||
If no i18n_patterns is used in root URLconfs, then no language activation
|
||||
activation happens based on url prefix.
|
||||
"""
|
||||
|
||||
def test_no_lang_activate(self):
|
||||
@ -235,8 +235,7 @@ class URLRedirectTests(URLTestCaseBase):
|
||||
|
||||
class URLVaryAcceptLanguageTests(URLTestCaseBase):
|
||||
"""
|
||||
Tests that 'Accept-Language' is not added to the Vary header when using
|
||||
prefixed URLs.
|
||||
'Accept-Language' is not added to the Vary header when using prefixed URLs.
|
||||
"""
|
||||
def test_no_prefix_response(self):
|
||||
response = self.client.get('/not-prefixed/')
|
||||
|
@ -214,7 +214,7 @@ class BasicExtractorTests(ExtractorTests):
|
||||
)
|
||||
with self.assertRaisesMessage(SyntaxError, msg):
|
||||
management.call_command('makemessages', locale=[LOCALE], extensions=['tpl'], verbosity=0)
|
||||
# Check that the temporary file was cleaned up
|
||||
# The temporary file was cleaned up
|
||||
self.assertFalse(os.path.exists('./templates/template_with_error.tpl.py'))
|
||||
|
||||
def test_unicode_decode_error(self):
|
||||
@ -237,9 +237,8 @@ class BasicExtractorTests(ExtractorTests):
|
||||
|
||||
def test_template_message_context_extractor(self):
|
||||
"""
|
||||
Ensure that message contexts are correctly extracted for the
|
||||
{% trans %} and {% blocktrans %} template tags.
|
||||
Refs #14806.
|
||||
Message contexts are correctly extracted for the {% trans %} and
|
||||
{% blocktrans %} template tags (#14806).
|
||||
"""
|
||||
management.call_command('makemessages', locale=[LOCALE], verbosity=0)
|
||||
self.assertTrue(os.path.exists(self.PO_FILE))
|
||||
@ -350,7 +349,7 @@ class BasicExtractorTests(ExtractorTests):
|
||||
|
||||
def test_makemessages_find_files(self):
|
||||
"""
|
||||
Test that find_files only discover files having the proper extensions.
|
||||
find_files only discover files having the proper extensions.
|
||||
"""
|
||||
cmd = MakeMessagesCommand()
|
||||
cmd.ignore_patterns = ['CVS', '.*', '*~', '*.pyc']
|
||||
@ -695,9 +694,8 @@ class CustomLayoutExtractionTests(ExtractorTests):
|
||||
|
||||
def test_project_locale_paths(self):
|
||||
"""
|
||||
Test that:
|
||||
* translations for an app containing a locale folder are stored in that folder
|
||||
* translations outside of that app are in LOCALE_PATHS[0]
|
||||
* translations for an app containing a locale folder are stored in that folder
|
||||
* translations outside of that app are in LOCALE_PATHS[0]
|
||||
"""
|
||||
with override_settings(LOCALE_PATHS=[os.path.join(self.test_dir, 'project_locale')]):
|
||||
management.call_command('makemessages', locale=[LOCALE], verbosity=0)
|
||||
|
@ -35,7 +35,7 @@ class ExtractingStringsWithPercentSigns(POFileAssertionMixin, FrenchTestCase):
|
||||
"""
|
||||
Tests the extracted string found in the gettext catalog.
|
||||
|
||||
Ensures that percent signs are python formatted.
|
||||
Percent signs are python formatted.
|
||||
|
||||
These tests should all have an analogous translation tests below, ensuring
|
||||
the python formatting does not persist through to a rendered template.
|
||||
|
@ -107,8 +107,8 @@ class TranslationTests(SimpleTestCase):
|
||||
|
||||
def test_override_exit(self):
|
||||
"""
|
||||
Test that the language restored is the one used when the function was
|
||||
called, not the one used when the decorator was initialized. refs #23381
|
||||
The language restored is the one used when the function was
|
||||
called, not the one used when the decorator was initialized (#23381).
|
||||
"""
|
||||
activate('fr')
|
||||
|
||||
@ -267,9 +267,8 @@ class TranslationTests(SimpleTestCase):
|
||||
@override_settings(LOCALE_PATHS=extended_locale_paths)
|
||||
def test_template_tags_pgettext(self):
|
||||
"""
|
||||
Ensure that message contexts are taken into account the {% trans %} and
|
||||
{% blocktrans %} template tags.
|
||||
Refs #14806.
|
||||
Message contexts are taken into account the {% trans %} and
|
||||
{% blocktrans %} template tags (#14806).
|
||||
"""
|
||||
trans_real._active = local()
|
||||
trans_real._translations = {}
|
||||
@ -726,10 +725,9 @@ class FormattingTests(SimpleTestCase):
|
||||
|
||||
def test_false_like_locale_formats(self):
|
||||
"""
|
||||
Ensure that the active locale's formats take precedence over the
|
||||
default settings even if they would be interpreted as False in a
|
||||
conditional test (e.g. 0 or empty string).
|
||||
Refs #16938.
|
||||
The active locale's formats take precedence over the default settings
|
||||
even if they would be interpreted as False in a conditional test
|
||||
(e.g. 0 or empty string) (#16938).
|
||||
"""
|
||||
with patch_formats('fr', THOUSAND_SEPARATOR='', FIRST_DAY_OF_WEEK=0):
|
||||
with translation.override('fr'):
|
||||
@ -1152,7 +1150,7 @@ class FormattingTests(SimpleTestCase):
|
||||
|
||||
with translation.override('ru', deactivate=True):
|
||||
# Russian locale has non-breaking space (\xa0) as thousand separator
|
||||
# Check that usual space is accepted too when sanitizing inputs
|
||||
# Usual space is accepted too when sanitizing inputs
|
||||
with self.settings(USE_THOUSAND_SEPARATOR=True):
|
||||
self.assertEqual(sanitize_separators('1\xa0234\xa0567'), '1234567')
|
||||
self.assertEqual(sanitize_separators('77\xa0777,777'), '77777.777')
|
||||
@ -1514,8 +1512,8 @@ class MiscTests(SimpleTestCase):
|
||||
@override_settings(LOCALE_PATHS=extended_locale_paths)
|
||||
def test_percent_formatting_in_blocktrans(self):
|
||||
"""
|
||||
Test that using Python's %-formatting is properly escaped in blocktrans,
|
||||
singular or plural
|
||||
Python's %-formatting is properly escaped in blocktrans, singular or
|
||||
plural.
|
||||
"""
|
||||
t_sing = Template("{% load i18n %}{% blocktrans %}There are %(num_comments)s comments{% endblocktrans %}")
|
||||
t_plur = Template(
|
||||
@ -1531,8 +1529,8 @@ class MiscTests(SimpleTestCase):
|
||||
|
||||
def test_cache_resetting(self):
|
||||
"""
|
||||
#14170 after setting LANGUAGE, cache should be cleared and languages
|
||||
previously valid should not be used.
|
||||
After setting LANGUAGE, the cache should be cleared and languages
|
||||
previously valid should not be used (#14170).
|
||||
"""
|
||||
g = get_language_from_request
|
||||
r = self.rf.get('/')
|
||||
@ -1812,9 +1810,10 @@ class LocaleMiddlewareTests(TestCase):
|
||||
],
|
||||
)
|
||||
def test_language_not_saved_to_session(self):
|
||||
"""Checks that current language is not automatically saved to
|
||||
session on every request."""
|
||||
# Regression test for #21473
|
||||
"""
|
||||
The Current language isno' automatically saved to the session on every
|
||||
request (#21473).
|
||||
"""
|
||||
self.client.get('/fr/simple/')
|
||||
self.assertNotIn(LANGUAGE_SESSION_KEY, self.client.session)
|
||||
|
||||
|
@ -236,7 +236,7 @@ class InspectDBTestCase(TestCase):
|
||||
self.assertIn("class InspectdbSpecialTableName(models.Model):", output)
|
||||
|
||||
def test_managed_models(self):
|
||||
"""Test that by default the command generates models with `Meta.managed = False` (#14305)"""
|
||||
"""By default the command generates models with `Meta.managed = False` (#14305)"""
|
||||
out = StringIO()
|
||||
call_command('inspectdb',
|
||||
table_name_filter=lambda tn: tn.startswith('inspectdb_columntypes'),
|
||||
|
@ -182,8 +182,7 @@ class IntrospectionTests(TransactionTestCase):
|
||||
@ignore_warnings(category=RemovedInDjango21Warning)
|
||||
def test_get_indexes_multicol(self):
|
||||
"""
|
||||
Test that multicolumn indexes are not included in the introspection
|
||||
results.
|
||||
Multicolumn indexes are not included in the introspection results.
|
||||
"""
|
||||
with connection.cursor() as cursor:
|
||||
indexes = connection.introspection.get_indexes(cursor, Reporter._meta.db_table)
|
||||
|
@ -1527,7 +1527,7 @@ class ComplexClashTests(SimpleTestCase):
|
||||
class M2mThroughFieldsTests(SimpleTestCase):
|
||||
def test_m2m_field_argument_validation(self):
|
||||
"""
|
||||
Tests that ManyToManyField accepts the ``through_fields`` kwarg
|
||||
ManyToManyField accepts the ``through_fields`` kwarg
|
||||
only if an intermediary table is specified.
|
||||
"""
|
||||
class Fan(models.Model):
|
||||
@ -1538,7 +1538,7 @@ class M2mThroughFieldsTests(SimpleTestCase):
|
||||
|
||||
def test_invalid_order(self):
|
||||
"""
|
||||
Tests that mixing up the order of link fields to ManyToManyField.through_fields
|
||||
Mixing up the order of link fields to ManyToManyField.through_fields
|
||||
triggers validation errors.
|
||||
"""
|
||||
class Fan(models.Model):
|
||||
@ -1572,7 +1572,7 @@ class M2mThroughFieldsTests(SimpleTestCase):
|
||||
|
||||
def test_invalid_field(self):
|
||||
"""
|
||||
Tests that providing invalid field names to ManyToManyField.through_fields
|
||||
Providing invalid field names to ManyToManyField.through_fields
|
||||
triggers validation errors.
|
||||
"""
|
||||
class Fan(models.Model):
|
||||
@ -1610,7 +1610,7 @@ class M2mThroughFieldsTests(SimpleTestCase):
|
||||
|
||||
def test_explicit_field_names(self):
|
||||
"""
|
||||
Tests that if ``through_fields`` kwarg is given, it must specify both
|
||||
If ``through_fields`` kwarg is given, it must specify both
|
||||
link fields of the intermediary table.
|
||||
"""
|
||||
class Fan(models.Model):
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""
|
||||
Existing related object instance caching.
|
||||
|
||||
Test that queries are not redone when going back through known relations.
|
||||
Queries are not redone when going back through known relations.
|
||||
"""
|
||||
|
||||
from django.db import models
|
||||
|
@ -170,7 +170,7 @@ class AdminEmailHandlerTest(SimpleTestCase):
|
||||
logger = logging.getLogger('django')
|
||||
|
||||
def get_admin_email_handler(self, logger):
|
||||
# Ensure that AdminEmailHandler does not get filtered out
|
||||
# AdminEmailHandler does not get filtered out
|
||||
# even with DEBUG=True.
|
||||
admin_email_handler = [
|
||||
h for h in logger.handlers
|
||||
@ -188,9 +188,8 @@ class AdminEmailHandlerTest(SimpleTestCase):
|
||||
)
|
||||
def test_accepts_args(self):
|
||||
"""
|
||||
Ensure that user-supplied arguments and the EMAIL_SUBJECT_PREFIX
|
||||
setting are used to compose the email subject.
|
||||
Refs #16736.
|
||||
User-supplied arguments and the EMAIL_SUBJECT_PREFIX setting are used
|
||||
to compose the email subject (#16736).
|
||||
"""
|
||||
message = "Custom message that says '%s' and '%s'"
|
||||
token1 = 'ping'
|
||||
@ -219,8 +218,7 @@ class AdminEmailHandlerTest(SimpleTestCase):
|
||||
)
|
||||
def test_accepts_args_and_request(self):
|
||||
"""
|
||||
Ensure that the subject is also handled if being
|
||||
passed a request object.
|
||||
The subject is also handled if being passed a request object.
|
||||
"""
|
||||
message = "Custom message that says '%s' and '%s'"
|
||||
token1 = 'ping'
|
||||
@ -255,9 +253,8 @@ class AdminEmailHandlerTest(SimpleTestCase):
|
||||
)
|
||||
def test_subject_accepts_newlines(self):
|
||||
"""
|
||||
Ensure that newlines in email reports' subjects are escaped to avoid
|
||||
AdminErrorHandler to fail.
|
||||
Refs #17281.
|
||||
Newlines in email reports' subjects are escaped to prevent
|
||||
AdminErrorHandler from failing (#17281).
|
||||
"""
|
||||
message = 'Message \r\n with newlines'
|
||||
expected_subject = 'ERROR: Message \\r\\n with newlines'
|
||||
@ -361,7 +358,7 @@ class AdminEmailHandlerTest(SimpleTestCase):
|
||||
|
||||
class SettingsConfigTest(AdminScriptTestCase):
|
||||
"""
|
||||
Test that accessing settings in a custom logging handler does not trigger
|
||||
Accessing settings in a custom logging handler does not trigger
|
||||
a circular import error.
|
||||
"""
|
||||
def setUp(self):
|
||||
@ -393,7 +390,7 @@ dictConfig.called = False
|
||||
|
||||
class SetupConfigureLogging(SimpleTestCase):
|
||||
"""
|
||||
Test that calling django.setup() initializes the logging configuration.
|
||||
Calling django.setup() initializes the logging configuration.
|
||||
"""
|
||||
@override_settings(LOGGING_CONFIG='logging_tests.tests.dictConfig',
|
||||
LOGGING=OLD_LOGGING)
|
||||
@ -430,7 +427,7 @@ class SecurityLoggerTest(SimpleTestCase):
|
||||
|
||||
class SettingsCustomLoggingTest(AdminScriptTestCase):
|
||||
"""
|
||||
Test that using a logging defaults are still applied when using a custom
|
||||
Using a logging defaults are still applied when using a custom
|
||||
callable in LOGGING_CONFIG (i.e., logging.config.fileConfig).
|
||||
"""
|
||||
def setUp(self):
|
||||
|
@ -655,29 +655,28 @@ class LookupTests(TestCase):
|
||||
|
||||
def test_regex_null(self):
|
||||
"""
|
||||
Ensure that a regex lookup does not fail on null/None values
|
||||
A regex lookup does not fail on null/None values
|
||||
"""
|
||||
Season.objects.create(year=2012, gt=None)
|
||||
self.assertQuerysetEqual(Season.objects.filter(gt__regex=r'^$'), [])
|
||||
|
||||
def test_regex_non_string(self):
|
||||
"""
|
||||
Ensure that a regex lookup does not fail on non-string fields
|
||||
A regex lookup does not fail on non-string fields
|
||||
"""
|
||||
Season.objects.create(year=2013, gt=444)
|
||||
self.assertQuerysetEqual(Season.objects.filter(gt__regex=r'^444$'), ['<Season: 2013>'])
|
||||
|
||||
def test_regex_non_ascii(self):
|
||||
"""
|
||||
Ensure that a regex lookup does not trip on non-ASCII characters.
|
||||
A regex lookup does not trip on non-ASCII characters.
|
||||
"""
|
||||
Player.objects.create(name='\u2660')
|
||||
Player.objects.get(name__regex='\u2660')
|
||||
|
||||
def test_nonfield_lookups(self):
|
||||
"""
|
||||
Ensure that a lookup query containing non-fields raises the proper
|
||||
exception.
|
||||
A lookup query containing non-fields raises the proper exception.
|
||||
"""
|
||||
with self.assertRaises(FieldError):
|
||||
Article.objects.filter(headline__blahblah=99)
|
||||
@ -688,12 +687,10 @@ class LookupTests(TestCase):
|
||||
|
||||
def test_lookup_collision(self):
|
||||
"""
|
||||
Ensure that genuine field names don't collide with built-in lookup
|
||||
types ('year', 'gt', 'range', 'in' etc.).
|
||||
Refs #11670.
|
||||
Genuine field names don't collide with built-in lookup types
|
||||
('year', 'gt', 'range', 'in' etc.) (#11670).
|
||||
"""
|
||||
|
||||
# Here we're using 'gt' as a code number for the year, e.g. 111=>2009.
|
||||
# 'gt' is used as a code number for the year, e.g. 111=>2009.
|
||||
season_2009 = Season.objects.create(year=2009, gt=111)
|
||||
season_2009.games.create(home="Houston Astros", away="St. Louis Cardinals")
|
||||
season_2010 = Season.objects.create(year=2010, gt=222)
|
||||
|
@ -21,7 +21,6 @@ class RecursiveM2MTests(TestCase):
|
||||
self.d.friends.add(self.a, self.c)
|
||||
|
||||
def test_recursive_m2m_all(self):
|
||||
""" Test that m2m relations are reported correctly """
|
||||
# Who is friends with Anne?
|
||||
self.assertQuerysetEqual(
|
||||
self.a.friends.all(), [
|
||||
@ -59,8 +58,6 @@ class RecursiveM2MTests(TestCase):
|
||||
)
|
||||
|
||||
def test_recursive_m2m_reverse_add(self):
|
||||
""" Test reverse m2m relation is consistent """
|
||||
|
||||
# Bill is already friends with Anne - add Anne again, but in the
|
||||
# reverse direction
|
||||
self.b.friends.add(self.a)
|
||||
@ -84,8 +81,6 @@ class RecursiveM2MTests(TestCase):
|
||||
)
|
||||
|
||||
def test_recursive_m2m_remove(self):
|
||||
""" Test that we can remove items from an m2m relationship """
|
||||
|
||||
# Remove Anne from Bill's friends
|
||||
self.b.friends.remove(self.a)
|
||||
|
||||
@ -104,8 +99,6 @@ class RecursiveM2MTests(TestCase):
|
||||
)
|
||||
|
||||
def test_recursive_m2m_clear(self):
|
||||
""" Tests the clear method works as expected on m2m fields """
|
||||
|
||||
# Clear Anne's group of friends
|
||||
self.a.friends.clear()
|
||||
|
||||
@ -132,8 +125,6 @@ class RecursiveM2MTests(TestCase):
|
||||
)
|
||||
|
||||
def test_recursive_m2m_add_via_related_name(self):
|
||||
""" Tests that we can add m2m relations via the related_name attribute """
|
||||
|
||||
# David is idolized by Anne and Chuck - add in reverse direction
|
||||
self.d.stalkers.add(self.a)
|
||||
|
||||
@ -152,8 +143,7 @@ class RecursiveM2MTests(TestCase):
|
||||
)
|
||||
|
||||
def test_recursive_m2m_add_in_both_directions(self):
|
||||
""" Check that adding the same relation twice results in a single relation """
|
||||
|
||||
"""Adding the same relation twice results in a single relation."""
|
||||
# Ann idolizes David
|
||||
self.a.idols.add(self.d)
|
||||
|
||||
@ -173,8 +163,6 @@ class RecursiveM2MTests(TestCase):
|
||||
self.assertEqual(self.a.idols.all().count(), 1)
|
||||
|
||||
def test_recursive_m2m_related_to_self(self):
|
||||
""" Check the expected behavior when an instance is related to itself """
|
||||
|
||||
# Ann idolizes herself
|
||||
self.a.idols.add(self.a)
|
||||
|
||||
|
@ -359,7 +359,7 @@ class ManyToManySignalsTest(TestCase):
|
||||
|
||||
self._initialize_signal_car(add_default_parts_before_set_signal=True)
|
||||
|
||||
# Check that signals still work when model inheritance is involved
|
||||
# Signals still work when model inheritance is involved
|
||||
c4 = SportsCar.objects.create(name='Bugatti', price='1000000')
|
||||
c4b = Car.objects.get(name='Bugatti')
|
||||
c4.default_parts.set([self.doors])
|
||||
|
@ -341,7 +341,7 @@ class M2mThroughTests(TestCase):
|
||||
|
||||
def test_through_fields(self):
|
||||
"""
|
||||
Tests that relations with intermediary tables with multiple FKs
|
||||
Relations with intermediary tables with multiple FKs
|
||||
to the M2M's ``to`` model are possible.
|
||||
"""
|
||||
event = Event.objects.create(title='Rockwhale 2014')
|
||||
|
@ -91,7 +91,10 @@ class M2MThroughTestCase(TestCase):
|
||||
)
|
||||
|
||||
def test_join_trimming_forwards(self):
|
||||
"Check that we don't involve too many copies of the intermediate table when doing a join. Refs #8046, #8254"
|
||||
"""
|
||||
Too many copies of the intermediate table aren't involved when doing a
|
||||
join (#8046, #8254).
|
||||
"""
|
||||
self.assertQuerysetEqual(
|
||||
self.rock.members.filter(membership__price=50), [
|
||||
"<Person: Jim>",
|
||||
|
@ -45,11 +45,11 @@ class HeadersCheckMixin(object):
|
||||
|
||||
def assertMessageHasHeaders(self, message, headers):
|
||||
"""
|
||||
Check that :param message: has all :param headers: headers.
|
||||
Asserts that the `message` has all `headers`.
|
||||
|
||||
:param message: can be an instance of an email.Message subclass or a
|
||||
string with the contents of an email message.
|
||||
:param headers: should be a set of (header-name, header-value) tuples.
|
||||
message: can be an instance of an email.Message subclass or a string
|
||||
with the contents of an email message.
|
||||
headers: should be a set of (header-name, header-value) tuples.
|
||||
"""
|
||||
if isinstance(message, binary_type):
|
||||
message = message_from_bytes(message)
|
||||
@ -432,7 +432,6 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
||||
def test_attach_text_as_bytes(self):
|
||||
msg = EmailMessage('subject', 'body', 'from@example.com', ['to@example.com'])
|
||||
msg.attach('file.txt', b'file content')
|
||||
# Check that the message would be sent at all.
|
||||
sent_num = msg.send()
|
||||
self.assertEqual(sent_num, 1)
|
||||
filename, content, mimetype = self.get_decoded_attachments(msg)[0]
|
||||
@ -620,7 +619,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
||||
parent_msg.attach(content=child_s, mimetype='message/rfc822')
|
||||
parent_s = parent_msg.message().as_string()
|
||||
|
||||
# Verify that the child message header is not base64 encoded
|
||||
# The child message header is not base64 encoded
|
||||
self.assertIn(str('Child Subject'), parent_s)
|
||||
|
||||
# Feature test: try attaching email.Message object directly to the mail.
|
||||
@ -631,7 +630,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
||||
parent_msg.attach(content=child_msg.message(), mimetype='message/rfc822')
|
||||
parent_s = parent_msg.message().as_string()
|
||||
|
||||
# Verify that the child message header is not base64 encoded
|
||||
# The child message header is not base64 encoded
|
||||
self.assertIn(str('Child Subject'), parent_s)
|
||||
|
||||
# Feature test: try attaching Django's EmailMessage object directly to the mail.
|
||||
@ -642,7 +641,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
||||
parent_msg.attach(content=child_msg, mimetype='message/rfc822')
|
||||
parent_s = parent_msg.message().as_string()
|
||||
|
||||
# Verify that the child message header is not base64 encoded
|
||||
# The child message header is not base64 encoded
|
||||
self.assertIn(str('Child Subject'), parent_s)
|
||||
|
||||
def test_sanitize_address(self):
|
||||
@ -890,7 +889,7 @@ class BaseEmailBackendTests(HeadersCheckMixin, object):
|
||||
@override_settings(ADMINS=[], MANAGERS=[])
|
||||
def test_empty_admins(self):
|
||||
"""
|
||||
Test that mail_admins/mail_managers doesn't connect to the mail server
|
||||
mail_admins/mail_managers doesn't connect to the mail server
|
||||
if there are no recipients (#9383)
|
||||
"""
|
||||
mail_admins('hi', 'there')
|
||||
@ -971,14 +970,14 @@ class BaseEmailBackendTests(HeadersCheckMixin, object):
|
||||
|
||||
def test_close_connection(self):
|
||||
"""
|
||||
Test that connection can be closed (even when not explicitly opened)
|
||||
Connection can be closed (even when not explicitly opened)
|
||||
"""
|
||||
conn = mail.get_connection(username='', password='')
|
||||
conn.close()
|
||||
|
||||
def test_use_as_contextmanager(self):
|
||||
"""
|
||||
Test that the connection can be used as a contextmanager.
|
||||
The connection can be used as a contextmanager.
|
||||
"""
|
||||
opened = [False]
|
||||
closed = [False]
|
||||
@ -1114,7 +1113,7 @@ class ConsoleBackendTests(BaseEmailBackendTests, SimpleTestCase):
|
||||
|
||||
def test_console_stream_kwarg(self):
|
||||
"""
|
||||
Test that the console backend can be pointed at an arbitrary stream.
|
||||
The console backend can be pointed at an arbitrary stream.
|
||||
"""
|
||||
s = StringIO()
|
||||
connection = mail.get_connection('django.core.mail.backends.console.EmailBackend', stream=s)
|
||||
@ -1300,7 +1299,7 @@ class SMTPBackendTests(BaseEmailBackendTests, SMTPBackendTestsBase):
|
||||
|
||||
def test_auth_attempted(self):
|
||||
"""
|
||||
Test that opening the backend with non empty username/password tries
|
||||
Opening the backend with non empty username/password tries
|
||||
to authenticate against the SMTP server.
|
||||
"""
|
||||
backend = smtp.EmailBackend(
|
||||
@ -1311,7 +1310,7 @@ class SMTPBackendTests(BaseEmailBackendTests, SMTPBackendTestsBase):
|
||||
|
||||
def test_server_open(self):
|
||||
"""
|
||||
Test that open() tells us whether it opened a connection.
|
||||
open() returns whether it opened a connection.
|
||||
"""
|
||||
backend = smtp.EmailBackend(username='', password='')
|
||||
self.assertFalse(backend.connection)
|
||||
@ -1405,12 +1404,12 @@ class SMTPBackendTests(BaseEmailBackendTests, SMTPBackendTestsBase):
|
||||
pass
|
||||
|
||||
def test_connection_timeout_default(self):
|
||||
"""Test that the connection's timeout value is None by default."""
|
||||
"""The connection's timeout value is None by default."""
|
||||
connection = mail.get_connection('django.core.mail.backends.smtp.EmailBackend')
|
||||
self.assertIsNone(connection.timeout)
|
||||
|
||||
def test_connection_timeout_custom(self):
|
||||
"""Test that the timeout parameter can be customized."""
|
||||
"""The timeout parameter can be customized."""
|
||||
class MyEmailBackend(smtp.EmailBackend):
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs.setdefault('timeout', 42)
|
||||
@ -1428,7 +1427,7 @@ class SMTPBackendTests(BaseEmailBackendTests, SMTPBackendTestsBase):
|
||||
self.assertEqual(backend.timeout, 10)
|
||||
|
||||
def test_email_msg_uses_crlf(self):
|
||||
"""#23063 -- Test that RFC-compliant messages are sent over SMTP."""
|
||||
"""#23063 -- RFC-compliant messages are sent over SMTP."""
|
||||
send = SMTP.send
|
||||
try:
|
||||
smtp_messages = []
|
||||
@ -1453,7 +1452,7 @@ class SMTPBackendTests(BaseEmailBackendTests, SMTPBackendTestsBase):
|
||||
|
||||
if PY3:
|
||||
msg = msg.decode('utf-8')
|
||||
# Ensure that the message only contains CRLF and not combinations of CRLF, LF, and CR.
|
||||
# The message only contains CRLF and not combinations of CRLF, LF, and CR.
|
||||
msg = msg.replace('\r\n', '')
|
||||
self.assertNotIn('\r', msg)
|
||||
self.assertNotIn('\n', msg)
|
||||
|
@ -475,9 +475,9 @@ class ManyToManyTests(TestCase):
|
||||
self.assertQuerysetEqual(self.a4.publications.all(), ['<Publication: Science Weekly>'])
|
||||
|
||||
def test_forward_assign_with_queryset(self):
|
||||
# Ensure that querysets used in m2m assignments are pre-evaluated
|
||||
# so their value isn't affected by the clearing operation in
|
||||
# ManyRelatedManager.set() (#19816).
|
||||
# Querysets used in m2m assignments are pre-evaluated so their value
|
||||
# isn't affected by the clearing operation in ManyRelatedManager.set()
|
||||
# (#19816).
|
||||
self.a1.publications.set([self.p1, self.p2])
|
||||
|
||||
qs = self.a1.publications.filter(title='The Python Journal')
|
||||
@ -487,9 +487,9 @@ class ManyToManyTests(TestCase):
|
||||
self.assertEqual(1, qs.count())
|
||||
|
||||
def test_reverse_assign_with_queryset(self):
|
||||
# Ensure that querysets used in M2M assignments are pre-evaluated
|
||||
# so their value isn't affected by the clearing operation in
|
||||
# ManyRelatedManager.set() (#19816).
|
||||
# Querysets used in M2M assignments are pre-evaluated so their value
|
||||
# isn't affected by the clearing operation in ManyRelatedManager.set()
|
||||
# (#19816).
|
||||
self.p1.article_set.set([self.a1, self.a2])
|
||||
|
||||
qs = self.p1.article_set.filter(headline='Django lets you build Web apps easily')
|
||||
|
@ -183,7 +183,7 @@ class ManyToOneTests(TestCase):
|
||||
Article.objects.filter(reporter__first_name__exact='John'),
|
||||
["<Article: John's second story>", "<Article: This is a test>"]
|
||||
)
|
||||
# Check that implied __exact also works
|
||||
# Implied __exact also works
|
||||
self.assertQuerysetEqual(
|
||||
Article.objects.filter(reporter__first_name='John'),
|
||||
["<Article: John's second story>", "<Article: This is a test>"]
|
||||
@ -314,7 +314,7 @@ class ManyToOneTests(TestCase):
|
||||
)
|
||||
self.assertQuerysetEqual(Reporter.objects.filter(article__reporter__exact=self.r).distinct(), john_smith)
|
||||
|
||||
# Check that implied __exact also works.
|
||||
# Implied __exact also works.
|
||||
self.assertQuerysetEqual(Reporter.objects.filter(article__reporter=self.r).distinct(), john_smith)
|
||||
|
||||
# It's possible to use values() calls across many-to-one relations.
|
||||
@ -327,8 +327,8 @@ class ManyToOneTests(TestCase):
|
||||
self.assertEqual([d], list(qs))
|
||||
|
||||
def test_select_related(self):
|
||||
# Check that Article.objects.select_related().dates() works properly when
|
||||
# there are multiple Articles with the same date but different foreign-key
|
||||
# Article.objects.select_related().dates() works properly when there
|
||||
# are multiple Articles with the same date but different foreign-key
|
||||
# objects (Reporters).
|
||||
r1 = Reporter.objects.create(first_name='Mike', last_name='Royko', email='royko@suntimes.com')
|
||||
r2 = Reporter.objects.create(first_name='John', last_name='Kass', email='jkass@tribune.com')
|
||||
@ -567,7 +567,7 @@ class ManyToOneTests(TestCase):
|
||||
self.assertEqual('id', cat.remote_field.get_related_field().name)
|
||||
|
||||
def test_relation_unsaved(self):
|
||||
# Test that the <field>_set manager does not join on Null value fields (#17541)
|
||||
# The <field>_set manager does not join on Null value fields (#17541)
|
||||
Third.objects.create(name='Third 1')
|
||||
Third.objects.create(name='Third 2')
|
||||
th = Third(name="testing")
|
||||
|
@ -102,7 +102,7 @@ class ManyToOneNullTests(TestCase):
|
||||
)
|
||||
|
||||
def test_assign_with_queryset(self):
|
||||
# Ensure that querysets used in reverse FK assignments are pre-evaluated
|
||||
# Querysets used in reverse FK assignments are pre-evaluated
|
||||
# so their value isn't affected by the clearing operation in
|
||||
# RelatedManager.set() (#19816).
|
||||
self.r2.article_set.set([self.a2, self.a3])
|
||||
|
@ -197,8 +197,7 @@ class BaseTests(object):
|
||||
@override_settings(MESSAGE_LEVEL=constants.DEBUG)
|
||||
def test_multiple_posts(self):
|
||||
"""
|
||||
Tests that messages persist properly when multiple POSTs are made
|
||||
before a GET.
|
||||
Messages persist properly when multiple POSTs are made before a GET.
|
||||
"""
|
||||
data = {
|
||||
'messages': ['Test message %d' % x for x in range(5)],
|
||||
@ -229,8 +228,8 @@ class BaseTests(object):
|
||||
)
|
||||
def test_middleware_disabled(self):
|
||||
"""
|
||||
Tests that, when the middleware is disabled, an exception is raised
|
||||
when one attempts to store a message.
|
||||
When the middleware is disabled, an exception is raised when one
|
||||
attempts to store a message.
|
||||
"""
|
||||
data = {
|
||||
'messages': ['Test message %d' % x for x in range(5)],
|
||||
@ -254,8 +253,8 @@ class BaseTests(object):
|
||||
)
|
||||
def test_middleware_disabled_fail_silently(self):
|
||||
"""
|
||||
Tests that, when the middleware is disabled, an exception is not
|
||||
raised if 'fail_silently' = True
|
||||
When the middleware is disabled, an exception is not raised
|
||||
if 'fail_silently' = True
|
||||
"""
|
||||
data = {
|
||||
'messages': ['Test message %d' % x for x in range(5)],
|
||||
@ -285,8 +284,7 @@ class BaseTests(object):
|
||||
|
||||
def test_existing_read(self):
|
||||
"""
|
||||
Tests that reading the existing storage doesn't cause the data to be
|
||||
lost.
|
||||
Reading the existing storage doesn't cause the data to be lost.
|
||||
"""
|
||||
storage = self.get_existing_storage()
|
||||
self.assertFalse(storage.used)
|
||||
|
@ -54,13 +54,13 @@ class CookieTest(BaseTests, SimpleTestCase):
|
||||
# Set initial data.
|
||||
example_messages = ['test', 'me']
|
||||
set_cookie_data(storage, example_messages)
|
||||
# Test that the message actually contains what we expect.
|
||||
# The message actually contains what we expect.
|
||||
self.assertEqual(list(storage), example_messages)
|
||||
|
||||
def test_cookie_setings(self):
|
||||
"""
|
||||
Ensure that CookieStorage honors SESSION_COOKIE_DOMAIN, SESSION_COOKIE_SECURE and SESSION_COOKIE_HTTPONLY
|
||||
Refs #15618 and #20972.
|
||||
CookieStorage honors SESSION_COOKIE_DOMAIN, SESSION_COOKIE_SECURE, and
|
||||
SESSION_COOKIE_HTTPONLY (#15618, #20972).
|
||||
"""
|
||||
# Test before the messages have been consumed
|
||||
storage = self.get_storage()
|
||||
@ -90,14 +90,13 @@ class CookieTest(BaseTests, SimpleTestCase):
|
||||
# Set initial (invalid) data.
|
||||
example_messages = ['test', 'me']
|
||||
set_cookie_data(storage, example_messages, invalid=True)
|
||||
# Test that the message actually contains what we expect.
|
||||
# The message actually contains what we expect.
|
||||
self.assertEqual(list(storage), [])
|
||||
|
||||
def test_max_cookie_length(self):
|
||||
"""
|
||||
Tests that, if the data exceeds what is allowed in a cookie, older
|
||||
messages are removed before saving (and returned by the ``update``
|
||||
method).
|
||||
If the data exceeds what is allowed in a cookie, older messages are
|
||||
removed before saving (and returned by the ``update`` method).
|
||||
"""
|
||||
storage = self.get_storage()
|
||||
response = self.get_response()
|
||||
@ -120,7 +119,7 @@ class CookieTest(BaseTests, SimpleTestCase):
|
||||
|
||||
def test_json_encoder_decoder(self):
|
||||
"""
|
||||
Tests that a complex nested data structure containing Message
|
||||
A complex nested data structure containing Message
|
||||
instances is properly encoded/decoded by the custom JSON
|
||||
encoder/decoder classes.
|
||||
"""
|
||||
@ -140,7 +139,7 @@ class CookieTest(BaseTests, SimpleTestCase):
|
||||
|
||||
def test_safedata(self):
|
||||
"""
|
||||
Tests that a message containing SafeData is keeping its safe status when
|
||||
A message containing SafeData is keeping its safe status when
|
||||
retrieved from the message storage.
|
||||
"""
|
||||
def encode_decode(data):
|
||||
|
@ -25,8 +25,7 @@ class FallbackTest(BaseTests, SimpleTestCase):
|
||||
return storage.storages[-1]
|
||||
|
||||
def stored_cookie_messages_count(self, storage, response):
|
||||
return stored_cookie_messages_count(self.get_cookie_storage(storage),
|
||||
response)
|
||||
return stored_cookie_messages_count(self.get_cookie_storage(storage), response)
|
||||
|
||||
def stored_session_messages_count(self, storage, response):
|
||||
return stored_session_messages_count(self.get_session_storage(storage))
|
||||
@ -35,9 +34,10 @@ class FallbackTest(BaseTests, SimpleTestCase):
|
||||
"""
|
||||
Return the storage totals from both cookie and session backends.
|
||||
"""
|
||||
total = (self.stored_cookie_messages_count(storage, response) +
|
||||
self.stored_session_messages_count(storage, response))
|
||||
return total
|
||||
return (
|
||||
self.stored_cookie_messages_count(storage, response) +
|
||||
self.stored_session_messages_count(storage, response)
|
||||
)
|
||||
|
||||
def test_get(self):
|
||||
request = self.get_request()
|
||||
@ -52,7 +52,6 @@ class FallbackTest(BaseTests, SimpleTestCase):
|
||||
# used (it would cause a TypeError: 'NoneType' object is not callable).
|
||||
self.get_session_storage(storage)._get = None
|
||||
|
||||
# Test that the message actually contains what we expect.
|
||||
self.assertEqual(list(storage), example_messages)
|
||||
|
||||
def test_get_empty(self):
|
||||
@ -63,7 +62,6 @@ class FallbackTest(BaseTests, SimpleTestCase):
|
||||
# used (it would cause a TypeError: 'NoneType' object is not callable).
|
||||
self.get_session_storage(storage)._get = None
|
||||
|
||||
# Test that the message actually contains what we expect.
|
||||
self.assertEqual(list(storage), [])
|
||||
|
||||
def test_get_fallback(self):
|
||||
@ -74,11 +72,9 @@ class FallbackTest(BaseTests, SimpleTestCase):
|
||||
|
||||
# Set initial cookie and session data.
|
||||
example_messages = [str(i) for i in range(5)]
|
||||
set_cookie_data(cookie_storage, example_messages[:4] +
|
||||
[CookieStorage.not_finished])
|
||||
set_cookie_data(cookie_storage, example_messages[:4] + [CookieStorage.not_finished])
|
||||
set_session_data(session_storage, example_messages[4:])
|
||||
|
||||
# Test that the message actually contains what we expect.
|
||||
self.assertEqual(list(storage), example_messages)
|
||||
|
||||
def test_get_fallback_only(self):
|
||||
@ -89,11 +85,9 @@ class FallbackTest(BaseTests, SimpleTestCase):
|
||||
|
||||
# Set initial cookie and session data.
|
||||
example_messages = [str(i) for i in range(5)]
|
||||
set_cookie_data(cookie_storage, [CookieStorage.not_finished],
|
||||
encode_empty=True)
|
||||
set_cookie_data(cookie_storage, [CookieStorage.not_finished], encode_empty=True)
|
||||
set_session_data(session_storage, example_messages)
|
||||
|
||||
# Test that the message actually contains what we expect.
|
||||
self.assertEqual(list(storage), example_messages)
|
||||
|
||||
def test_flush_used_backends(self):
|
||||
@ -116,8 +110,6 @@ class FallbackTest(BaseTests, SimpleTestCase):
|
||||
|
||||
def test_no_fallback(self):
|
||||
"""
|
||||
Confirms that:
|
||||
|
||||
(1) A short number of messages whose data size doesn't exceed what is
|
||||
allowed in a cookie will all be stored in the CookieBackend.
|
||||
|
||||
@ -142,8 +134,8 @@ class FallbackTest(BaseTests, SimpleTestCase):
|
||||
|
||||
def test_session_fallback(self):
|
||||
"""
|
||||
Confirms that, if the data exceeds what is allowed in a cookie,
|
||||
messages which did not fit are stored in the SessionBackend.
|
||||
If the data exceeds what is allowed in a cookie, messages which did
|
||||
not fit are stored in the SessionBackend.
|
||||
"""
|
||||
storage = self.get_storage()
|
||||
response = self.get_response()
|
||||
@ -161,8 +153,8 @@ class FallbackTest(BaseTests, SimpleTestCase):
|
||||
|
||||
def test_session_fallback_only(self):
|
||||
"""
|
||||
Confirms that large messages, none of which fit in a cookie, are stored
|
||||
in the SessionBackend (and nothing is stored in the CookieBackend).
|
||||
Large messages, none of which fit in a cookie, are stored in the
|
||||
SessionBackend (and nothing is stored in the CookieBackend).
|
||||
"""
|
||||
storage = self.get_storage()
|
||||
response = self.get_response()
|
||||
|
@ -36,19 +36,16 @@ class SessionTest(BaseTests, TestCase):
|
||||
|
||||
def test_get(self):
|
||||
storage = self.storage_class(self.get_request())
|
||||
# Set initial data.
|
||||
example_messages = ['test', 'me']
|
||||
set_session_data(storage, example_messages)
|
||||
# Test that the message actually contains what we expect.
|
||||
self.assertEqual(list(storage), example_messages)
|
||||
|
||||
def test_safedata(self):
|
||||
"""
|
||||
Tests that a message containing SafeData is keeping its safe status when
|
||||
retrieved from the message storage.
|
||||
A message containing SafeData keeps its safe status when retrieved from
|
||||
the message storage.
|
||||
"""
|
||||
storage = self.get_storage()
|
||||
|
||||
message = Message(constants.DEBUG, mark_safe("<b>Hello Django!</b>"))
|
||||
set_session_data(storage, [message])
|
||||
self.assertIsInstance(list(storage)[0].message, SafeData)
|
||||
|
@ -98,7 +98,7 @@ class CommonMiddlewareTest(SimpleTestCase):
|
||||
@override_settings(APPEND_SLASH=True, DEBUG=True)
|
||||
def test_append_slash_no_redirect_on_POST_in_DEBUG(self):
|
||||
"""
|
||||
Tests that while in debug mode, an exception is raised with a warning
|
||||
While in debug mode, an exception is raised with a warning
|
||||
when a failed attempt is made to POST, PUT, or PATCH to an URL which
|
||||
would normally be redirected to a slashed version.
|
||||
"""
|
||||
@ -210,7 +210,7 @@ class CommonMiddlewareTest(SimpleTestCase):
|
||||
@override_settings(APPEND_SLASH=True, DEBUG=True)
|
||||
def test_append_slash_no_redirect_on_POST_in_DEBUG_custom_urlconf(self):
|
||||
"""
|
||||
Tests that while in debug mode, an exception is raised with a warning
|
||||
While in debug mode, an exception is raised with a warning
|
||||
when a failed attempt is made to POST to an URL which would normally be
|
||||
redirected to a slashed version.
|
||||
"""
|
||||
|
@ -206,7 +206,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||
@ -220,7 +220,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||
@ -234,7 +234,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||
@ -248,7 +248,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/template_response/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, True, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, True, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, True, True, False)
|
||||
@ -262,7 +262,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||
@ -276,7 +276,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||
@ -290,7 +290,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||
@ -304,7 +304,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -318,7 +318,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -332,7 +332,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -346,7 +346,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/error/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||
@ -360,7 +360,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/error/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||
@ -374,7 +374,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Error in view'], Exception())
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -388,7 +388,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/error/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -402,7 +402,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/null_view/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||
@ -416,7 +416,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/null_view/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||
@ -436,7 +436,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
ValueError()
|
||||
)
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||
@ -456,7 +456,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
ValueError()
|
||||
)
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||
@ -470,7 +470,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||
@ -484,7 +484,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||
@ -498,7 +498,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -512,7 +512,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -522,7 +522,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/template_response_error/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(middleware, True, True, True, True, False)
|
||||
|
||||
def test_templateresponse_from_process_view_rendered(self):
|
||||
@ -561,7 +561,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/view/', ['Test Request Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||
@ -575,7 +575,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/view/', ['Test View Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||
@ -592,7 +592,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
['Test Template Response Exception']
|
||||
)
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, True, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, True, True, False)
|
||||
@ -606,7 +606,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/view/', ['Test Response Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, False, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||
@ -620,7 +620,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||
@ -634,7 +634,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test Request Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||
@ -648,7 +648,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test View Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||
@ -662,7 +662,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test Response Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, False, True)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -676,7 +676,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test Exception Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -690,7 +690,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Test Request Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||
@ -704,7 +704,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Test View Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||
@ -718,7 +718,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Error in view', 'Test Response Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, False, True)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -732,7 +732,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Test Exception Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -746,7 +746,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/null_view/', ['Test Request Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||
@ -760,7 +760,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/null_view/', ['Test View Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||
@ -780,7 +780,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
]
|
||||
)
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, False, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||
@ -800,7 +800,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
ValueError()
|
||||
)
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||
@ -814,7 +814,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test Request Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||
@ -828,7 +828,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test View Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||
@ -842,7 +842,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test Response Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, False, True)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -856,7 +856,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
self._add_middleware(pre_middleware)
|
||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test Exception Exception'])
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||
@ -873,7 +873,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
],
|
||||
ValueError())
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, False, False)
|
||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||
@ -893,7 +893,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||
ValueError()
|
||||
)
|
||||
|
||||
# Check that the right middleware methods have been invoked
|
||||
# The right middleware methods have been invoked
|
||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||
self.assert_middleware_usage(middleware, True, True, True, True, False)
|
||||
self.assert_middleware_usage(post_middleware, True, True, True, True, False)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user