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