Fixed E124 pep8 warnings.
This commit is contained in:
parent
0873200e7f
commit
a2814846ca
|
@ -42,7 +42,8 @@ class AdminForm(object):
|
|||
|
||||
def __iter__(self):
|
||||
for name, options in self.fieldsets:
|
||||
yield Fieldset(self.form, name,
|
||||
yield Fieldset(
|
||||
self.form, name,
|
||||
readonly_fields=self.readonly_fields,
|
||||
model_admin=self.model_admin,
|
||||
**options
|
||||
|
|
|
@ -1520,7 +1520,8 @@ class ModelAdmin(BaseModelAdmin):
|
|||
selection_note_all = ungettext('%(total_count)s selected',
|
||||
'All %(total_count)s selected', cl.result_count)
|
||||
|
||||
context = dict(self.admin_site.each_context(),
|
||||
context = dict(
|
||||
self.admin_site.each_context(),
|
||||
module_name=force_text(opts.verbose_name_plural),
|
||||
selection_note=_('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
|
||||
selection_note_all=selection_note_all % {'total_count': cl.result_count},
|
||||
|
@ -1587,7 +1588,8 @@ class ModelAdmin(BaseModelAdmin):
|
|||
else:
|
||||
title = _("Are you sure?")
|
||||
|
||||
context = dict(self.admin_site.each_context(),
|
||||
context = dict(
|
||||
self.admin_site.each_context(),
|
||||
title=title,
|
||||
object_name=object_name,
|
||||
object=obj,
|
||||
|
|
|
@ -398,7 +398,8 @@ class AdminSite(object):
|
|||
for app in app_list:
|
||||
app['models'].sort(key=lambda x: x['name'])
|
||||
|
||||
context = dict(self.each_context(),
|
||||
context = dict(
|
||||
self.each_context(),
|
||||
title=self.index_title,
|
||||
app_list=app_list,
|
||||
)
|
||||
|
|
|
@ -95,7 +95,8 @@ def result_headers(cl):
|
|||
"""
|
||||
ordering_field_columns = cl.get_ordering_field_columns()
|
||||
for i, field_name in enumerate(cl.list_display):
|
||||
text, attr = label_for_field(field_name, cl.model,
|
||||
text, attr = label_for_field(
|
||||
field_name, cl.model,
|
||||
model_admin=cl.model_admin,
|
||||
return_attr=True
|
||||
)
|
||||
|
|
|
@ -21,7 +21,8 @@ class TestFieldType(unittest.TestCase):
|
|||
pass
|
||||
|
||||
def test_field_name(self):
|
||||
self.assertRaises(AttributeError,
|
||||
self.assertRaises(
|
||||
AttributeError,
|
||||
views.get_readable_field_data_type, "NotAField"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,38 +4,29 @@ from django.contrib.admindocs import views
|
|||
urlpatterns = patterns('',
|
||||
url('^$',
|
||||
views.BaseAdminDocsView.as_view(template_name='admin_doc/index.html'),
|
||||
name='django-admindocs-docroot'
|
||||
),
|
||||
name='django-admindocs-docroot'),
|
||||
url('^bookmarklets/$',
|
||||
views.BookmarkletsView.as_view(),
|
||||
name='django-admindocs-bookmarklets'
|
||||
),
|
||||
name='django-admindocs-bookmarklets'),
|
||||
url('^tags/$',
|
||||
views.TemplateTagIndexView.as_view(),
|
||||
name='django-admindocs-tags'
|
||||
),
|
||||
name='django-admindocs-tags'),
|
||||
url('^filters/$',
|
||||
views.TemplateFilterIndexView.as_view(),
|
||||
name='django-admindocs-filters'
|
||||
),
|
||||
name='django-admindocs-filters'),
|
||||
url('^views/$',
|
||||
views.ViewIndexView.as_view(),
|
||||
name='django-admindocs-views-index'
|
||||
),
|
||||
name='django-admindocs-views-index'),
|
||||
url('^views/(?P<view>[^/]+)/$',
|
||||
views.ViewDetailView.as_view(),
|
||||
name='django-admindocs-views-detail'
|
||||
),
|
||||
name='django-admindocs-views-detail'),
|
||||
url('^models/$',
|
||||
views.ModelIndexView.as_view(),
|
||||
name='django-admindocs-models-index'
|
||||
),
|
||||
name='django-admindocs-models-index'),
|
||||
url('^models/(?P<app_label>[^\.]+)\.(?P<model_name>[^/]+)/$',
|
||||
views.ModelDetailView.as_view(),
|
||||
name='django-admindocs-models-detail'
|
||||
),
|
||||
name='django-admindocs-models-detail'),
|
||||
url('^templates/(?P<template>.*)/$',
|
||||
views.TemplateDetailView.as_view(),
|
||||
name='django-admindocs-templates'
|
||||
),
|
||||
name='django-admindocs-templates'),
|
||||
)
|
||||
|
|
|
@ -48,8 +48,8 @@ class UserAdmin(admin.ModelAdmin):
|
|||
add_fieldsets = (
|
||||
(None, {
|
||||
'classes': ('wide',),
|
||||
'fields': ('username', 'password1', 'password2')}
|
||||
),
|
||||
'fields': ('username', 'password1', 'password2'),
|
||||
}),
|
||||
)
|
||||
form = UserChangeForm
|
||||
add_form = UserCreationForm
|
||||
|
|
|
@ -130,7 +130,8 @@ class BasicTestCase(TestCase):
|
|||
"Check the operation of the createsuperuser management command"
|
||||
# We can use the management command to create a superuser
|
||||
new_io = StringIO()
|
||||
call_command("createsuperuser",
|
||||
call_command(
|
||||
"createsuperuser",
|
||||
interactive=False,
|
||||
username="joe",
|
||||
email="joe@somewhere.org",
|
||||
|
@ -146,7 +147,8 @@ class BasicTestCase(TestCase):
|
|||
|
||||
# We can supress output on the management command
|
||||
new_io = StringIO()
|
||||
call_command("createsuperuser",
|
||||
call_command(
|
||||
"createsuperuser",
|
||||
interactive=False,
|
||||
username="joe2",
|
||||
email="joe2@somewhere.org",
|
||||
|
@ -159,7 +161,8 @@ class BasicTestCase(TestCase):
|
|||
self.assertEqual(u.email, 'joe2@somewhere.org')
|
||||
self.assertFalse(u.has_usable_password())
|
||||
|
||||
call_command("createsuperuser",
|
||||
call_command(
|
||||
"createsuperuser",
|
||||
interactive=False,
|
||||
username="joe+admin@somewhere.org",
|
||||
email="joe@somewhere.org",
|
||||
|
@ -182,7 +185,8 @@ class BasicTestCase(TestCase):
|
|||
locale.getdefaultlocale = lambda: (None, None)
|
||||
|
||||
# Call the command in this new environment
|
||||
call_command("createsuperuser",
|
||||
call_command(
|
||||
"createsuperuser",
|
||||
interactive=True,
|
||||
username="nolocale@somewhere.org",
|
||||
email="nolocale@somewhere.org",
|
||||
|
@ -212,7 +216,8 @@ class BasicTestCase(TestCase):
|
|||
username_field.verbose_name = ulazy('uživatel')
|
||||
new_io = StringIO()
|
||||
try:
|
||||
call_command("createsuperuser",
|
||||
call_command(
|
||||
"createsuperuser",
|
||||
interactive=True,
|
||||
stdout=new_io
|
||||
)
|
||||
|
|
|
@ -91,7 +91,8 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
|
|||
"Check the operation of the createsuperuser management command"
|
||||
# We can use the management command to create a superuser
|
||||
new_io = StringIO()
|
||||
call_command("createsuperuser",
|
||||
call_command(
|
||||
"createsuperuser",
|
||||
interactive=False,
|
||||
username="joe",
|
||||
email="joe@somewhere.org",
|
||||
|
@ -108,7 +109,8 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
|
|||
def test_verbosity_zero(self):
|
||||
# We can supress output on the management command
|
||||
new_io = StringIO()
|
||||
call_command("createsuperuser",
|
||||
call_command(
|
||||
"createsuperuser",
|
||||
interactive=False,
|
||||
username="joe2",
|
||||
email="joe2@somewhere.org",
|
||||
|
@ -123,7 +125,8 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
|
|||
|
||||
def test_email_in_username(self):
|
||||
new_io = StringIO()
|
||||
call_command("createsuperuser",
|
||||
call_command(
|
||||
"createsuperuser",
|
||||
interactive=False,
|
||||
username="joe+admin@somewhere.org",
|
||||
email="joe@somewhere.org",
|
||||
|
@ -140,7 +143,8 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
|
|||
# We skip validation because the temporary substitution of the
|
||||
# swappable User model messes with validation.
|
||||
new_io = StringIO()
|
||||
call_command("createsuperuser",
|
||||
call_command(
|
||||
"createsuperuser",
|
||||
interactive=False,
|
||||
email="joe@somewhere.org",
|
||||
date_of_birth="1976-04-01",
|
||||
|
@ -163,7 +167,8 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
|
|||
# swappable User model messes with validation.
|
||||
new_io = StringIO()
|
||||
with self.assertRaises(CommandError):
|
||||
call_command("createsuperuser",
|
||||
call_command(
|
||||
"createsuperuser",
|
||||
interactive=False,
|
||||
username="joe@somewhere.org",
|
||||
stdout=new_io,
|
||||
|
|
|
@ -452,9 +452,10 @@ class BaseGenericInlineFormSet(BaseModelFormSet):
|
|||
@classmethod
|
||||
def get_default_prefix(cls):
|
||||
opts = cls.model._meta
|
||||
return '-'.join((opts.app_label, opts.model_name,
|
||||
cls.ct_field.name, cls.ct_fk_field.name,
|
||||
))
|
||||
return '-'.join(
|
||||
(opts.app_label, opts.model_name,
|
||||
cls.ct_field.name, cls.ct_fk_field.name)
|
||||
)
|
||||
|
||||
def save_new(self, form, commit=True):
|
||||
setattr(form.instance, self.ct_field.get_attname(),
|
||||
|
|
|
@ -362,12 +362,14 @@ class GeoQuerySet(QuerySet):
|
|||
relative = int(bool(relative))
|
||||
if not isinstance(precision, six.integer_types):
|
||||
raise TypeError('SVG precision keyword argument must be an integer.')
|
||||
s = {'desc': 'SVG',
|
||||
'procedure_fmt': '%(geo_col)s,%(rel)s,%(precision)s',
|
||||
'procedure_args': {'rel': relative,
|
||||
'precision': precision,
|
||||
}
|
||||
}
|
||||
s = {
|
||||
'desc': 'SVG',
|
||||
'procedure_fmt': '%(geo_col)s,%(rel)s,%(precision)s',
|
||||
'procedure_args': {
|
||||
'rel': relative,
|
||||
'precision': precision,
|
||||
}
|
||||
}
|
||||
return self._spatial_attribute('svg', s, **kwargs)
|
||||
|
||||
def sym_difference(self, geom, **kwargs):
|
||||
|
@ -746,11 +748,12 @@ class GeoQuerySet(QuerySet):
|
|||
for geometry set-like operations (e.g., intersection, difference,
|
||||
union, sym_difference).
|
||||
"""
|
||||
s = {'geom_args': ('geom',),
|
||||
'select_field': GeomField(),
|
||||
'procedure_fmt': '%(geo_col)s,%(geom)s',
|
||||
'procedure_args': {'geom': geom},
|
||||
}
|
||||
s = {
|
||||
'geom_args': ('geom',),
|
||||
'select_field': GeomField(),
|
||||
'procedure_fmt': '%(geo_col)s,%(geom)s',
|
||||
'procedure_args': {'geom': geom},
|
||||
}
|
||||
if connections[self.db].ops.oracle:
|
||||
s['procedure_fmt'] += ',%(tolerance)s'
|
||||
s['procedure_args']['tolerance'] = tolerance
|
||||
|
|
|
@ -66,7 +66,8 @@ class BaseGeometryWidget(Widget):
|
|||
value.srid, self.map_srid, err)
|
||||
)
|
||||
|
||||
context = self.build_attrs(attrs,
|
||||
context = self.build_attrs(
|
||||
attrs,
|
||||
name=name,
|
||||
module='geodjango_%s' % name.replace('-', '_'), # JS-safe
|
||||
serialized=self.serialize(value),
|
||||
|
|
|
@ -33,10 +33,11 @@ class GeoRegressionTests(TestCase):
|
|||
def test_kmz(self):
|
||||
"Testing `render_to_kmz` with non-ASCII data. See #11624."
|
||||
name = "Åland Islands"
|
||||
places = [{'name': name,
|
||||
'description': name,
|
||||
'kml': '<Point><coordinates>5.0,23.0</coordinates></Point>'
|
||||
}]
|
||||
places = [{
|
||||
'name': name,
|
||||
'description': name,
|
||||
'kml': '<Point><coordinates>5.0,23.0</coordinates></Point>'
|
||||
}]
|
||||
render_to_kmz('gis/kml/placemarks.kml', {'places': places})
|
||||
|
||||
@no_spatialite
|
||||
|
|
|
@ -37,7 +37,8 @@ class Command(BaseCommand):
|
|||
# multiple times.
|
||||
shutdown_message = '\nServer stopped.\nNote that the test database, %r, has not been deleted. You can explore it on your own.' % db_name
|
||||
use_threading = connection.features.test_db_allows_multiple_connections
|
||||
call_command('runserver',
|
||||
call_command(
|
||||
'runserver',
|
||||
addrport=addrport,
|
||||
shutdown_message=shutdown_message,
|
||||
use_reloader=False,
|
||||
|
|
|
@ -270,8 +270,7 @@ def get_validation_errors(outfile, app=None):
|
|||
seen_to = True
|
||||
if f.rel.through not in models.get_models(include_auto_created=True):
|
||||
e.add(opts, "'%s' specifies an m2m relation through model "
|
||||
"%s, which has not been installed." % (f.name, f.rel.through)
|
||||
)
|
||||
"%s, which has not been installed." % (f.name, f.rel.through))
|
||||
signature = (f.rel.to, cls, f.rel.through)
|
||||
if signature in seen_intermediary_signatures:
|
||||
e.add(opts, "The model %s has two manually-defined m2m "
|
||||
|
@ -295,13 +294,14 @@ def get_validation_errors(outfile, app=None):
|
|||
if not seen_related_fk or not seen_this_fk:
|
||||
e.add(opts, "'%s' is a manually-defined m2m relation "
|
||||
"through model %s, which does not have foreign keys "
|
||||
"to %s and %s" % (f.name, f.rel.through._meta.object_name,
|
||||
f.rel.to._meta.object_name, cls._meta.object_name)
|
||||
"to %s and %s" % (
|
||||
f.name, f.rel.through._meta.object_name,
|
||||
f.rel.to._meta.object_name, cls._meta.object_name
|
||||
)
|
||||
)
|
||||
elif isinstance(f.rel.through, six.string_types):
|
||||
e.add(opts, "'%s' specifies an m2m relation through model %s, "
|
||||
"which has not been installed" % (f.name, f.rel.through)
|
||||
)
|
||||
"which has not been installed" % (f.name, f.rel.through))
|
||||
|
||||
rel_opts = f.rel.to._meta
|
||||
rel_name = f.related.get_accessor_name()
|
||||
|
|
|
@ -1215,8 +1215,7 @@ class BaseDatabaseOperations(object):
|
|||
|
||||
# Structure returned by the DB-API cursor.description interface (PEP 249)
|
||||
FieldInfo = namedtuple('FieldInfo',
|
||||
'name type_code display_size internal_size precision scale null_ok'
|
||||
)
|
||||
'name type_code display_size internal_size precision scale null_ok')
|
||||
|
||||
|
||||
class BaseDatabaseIntrospection(object):
|
||||
|
|
|
@ -332,13 +332,15 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||
# Truncate already resets the AUTO_INCREMENT field from
|
||||
# MySQL version 5.0.13 onwards. Refs #16961.
|
||||
if self.connection.mysql_version < (5, 0, 13):
|
||||
return ["%s %s %s %s %s;" %
|
||||
(style.SQL_KEYWORD('ALTER'),
|
||||
return [
|
||||
"%s %s %s %s %s;" % (
|
||||
style.SQL_KEYWORD('ALTER'),
|
||||
style.SQL_KEYWORD('TABLE'),
|
||||
style.SQL_TABLE(self.quote_name(sequence['table'])),
|
||||
style.SQL_KEYWORD('AUTO_INCREMENT'),
|
||||
style.SQL_FIELD('= 1'),
|
||||
) for sequence in sequences]
|
||||
) for sequence in sequences
|
||||
]
|
||||
else:
|
||||
return []
|
||||
|
||||
|
|
|
@ -168,7 +168,8 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||
# notification. If we don't set self.connection to None, the error
|
||||
# will occur a every request.
|
||||
self.connection = None
|
||||
logger.warning('psycopg2 error while closing the connection.',
|
||||
logger.warning(
|
||||
'psycopg2 error while closing the connection.',
|
||||
exc_info=sys.exc_info()
|
||||
)
|
||||
raise
|
||||
|
|
|
@ -176,12 +176,14 @@ class MigrationOptimizer(object):
|
|||
Folds a model rename into its create
|
||||
"""
|
||||
if operation.name.lower() == other.old_name.lower():
|
||||
return [migrations.CreateModel(
|
||||
other.new_name,
|
||||
fields=operation.fields,
|
||||
options=operation.options,
|
||||
bases=operation.bases,
|
||||
)]
|
||||
return [
|
||||
migrations.CreateModel(
|
||||
other.new_name,
|
||||
fields=operation.fields,
|
||||
options=operation.options,
|
||||
bases=operation.bases,
|
||||
)
|
||||
]
|
||||
|
||||
def reduce_model_rename_self(self, operation, other):
|
||||
"""
|
||||
|
@ -197,57 +199,67 @@ class MigrationOptimizer(object):
|
|||
|
||||
def reduce_create_model_add_field(self, operation, other):
|
||||
if operation.name.lower() == other.model_name.lower():
|
||||
return [migrations.CreateModel(
|
||||
operation.name,
|
||||
fields=operation.fields + [(other.name, other.field)],
|
||||
options=operation.options,
|
||||
bases=operation.bases,
|
||||
)]
|
||||
return [
|
||||
migrations.CreateModel(
|
||||
operation.name,
|
||||
fields=operation.fields + [(other.name, other.field)],
|
||||
options=operation.options,
|
||||
bases=operation.bases,
|
||||
)
|
||||
]
|
||||
|
||||
def reduce_create_model_alter_field(self, operation, other):
|
||||
if operation.name.lower() == other.model_name.lower():
|
||||
return [migrations.CreateModel(
|
||||
operation.name,
|
||||
fields=[
|
||||
(n, other.field if n == other.name else v)
|
||||
for n, v in operation.fields
|
||||
],
|
||||
options=operation.options,
|
||||
bases=operation.bases,
|
||||
)]
|
||||
return [
|
||||
migrations.CreateModel(
|
||||
operation.name,
|
||||
fields=[
|
||||
(n, other.field if n == other.name else v)
|
||||
for n, v in operation.fields
|
||||
],
|
||||
options=operation.options,
|
||||
bases=operation.bases,
|
||||
)
|
||||
]
|
||||
|
||||
def reduce_create_model_rename_field(self, operation, other):
|
||||
if operation.name.lower() == other.model_name.lower():
|
||||
return [migrations.CreateModel(
|
||||
operation.name,
|
||||
fields=[
|
||||
(other.new_name if n == other.old_name else n, v)
|
||||
for n, v in operation.fields
|
||||
],
|
||||
options=operation.options,
|
||||
bases=operation.bases,
|
||||
)]
|
||||
return [
|
||||
migrations.CreateModel(
|
||||
operation.name,
|
||||
fields=[
|
||||
(other.new_name if n == other.old_name else n, v)
|
||||
for n, v in operation.fields
|
||||
],
|
||||
options=operation.options,
|
||||
bases=operation.bases,
|
||||
)
|
||||
]
|
||||
|
||||
def reduce_create_model_remove_field(self, operation, other):
|
||||
if operation.name.lower() == other.model_name.lower():
|
||||
return [migrations.CreateModel(
|
||||
operation.name,
|
||||
fields=[
|
||||
(n, v)
|
||||
for n, v in operation.fields
|
||||
if n.lower() != other.name.lower()
|
||||
],
|
||||
options=operation.options,
|
||||
bases=operation.bases,
|
||||
)]
|
||||
return [
|
||||
migrations.CreateModel(
|
||||
operation.name,
|
||||
fields=[
|
||||
(n, v)
|
||||
for n, v in operation.fields
|
||||
if n.lower() != other.name.lower()
|
||||
],
|
||||
options=operation.options,
|
||||
bases=operation.bases,
|
||||
)
|
||||
]
|
||||
|
||||
def reduce_add_field_alter_field(self, operation, other):
|
||||
if operation.model_name.lower() == other.model_name.lower() and operation.name.lower() == other.name.lower():
|
||||
return [migrations.AddField(
|
||||
model_name=operation.model_name,
|
||||
name=operation.name,
|
||||
field=other.field,
|
||||
)]
|
||||
return [
|
||||
migrations.AddField(
|
||||
model_name=operation.model_name,
|
||||
name=operation.name,
|
||||
field=other.field,
|
||||
)
|
||||
]
|
||||
|
||||
def reduce_add_field_delete_field(self, operation, other):
|
||||
if operation.model_name.lower() == other.model_name.lower() and operation.name.lower() == other.name.lower():
|
||||
|
@ -259,11 +271,13 @@ class MigrationOptimizer(object):
|
|||
|
||||
def reduce_add_field_rename_field(self, operation, other):
|
||||
if operation.model_name.lower() == other.model_name.lower() and operation.name.lower() == other.old_name.lower():
|
||||
return [migrations.AddField(
|
||||
model_name=operation.model_name,
|
||||
name=other.new_name,
|
||||
field=operation.field,
|
||||
)]
|
||||
return [
|
||||
migrations.AddField(
|
||||
model_name=operation.model_name,
|
||||
name=other.new_name,
|
||||
field=operation.field,
|
||||
)
|
||||
]
|
||||
|
||||
def reduce_alter_field_rename_field(self, operation, other):
|
||||
if operation.model_name.lower() == other.model_name.lower() and operation.name.lower() == other.old_name.lower():
|
||||
|
|
|
@ -1686,8 +1686,7 @@ class BinaryField(Field):
|
|||
return default
|
||||
|
||||
def get_db_prep_value(self, value, connection, prepared=False):
|
||||
value = super(BinaryField, self
|
||||
).get_db_prep_value(value, connection, prepared)
|
||||
value = super(BinaryField, self).get_db_prep_value(value, connection, prepared)
|
||||
if value is not None:
|
||||
return connection.Database.Binary(value)
|
||||
return value
|
||||
|
|
|
@ -963,8 +963,7 @@ class OneToOneRel(ManyToOneRel):
|
|||
parent_link=False, on_delete=None, related_query_name=None):
|
||||
super(OneToOneRel, self).__init__(field, to, field_name,
|
||||
related_name=related_name, limit_choices_to=limit_choices_to,
|
||||
parent_link=parent_link, on_delete=on_delete, related_query_name=related_query_name,
|
||||
)
|
||||
parent_link=parent_link, on_delete=on_delete, related_query_name=related_query_name)
|
||||
self.multiple = False
|
||||
|
||||
|
||||
|
|
|
@ -52,11 +52,10 @@ class ErrorDict(dict):
|
|||
def as_ul(self):
|
||||
if not self:
|
||||
return ''
|
||||
return format_html('<ul class="errorlist">{0}</ul>',
|
||||
format_html_join('', '<li>{0}{1}</li>',
|
||||
((k, force_text(v))
|
||||
for k, v in self.items())
|
||||
))
|
||||
return format_html(
|
||||
'<ul class="errorlist">{0}</ul>',
|
||||
format_html_join('', '<li>{0}{1}</li>', ((k, force_text(v)) for k, v in self.items()))
|
||||
)
|
||||
|
||||
def as_text(self):
|
||||
return '\n'.join('* %s\n%s' % (k, '\n'.join(' * %s' % force_text(i) for i in v)) for k, v in self.items())
|
||||
|
@ -73,11 +72,10 @@ class ErrorList(list):
|
|||
def as_ul(self):
|
||||
if not self:
|
||||
return ''
|
||||
return format_html('<ul class="errorlist">{0}</ul>',
|
||||
format_html_join('', '<li>{0}</li>',
|
||||
((force_text(e),) for e in self)
|
||||
)
|
||||
)
|
||||
return format_html(
|
||||
'<ul class="errorlist">{0}</ul>',
|
||||
format_html_join('', '<li>{0}</li>', ((force_text(e),) for e in self))
|
||||
)
|
||||
|
||||
def as_text(self):
|
||||
if not self:
|
||||
|
|
|
@ -72,7 +72,7 @@ class Media(object):
|
|||
return path
|
||||
if prefix is None:
|
||||
if settings.STATIC_URL is None:
|
||||
# backwards compatibility
|
||||
# backwards compatibility
|
||||
prefix = settings.MEDIA_URL
|
||||
else:
|
||||
prefix = settings.STATIC_URL
|
||||
|
|
|
@ -3,7 +3,8 @@ Django Unit Test and Doctest framework.
|
|||
"""
|
||||
|
||||
from django.test.client import Client, RequestFactory
|
||||
from django.test.testcases import (TestCase, TransactionTestCase,
|
||||
from django.test.testcases import (
|
||||
TestCase, TransactionTestCase,
|
||||
SimpleTestCase, LiveServerTestCase, skipIfDBFeature,
|
||||
skipUnlessDBFeature
|
||||
)
|
||||
|
|
|
@ -123,8 +123,7 @@ def get_tests(app_module):
|
|||
def make_doctest(module):
|
||||
return doctest.DocTestSuite(module,
|
||||
checker=doctestOutputChecker,
|
||||
runner=DocTestRunner,
|
||||
)
|
||||
runner=DocTestRunner)
|
||||
|
||||
|
||||
def build_suite(app_module):
|
||||
|
|
|
@ -268,8 +268,7 @@ def phone2numeric(phone):
|
|||
char2number = {'a': '2', 'b': '2', 'c': '2', 'd': '3', 'e': '3', 'f': '3',
|
||||
'g': '4', 'h': '4', 'i': '4', 'j': '5', 'k': '5', 'l': '5', 'm': '6',
|
||||
'n': '6', 'o': '6', 'p': '7', 'q': '7', 'r': '7', 's': '7', 't': '8',
|
||||
'u': '8', 'v': '8', 'w': '9', 'x': '9', 'y': '9', 'z': '9',
|
||||
}
|
||||
'u': '8', 'v': '8', 'w': '9', 'x': '9', 'y': '9', 'z': '9'}
|
||||
return ''.join(char2number.get(c, c) for c in phone.lower())
|
||||
phone2numeric = allow_lazy(phone2numeric)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
|
|||
|
||||
[flake8]
|
||||
exclude=.git,./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./django/utils/lru_cache.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py,./django/conf/app_template/*
|
||||
ignore=E124,E127,E128,E501,W601
|
||||
ignore=E127,E128,E501,W601
|
||||
|
||||
[metadata]
|
||||
license-file = LICENSE
|
||||
|
|
|
@ -38,7 +38,8 @@ class MultiDBCreatesuperuserTestCase(TestCase):
|
|||
" createsuperuser command should operate on specified DB"
|
||||
new_io = StringIO()
|
||||
|
||||
call_command("createsuperuser",
|
||||
call_command(
|
||||
"createsuperuser",
|
||||
interactive=False,
|
||||
username="joe",
|
||||
email="joe@somewhere.org",
|
||||
|
|
|
@ -42,7 +42,8 @@ class CustomColumnsTests(TestCase):
|
|||
)
|
||||
|
||||
def test_field_error(self):
|
||||
self.assertRaises(FieldError,
|
||||
self.assertRaises(
|
||||
FieldError,
|
||||
lambda: Author.objects.filter(firstname__exact="John")
|
||||
)
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ class CustomPKTests(TestCase):
|
|||
self.assertEqual(Employee.objects.get(pk=123), dan)
|
||||
self.assertEqual(Employee.objects.get(pk=456), fran)
|
||||
|
||||
self.assertRaises(Employee.DoesNotExist,
|
||||
self.assertRaises(
|
||||
Employee.DoesNotExist,
|
||||
lambda: Employee.objects.get(pk=42)
|
||||
)
|
||||
|
||||
|
|
|
@ -91,14 +91,18 @@ class ExtraRegressTests(TestCase):
|
|||
internal dictionary must remain sorted.
|
||||
"""
|
||||
self.assertEqual(
|
||||
User.objects.extra(select={"alpha": "%s"}, select_params=(1,)
|
||||
).extra(select={"beta": "%s"}, select_params=(2,))[0].alpha,
|
||||
1)
|
||||
(User.objects
|
||||
.extra(select={"alpha": "%s"}, select_params=(1,))
|
||||
.extra(select={"beta": "%s"}, select_params=(2,))[0].alpha),
|
||||
1
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
User.objects.extra(select={"beta": "%s"}, select_params=(1,)
|
||||
).extra(select={"alpha": "%s"}, select_params=(2,))[0].alpha,
|
||||
2)
|
||||
(User.objects
|
||||
.extra(select={"beta": "%s"}, select_params=(1,))
|
||||
.extra(select={"alpha": "%s"}, select_params=(2,))[0].alpha),
|
||||
2
|
||||
)
|
||||
|
||||
def test_regression_7961(self):
|
||||
"""
|
||||
|
@ -107,8 +111,10 @@ class ExtraRegressTests(TestCase):
|
|||
query as well.
|
||||
"""
|
||||
self.assertEqual(
|
||||
list(User.objects.extra(select={"alpha": "%s"}, select_params=(-6,)
|
||||
).filter(id=self.u.id).values_list('id', flat=True)),
|
||||
list(User.objects
|
||||
.extra(select={"alpha": "%s"}, select_params=(-6,))
|
||||
.filter(id=self.u.id)
|
||||
.values_list('id', flat=True)),
|
||||
[self.u.id]
|
||||
)
|
||||
|
||||
|
@ -129,10 +135,9 @@ class ExtraRegressTests(TestCase):
|
|||
should still be present because of the extra() call.
|
||||
"""
|
||||
self.assertQuerysetEqual(
|
||||
Order.objects.extra(where=["username=%s"],
|
||||
params=["fred"],
|
||||
tables=["auth_user"]
|
||||
).order_by('created_by'),
|
||||
(Order.objects
|
||||
.extra(where=["username=%s"], params=["fred"], tables=["auth_user"])
|
||||
.order_by('created_by')),
|
||||
[]
|
||||
)
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ class GetObjectOr404Tests(TestCase):
|
|||
)
|
||||
|
||||
# No articles containing "Camelot". This should raise a Http404 error.
|
||||
self.assertRaises(Http404,
|
||||
self.assertRaises(
|
||||
Http404,
|
||||
get_object_or_404, a1.article_set, title__contains="Camelot"
|
||||
)
|
||||
|
||||
|
@ -49,12 +50,14 @@ class GetObjectOr404Tests(TestCase):
|
|||
# Just as when using a get() lookup, you will get an error if more than
|
||||
# one object is returned.
|
||||
|
||||
self.assertRaises(Author.MultipleObjectsReturned,
|
||||
self.assertRaises(
|
||||
Author.MultipleObjectsReturned,
|
||||
get_object_or_404, Author.objects.all()
|
||||
)
|
||||
|
||||
# Using an empty QuerySet raises a Http404 error.
|
||||
self.assertRaises(Http404,
|
||||
self.assertRaises(
|
||||
Http404,
|
||||
get_object_or_404, Article.objects.none(), title__contains="Run"
|
||||
)
|
||||
|
||||
|
@ -65,7 +68,8 @@ class GetObjectOr404Tests(TestCase):
|
|||
)
|
||||
|
||||
# Http404 is returned if the list is empty.
|
||||
self.assertRaises(Http404,
|
||||
self.assertRaises(
|
||||
Http404,
|
||||
get_list_or_404, a1.article_set, title__icontains="Shrubbery"
|
||||
)
|
||||
|
||||
|
@ -84,7 +88,8 @@ class GetObjectOr404Tests(TestCase):
|
|||
def test_bad_class(self):
|
||||
# Given an argument klass that is not a Model, Manager, or Queryset
|
||||
# raises a helpful ValueError message
|
||||
self.assertRaisesMessage(ValueError,
|
||||
self.assertRaisesMessage(
|
||||
ValueError,
|
||||
"Object is of type 'str', but must be a Django Model, Manager, "
|
||||
"or QuerySet",
|
||||
get_object_or_404, str("Article"), title__icontains="Run"
|
||||
|
@ -93,14 +98,16 @@ class GetObjectOr404Tests(TestCase):
|
|||
class CustomClass(object):
|
||||
pass
|
||||
|
||||
self.assertRaisesMessage(ValueError,
|
||||
self.assertRaisesMessage(
|
||||
ValueError,
|
||||
"Object is of type 'CustomClass', but must be a Django Model, "
|
||||
"Manager, or QuerySet",
|
||||
get_object_or_404, CustomClass, title__icontains="Run"
|
||||
)
|
||||
|
||||
# Works for lists too
|
||||
self.assertRaisesMessage(ValueError,
|
||||
self.assertRaisesMessage(
|
||||
ValueError,
|
||||
"Object is of type 'list', but must be a Django Model, Manager, "
|
||||
"or QuerySet",
|
||||
get_list_or_404, [Article], title__icontains="Run"
|
||||
|
|
|
@ -45,14 +45,16 @@ class GetOrCreateTests(TestCase):
|
|||
|
||||
# If you don't specify a value or default value for all required
|
||||
# fields, you will get an error.
|
||||
self.assertRaises(IntegrityError,
|
||||
self.assertRaises(
|
||||
IntegrityError,
|
||||
Person.objects.get_or_create, first_name="Tom", last_name="Smith"
|
||||
)
|
||||
|
||||
# If you specify an existing primary key, but different other fields,
|
||||
# then you will get an error and data will not be updated.
|
||||
ManualPrimaryKeyTest.objects.create(id=1, data="Original")
|
||||
self.assertRaises(IntegrityError,
|
||||
self.assertRaises(
|
||||
IntegrityError,
|
||||
ManualPrimaryKeyTest.objects.get_or_create, id=1, data="Different"
|
||||
)
|
||||
self.assertEqual(ManualPrimaryKeyTest.objects.get(id=1).data, "Original")
|
||||
|
@ -181,7 +183,8 @@ class UpdateOrCreateTests(TestCase):
|
|||
# If you specify an existing primary key, but different other fields,
|
||||
# then you will get an error and data will not be updated.
|
||||
ManualPrimaryKeyTest.objects.create(id=1, data="Original")
|
||||
self.assertRaises(IntegrityError,
|
||||
self.assertRaises(
|
||||
IntegrityError,
|
||||
ManualPrimaryKeyTest.objects.update_or_create, id=1, data="Different"
|
||||
)
|
||||
self.assertEqual(ManualPrimaryKeyTest.objects.get(id=1).data, "Original")
|
||||
|
|
|
@ -123,7 +123,8 @@ class InlineFormsetFactoryTest(TestCase):
|
|||
Child has two ForeignKeys to Parent, so if we don't specify which one
|
||||
to use for the inline formset, we should get an exception.
|
||||
"""
|
||||
six.assertRaisesRegex(self, Exception,
|
||||
six.assertRaisesRegex(
|
||||
self, Exception,
|
||||
"<class 'inline_formsets.models.Child'> has more than 1 ForeignKey to <class 'inline_formsets.models.Parent'>",
|
||||
inlineformset_factory, Parent, Child
|
||||
)
|
||||
|
@ -133,7 +134,8 @@ class InlineFormsetFactoryTest(TestCase):
|
|||
If we specify fk_name, but it isn't a ForeignKey from the child model
|
||||
to the parent model, we should get an exception.
|
||||
"""
|
||||
self.assertRaises(Exception,
|
||||
self.assertRaises(
|
||||
Exception,
|
||||
"fk_name 'school' is not a ForeignKey to <class 'inline_formsets.models.Parent'>",
|
||||
inlineformset_factory, Parent, Child, fk_name='school'
|
||||
)
|
||||
|
@ -143,7 +145,8 @@ class InlineFormsetFactoryTest(TestCase):
|
|||
If the field specified in fk_name is not a ForeignKey, we should get an
|
||||
exception.
|
||||
"""
|
||||
six.assertRaisesRegex(self, Exception,
|
||||
six.assertRaisesRegex(
|
||||
self, Exception,
|
||||
"<class 'inline_formsets.models.Child'> has no field named 'test'",
|
||||
inlineformset_factory, Parent, Child, fk_name='test'
|
||||
)
|
||||
|
|
|
@ -36,7 +36,8 @@ class M2MRegressionTests(TestCase):
|
|||
# The secret internal related names for self-referential many-to-many
|
||||
# fields shouldn't appear in the list when an error is made.
|
||||
|
||||
six.assertRaisesRegex(self, FieldError,
|
||||
six.assertRaisesRegex(
|
||||
self, FieldError,
|
||||
"Choices are: id, name, references, related, selfreferchild, selfreferchildsibling$",
|
||||
lambda: SelfRefer.objects.filter(porcupine='fred')
|
||||
)
|
||||
|
|
|
@ -178,8 +178,9 @@ class ManyToOneTests(TestCase):
|
|||
])
|
||||
# ... and should work fine with the unicode that comes out of forms.Form.cleaned_data
|
||||
self.assertQuerysetEqual(
|
||||
Article.objects.filter(reporter__first_name__exact='John'
|
||||
).extra(where=["many_to_one_reporter.last_name='%s'" % 'Smith']),
|
||||
(Article.objects
|
||||
.filter(reporter__first_name__exact='John')
|
||||
.extra(where=["many_to_one_reporter.last_name='%s'" % 'Smith'])),
|
||||
[
|
||||
"<Article: John's second story>",
|
||||
"<Article: This is a test>",
|
||||
|
|
|
@ -788,6 +788,4 @@ class RootUrlconfTests(TestCase):
|
|||
# Removing ROOT_URLCONF is safe, as override_settings will restore
|
||||
# the previously defined settings.
|
||||
del settings.ROOT_URLCONF
|
||||
self.assertRaises(AttributeError,
|
||||
self.client.get, "/middleware_exceptions/view/"
|
||||
)
|
||||
self.assertRaises(AttributeError, self.client.get, "/middleware_exceptions/view/")
|
||||
|
|
|
@ -32,16 +32,18 @@ class ModelValidationTest(TestCase):
|
|||
post_init.connect(OnPostInit(), sender='missing-app.Model')
|
||||
e = ModelErrorCollection(six.StringIO())
|
||||
validate_model_signals(e)
|
||||
self.assertSetEqual(set(e.errors), {
|
||||
('model_validation.tests',
|
||||
self.assertSetEqual(
|
||||
set(e.errors),
|
||||
{(
|
||||
'model_validation.tests',
|
||||
"The `on_post_init` function was connected to the `post_init` "
|
||||
"signal with a lazy reference to the 'missing-app.Model' "
|
||||
"sender, which has not been installed."
|
||||
),
|
||||
('model_validation.tests',
|
||||
), (
|
||||
'model_validation.tests',
|
||||
"An instance of the `OnPostInit` class was connected to "
|
||||
"the `post_init` signal with a lazy reference to the "
|
||||
"'missing-app.Model' sender, which has not been installed."
|
||||
)
|
||||
})
|
||||
)}
|
||||
)
|
||||
post_init.unresolved_references = unresolved_references
|
||||
|
|
|
@ -545,7 +545,8 @@ class ValidationTests(unittest.TestCase):
|
|||
|
||||
site = AdminSite()
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.raw_id_fields' must be a list or tuple.",
|
||||
site.register,
|
||||
|
@ -562,7 +563,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
raw_id_fields = 10
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.raw_id_fields' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -572,7 +574,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
raw_id_fields = ('non_existent_field',)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.raw_id_fields' refers to field 'non_existent_field' that is missing from model 'modeladmin.ValidationTestModel'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -582,7 +585,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
raw_id_fields = ('name',)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.raw_id_fields\[0\]', 'name' must be either a ForeignKey or ManyToManyField.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -599,7 +603,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
fieldsets = 10
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.fieldsets' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -609,7 +614,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
fieldsets = ({},)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.fieldsets\[0\]' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -619,7 +625,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
fieldsets = ((),)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.fieldsets\[0\]' does not have exactly two elements.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -629,7 +636,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
fieldsets = (("General", ()),)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.fieldsets\[0\]\[1\]' must be a dictionary.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -639,7 +647,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
fieldsets = (("General", {}),)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'fields' key is required in ValidationTestModelAdmin.fieldsets\[0\]\[1\] field options dict.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -655,7 +664,8 @@ class ValidationTests(unittest.TestCase):
|
|||
fieldsets = (("General", {"fields": ("name",)}),)
|
||||
fields = ["name"]
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"Both fieldsets and fields are specified in ValidationTestModelAdmin.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -665,7 +675,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
fieldsets = [(None, {'fields': ['name', 'name']})]
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"There are duplicate field\(s\) in ValidationTestModelAdmin.fieldsets",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -675,7 +686,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
fields = ["name", "name"]
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"There are duplicate field\(s\) in ValidationTestModelAdmin.fields",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -690,7 +702,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
form = FakeForm
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"ValidationTestModelAdmin.form does not inherit from BaseModelForm.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -727,7 +740,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
filter_vertical = 10
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.filter_vertical' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -737,7 +751,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
filter_vertical = ("non_existent_field",)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.filter_vertical' refers to field 'non_existent_field' that is missing from model 'modeladmin.ValidationTestModel'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -747,7 +762,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
filter_vertical = ("name",)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.filter_vertical\[0\]' must be a ManyToManyField.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -764,7 +780,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
filter_horizontal = 10
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.filter_horizontal' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -774,7 +791,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
filter_horizontal = ("non_existent_field",)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.filter_horizontal' refers to field 'non_existent_field' that is missing from model 'modeladmin.ValidationTestModel'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -784,7 +802,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
filter_horizontal = ("name",)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.filter_horizontal\[0\]' must be a ManyToManyField.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -801,7 +820,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
radio_fields = ()
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.radio_fields' must be a dictionary.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -811,7 +831,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
radio_fields = {"non_existent_field": None}
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.radio_fields' refers to field 'non_existent_field' that is missing from model 'modeladmin.ValidationTestModel'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -821,7 +842,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
radio_fields = {"name": None}
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.radio_fields\['name'\]' is neither an instance of ForeignKey nor does have choices set.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -831,7 +853,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
radio_fields = {"state": None}
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.radio_fields\['state'\]' is neither admin.HORIZONTAL nor admin.VERTICAL.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -848,7 +871,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
prepopulated_fields = ()
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.prepopulated_fields' must be a dictionary.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -858,7 +882,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
prepopulated_fields = {"non_existent_field": None}
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.prepopulated_fields' refers to field 'non_existent_field' that is missing from model 'modeladmin.ValidationTestModel'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -868,7 +893,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
prepopulated_fields = {"slug": ("non_existent_field",)}
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.prepopulated_fields\['slug'\]\[0\]' refers to field 'non_existent_field' that is missing from model 'modeladmin.ValidationTestModel'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -878,7 +904,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
prepopulated_fields = {"users": ("name",)}
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.prepopulated_fields\['users'\]' is either a DateTimeField, ForeignKey or ManyToManyField. This isn't allowed.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -895,7 +922,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_display = 10
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_display' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -905,7 +933,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_display = ('non_existent_field',)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
str_prefix("ValidationTestModelAdmin.list_display\[0\], %(_)s'non_existent_field' is not a callable or an attribute of 'ValidationTestModelAdmin' or found in the model 'ValidationTestModel'."),
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -915,7 +944,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_display = ('users',)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_display\[0\]', 'users' is a ManyToManyField which is not supported.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -937,7 +967,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_display_links = 10
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_display_links' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -947,7 +978,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_display_links = ('non_existent_field',)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_display_links\[0\]' refers to 'non_existent_field' which is not defined in 'list_display'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -957,7 +989,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_display_links = ('name',)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_display_links\[0\]' refers to 'name' which is not defined in 'list_display'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -985,7 +1018,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_filter = 10
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_filter' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -995,7 +1029,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_filter = ('non_existent_field',)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_filter\[0\]' refers to 'non_existent_field' which does not refer to a Field.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1008,7 +1043,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_filter = (RandomClass,)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_filter\[0\]' is 'RandomClass' which is not a descendant of ListFilter.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1018,7 +1054,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_filter = (('is_active', RandomClass),)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_filter\[0\]\[1\]' is 'RandomClass' which is not of type FieldListFilter.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1038,7 +1075,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_filter = (('is_active', AwesomeFilter),)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_filter\[0\]\[1\]' is 'AwesomeFilter' which is not of type FieldListFilter.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1048,7 +1086,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_filter = (BooleanFieldListFilter,)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_filter\[0\]' is 'BooleanFieldListFilter' which is of type FieldListFilter but is not associated with a field name.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1067,7 +1106,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_per_page = 'hello'
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_per_page' should be a int.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1084,7 +1124,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
list_max_show_all = 'hello'
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.list_max_show_all' should be a int.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1101,7 +1142,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
search_fields = 10
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.search_fields' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1113,7 +1155,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
date_hierarchy = 'non_existent_field'
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.date_hierarchy' refers to field 'non_existent_field' that is missing from model 'modeladmin.ValidationTestModel'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1123,7 +1166,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
date_hierarchy = 'name'
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.date_hierarchy is neither an instance of DateField nor DateTimeField.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1140,7 +1184,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
ordering = 10
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.ordering' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1150,7 +1195,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
ordering = ('non_existent_field',)
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.ordering\[0\]' refers to field 'non_existent_field' that is missing from model 'modeladmin.ValidationTestModel'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1160,7 +1206,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
ordering = ('?', 'name')
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.ordering' has the random ordering marker '\?', but contains other fields as well. Please either remove '\?' or the other fields.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1206,7 +1253,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
save_as = 1
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.save_as' should be a bool.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1223,7 +1271,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
save_on_top = 1
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.save_on_top' should be a bool.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1240,7 +1289,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
inlines = 10
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.inlines' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1253,7 +1303,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
inlines = [ValidationTestInline]
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.inlines\[0\]' does not inherit from BaseModelAdmin.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1266,7 +1317,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
inlines = [ValidationTestInline]
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'model' is a required attribute of 'ValidationTestModelAdmin.inlines\[0\]'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1282,7 +1334,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
inlines = [ValidationTestInline]
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestModelAdmin.inlines\[0\].model' does not inherit from models.Model.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1306,7 +1359,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
inlines = [ValidationTestInline]
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestInline.fields' must be a list or tuple.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1322,7 +1376,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
inlines = [ValidationTestInline]
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestInline.fk_name' refers to field 'non_existent_field' that is missing from model 'modeladmin.ValidationTestInlineModel'.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1347,7 +1402,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
inlines = [ValidationTestInline]
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestInline.extra' should be a int.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1372,7 +1428,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
inlines = [ValidationTestInline]
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestInline.max_num' should be a int.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
@ -1400,7 +1457,8 @@ class ValidationTests(unittest.TestCase):
|
|||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
inlines = [ValidationTestInline]
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
ImproperlyConfigured,
|
||||
"'ValidationTestInline.formset' does not inherit from BaseModelFormSet.",
|
||||
ValidationTestModelAdmin.validate,
|
||||
|
|
|
@ -91,15 +91,18 @@ class ProxyModelTests(TestCase):
|
|||
LowerStatusPerson.objects.create(status="low", name="homer")
|
||||
max_id = Person.objects.aggregate(max_id=models.Max('id'))['max_id']
|
||||
|
||||
self.assertRaises(Person.DoesNotExist,
|
||||
self.assertRaises(
|
||||
Person.DoesNotExist,
|
||||
MyPersonProxy.objects.get,
|
||||
name='Zathras'
|
||||
)
|
||||
self.assertRaises(Person.MultipleObjectsReturned,
|
||||
self.assertRaises(
|
||||
Person.MultipleObjectsReturned,
|
||||
MyPersonProxy.objects.get,
|
||||
id__lt=max_id + 1
|
||||
)
|
||||
self.assertRaises(Person.DoesNotExist,
|
||||
self.assertRaises(
|
||||
Person.DoesNotExist,
|
||||
StatusPerson.objects.get,
|
||||
name='Zathras'
|
||||
)
|
||||
|
@ -108,7 +111,8 @@ class ProxyModelTests(TestCase):
|
|||
StatusPerson.objects.create(name='Foo Jr.')
|
||||
max_id = Person.objects.aggregate(max_id=models.Max('id'))['max_id']
|
||||
|
||||
self.assertRaises(Person.MultipleObjectsReturned,
|
||||
self.assertRaises(
|
||||
Person.MultipleObjectsReturned,
|
||||
StatusPerson.objects.get,
|
||||
id__lt=max_id + 1
|
||||
)
|
||||
|
@ -344,7 +348,8 @@ class ProxyModelTests(TestCase):
|
|||
resp = ProxyImprovement.objects.select_related().get(
|
||||
reporter__name__icontains='butor'
|
||||
)
|
||||
self.assertEqual(repr(resp),
|
||||
self.assertEqual(
|
||||
repr(resp),
|
||||
'<ProxyImprovement: ProxyImprovement:improve that>'
|
||||
)
|
||||
|
||||
|
@ -352,7 +357,8 @@ class ProxyModelTests(TestCase):
|
|||
resp = ProxyImprovement.objects.select_related().get(
|
||||
associated_bug__summary__icontains='fix'
|
||||
)
|
||||
self.assertEqual(repr(resp),
|
||||
self.assertEqual(
|
||||
repr(resp),
|
||||
'<ProxyImprovement: ProxyImprovement:improve that>'
|
||||
)
|
||||
|
||||
|
|
|
@ -234,6 +234,4 @@ class RawQueryTests(TestCase):
|
|||
)
|
||||
|
||||
def test_query_count(self):
|
||||
self.assertNumQueries(1,
|
||||
list, Author.objects.raw("SELECT * FROM raw_query_author")
|
||||
)
|
||||
self.assertNumQueries(1, list, Author.objects.raw("SELECT * FROM raw_query_author"))
|
||||
|
|
|
@ -100,8 +100,9 @@ class SelectRelatedTests(TestCase):
|
|||
['Agaricales', 'Diptera', 'Fabales', 'Primates'])
|
||||
|
||||
def test_select_related_with_extra(self):
|
||||
s = Species.objects.all().select_related()\
|
||||
.extra(select={'a': 'select_related_species.id + 10'})[0]
|
||||
s = (Species.objects.all()
|
||||
.select_related()
|
||||
.extra(select={'a': 'select_related_species.id + 10'})[0])
|
||||
self.assertEqual(s.id + 10, s.a)
|
||||
|
||||
def test_certain_fields(self):
|
||||
|
@ -131,12 +132,14 @@ class SelectRelatedTests(TestCase):
|
|||
|
||||
def test_field_traversal(self):
|
||||
with self.assertNumQueries(1):
|
||||
s = Species.objects.all().select_related('genus__family__order'
|
||||
).order_by('id')[0:1].get().genus.family.order.name
|
||||
s = (Species.objects.all()
|
||||
.select_related('genus__family__order')
|
||||
.order_by('id')[0:1].get().genus.family.order.name)
|
||||
self.assertEqual(s, 'Diptera')
|
||||
|
||||
def test_depth_fields_fails(self):
|
||||
self.assertRaises(TypeError,
|
||||
self.assertRaises(
|
||||
TypeError,
|
||||
Species.objects.select_related,
|
||||
'genus__family__order', depth=4
|
||||
)
|
||||
|
|
|
@ -362,7 +362,8 @@ class TestCollectionNonLocalStorage(CollectionTestCase, TestNoFilesCreated):
|
|||
|
||||
|
||||
# we set DEBUG to False here since the template tag wouldn't work otherwise
|
||||
@override_settings(**dict(TEST_SETTINGS,
|
||||
@override_settings(**dict(
|
||||
TEST_SETTINGS,
|
||||
STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage',
|
||||
DEBUG=False,
|
||||
))
|
||||
|
@ -569,7 +570,8 @@ class TestCollectionCachedStorage(BaseCollectionTestCase,
|
|||
|
||||
|
||||
# we set DEBUG to False here since the template tag wouldn't work otherwise
|
||||
@override_settings(**dict(TEST_SETTINGS,
|
||||
@override_settings(**dict(
|
||||
TEST_SETTINGS,
|
||||
STATICFILES_STORAGE='staticfiles_tests.storage.SimpleCachedStaticFilesStorage',
|
||||
DEBUG=False,
|
||||
))
|
||||
|
|
|
@ -58,9 +58,7 @@ class ParserTests(TestCase):
|
|||
|
||||
# Filtered variables should reject access of attributes beginning with
|
||||
# underscores.
|
||||
self.assertRaises(TemplateSyntaxError,
|
||||
FilterExpression, "article._hidden|upper", p
|
||||
)
|
||||
self.assertRaises(TemplateSyntaxError, FilterExpression, "article._hidden|upper", p)
|
||||
|
||||
def test_variable_parsing(self):
|
||||
c = {"article": {"section": "News"}}
|
||||
|
@ -83,9 +81,7 @@ class ParserTests(TestCase):
|
|||
|
||||
# Variables should reject access of attributes beginning with
|
||||
# underscores.
|
||||
self.assertRaises(TemplateSyntaxError,
|
||||
Variable, "article._hidden"
|
||||
)
|
||||
self.assertRaises(TemplateSyntaxError, Variable, "article._hidden")
|
||||
|
||||
# Variables should raise on non string type
|
||||
with six.assertRaisesRegex(self, TypeError, "Variable must be a string or number, got <(class|type) 'dict'>"):
|
||||
|
|
|
@ -56,9 +56,7 @@ class AssertNumQueriesTests(TestCase):
|
|||
def test_func():
|
||||
raise ValueError
|
||||
|
||||
self.assertRaises(ValueError,
|
||||
self.assertNumQueries, 2, test_func
|
||||
)
|
||||
self.assertRaises(ValueError, self.assertNumQueries, 2, test_func)
|
||||
|
||||
def test_assert_num_queries_with_client(self):
|
||||
person = Person.objects.create(name='test')
|
||||
|
|
Loading…
Reference in New Issue