mirror of https://github.com/django/django.git
Removed unnecessary trailing commas and spaces in various code.
This commit is contained in:
parent
058d112ed2
commit
83a36ac49a
|
@ -59,7 +59,7 @@ def permission_required(perm, login_url=None, raise_exception=False):
|
|||
"""
|
||||
def check_perms(user):
|
||||
if isinstance(perm, str):
|
||||
perms = (perm, )
|
||||
perms = (perm,)
|
||||
else:
|
||||
perms = perm
|
||||
# First check if the user has the permission (even anon users)
|
||||
|
|
|
@ -67,7 +67,7 @@ class PermissionRequiredMixin(AccessMixin):
|
|||
'{0}.get_permission_required().'.format(self.__class__.__name__)
|
||||
)
|
||||
if isinstance(self.permission_required, str):
|
||||
perms = (self.permission_required, )
|
||||
perms = (self.permission_required,)
|
||||
else:
|
||||
perms = self.permission_required
|
||||
return perms
|
||||
|
|
|
@ -369,7 +369,7 @@ class RasterField(BaseSpatialField):
|
|||
band_index = int(name)
|
||||
return type(
|
||||
'SpecificRasterBandTransform',
|
||||
(RasterBandTransform, ),
|
||||
(RasterBandTransform,),
|
||||
{'band_index': band_index}
|
||||
)
|
||||
except ValueError:
|
||||
|
|
|
@ -52,7 +52,7 @@ class CheckRegistry:
|
|||
return inner(check)
|
||||
else:
|
||||
if check:
|
||||
tags += (check, )
|
||||
tags += (check,)
|
||||
return inner
|
||||
|
||||
def run_checks(self, app_configs=None, tags=None, include_deployment_checks=False):
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.db.models.constants import LOOKUP_SEP
|
|||
class Command(BaseCommand):
|
||||
help = "Introspects the database tables in the given database and outputs a Django model module."
|
||||
requires_system_checks = False
|
||||
stealth_options = ('table_name_filter', )
|
||||
stealth_options = ('table_name_filter',)
|
||||
db_module = 'django.db'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
|
|
|
@ -276,7 +276,7 @@ class Command(BaseCommand):
|
|||
biggest_number = max(x for x in numbers if x is not None)
|
||||
except ValueError:
|
||||
biggest_number = 1
|
||||
subclass = type("Migration", (Migration, ), {
|
||||
subclass = type("Migration", (Migration,), {
|
||||
"dependencies": [(app_label, migration.name) for migration in merge_migrations],
|
||||
})
|
||||
migration_name = "%04i_%s" % (
|
||||
|
|
|
@ -148,7 +148,7 @@ class Command(BaseCommand):
|
|||
else:
|
||||
if targets[0][1] is None:
|
||||
self.stdout.write(self.style.MIGRATE_LABEL(
|
||||
" Unapply all migrations: ") + "%s" % (targets[0][0], )
|
||||
" Unapply all migrations: ") + "%s" % (targets[0][0],)
|
||||
)
|
||||
else:
|
||||
self.stdout.write(self.style.MIGRATE_LABEL(
|
||||
|
|
|
@ -153,7 +153,7 @@ class Command(BaseCommand):
|
|||
replaces.append((migration.app_label, migration.name))
|
||||
|
||||
# Make a new migration with those operations
|
||||
subclass = type("Migration", (migrations.Migration, ), {
|
||||
subclass = type("Migration", (migrations.Migration,), {
|
||||
"dependencies": dependencies,
|
||||
"operations": new_operations,
|
||||
"replaces": replaces,
|
||||
|
|
|
@ -419,7 +419,7 @@ class MigrationAutodetector:
|
|||
)
|
||||
# Unknown dependency. Raise an error.
|
||||
else:
|
||||
raise ValueError("Can't handle dependency %r" % (dependency, ))
|
||||
raise ValueError("Can't handle dependency %r" % (dependency,))
|
||||
|
||||
def add_operation(self, app_label, operation, dependencies=None, beginning=False):
|
||||
# Dependencies are (app_label, model_name, field_name, create/delete as True/False)
|
||||
|
|
|
@ -43,7 +43,7 @@ class NodeNotFoundError(LookupError):
|
|||
return self.message
|
||||
|
||||
def __repr__(self):
|
||||
return "NodeNotFoundError(%r)" % (self.node, )
|
||||
return "NodeNotFoundError(%r)" % (self.node,)
|
||||
|
||||
|
||||
class MigrationSchemaMissing(DatabaseError):
|
||||
|
|
|
@ -178,7 +178,7 @@ class MigrationGraph:
|
|||
except KeyError as err:
|
||||
raise NodeNotFoundError(
|
||||
"Unable to find replacement node %r. It was either never added"
|
||||
" to the migration graph, or has been removed." % (replacement, ),
|
||||
" to the migration graph, or has been removed." % (replacement,),
|
||||
replacement
|
||||
) from err
|
||||
for replaced_key in replaced:
|
||||
|
@ -214,7 +214,7 @@ class MigrationGraph:
|
|||
except KeyError as err:
|
||||
raise NodeNotFoundError(
|
||||
"Unable to remove replacement node %r. It was either never added"
|
||||
" to the migration graph, or has been removed already." % (replacement, ),
|
||||
" to the migration graph, or has been removed already." % (replacement,),
|
||||
replacement
|
||||
) from err
|
||||
replaced_nodes = set()
|
||||
|
@ -256,7 +256,7 @@ class MigrationGraph:
|
|||
follow if applying the migrations to a database.
|
||||
"""
|
||||
if target not in self.nodes:
|
||||
raise NodeNotFoundError("Node %r not a valid node" % (target, ), target)
|
||||
raise NodeNotFoundError("Node %r not a valid node" % (target,), target)
|
||||
# Use parent.key instead of parent to speed up the frequent hashing in ensure_not_cyclic
|
||||
self.ensure_not_cyclic(target, lambda x: (parent.key for parent in self.node_map[x].parents))
|
||||
self.cached = True
|
||||
|
@ -275,7 +275,7 @@ class MigrationGraph:
|
|||
would follow if removing the migrations from a database.
|
||||
"""
|
||||
if target not in self.nodes:
|
||||
raise NodeNotFoundError("Node %r not a valid node" % (target, ), target)
|
||||
raise NodeNotFoundError("Node %r not a valid node" % (target,), target)
|
||||
# Use child.key instead of child to speed up the frequent hashing in ensure_not_cyclic
|
||||
self.ensure_not_cyclic(target, lambda x: (child.key for child in self.node_map[x].children))
|
||||
self.cached = True
|
||||
|
|
|
@ -249,7 +249,7 @@ class DeleteModel(ModelOperation):
|
|||
schema_editor.create_model(model)
|
||||
|
||||
def describe(self):
|
||||
return "Delete model %s" % (self.name, )
|
||||
return "Delete model %s" % self.name
|
||||
|
||||
|
||||
class RenameModel(ModelOperation):
|
||||
|
@ -701,7 +701,7 @@ class AlterModelOptions(ModelOptionOperation):
|
|||
pass
|
||||
|
||||
def describe(self):
|
||||
return "Change Meta options on %s" % (self.name, )
|
||||
return "Change Meta options on %s" % self.name
|
||||
|
||||
|
||||
class AlterModelManagers(ModelOptionOperation):
|
||||
|
@ -732,7 +732,7 @@ class AlterModelManagers(ModelOptionOperation):
|
|||
pass
|
||||
|
||||
def describe(self):
|
||||
return "Change managers on %s" % (self.name, )
|
||||
return "Change managers on %s" % self.name
|
||||
|
||||
|
||||
class IndexOperation(Operation):
|
||||
|
|
|
@ -362,7 +362,7 @@ class ModelState:
|
|||
self.fields = fields
|
||||
self.options = options or {}
|
||||
self.options.setdefault('indexes', [])
|
||||
self.bases = bases or (models.Model, )
|
||||
self.bases = bases or (models.Model,)
|
||||
self.managers = managers or []
|
||||
# Sanity-check that fields is NOT a dict. It must be ordered.
|
||||
if isinstance(self.fields, dict):
|
||||
|
|
|
@ -284,7 +284,7 @@ man_pages = [(
|
|||
'Utility script for the Django Web framework',
|
||||
['Django Software Foundation'],
|
||||
1
|
||||
), ]
|
||||
)]
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
|
|
|
@ -193,7 +193,7 @@ registering a custom ``ModelAdmin`` for ``FlatPage``::
|
|||
fieldsets = (
|
||||
(None, {'fields': ('url', 'title', 'content', 'sites')}),
|
||||
(_('Advanced options'), {
|
||||
'classes': ('collapse', ),
|
||||
'classes': ('collapse',),
|
||||
'fields': (
|
||||
'enable_comments',
|
||||
'registration_required',
|
||||
|
|
|
@ -1029,7 +1029,7 @@ attributes. Thus, you can subclass the appropriate feed generator class
|
|||
.. _georss: http://georss.org/
|
||||
.. _itunes podcast format: https://www.apple.com/itunes/podcasts/specs.html
|
||||
|
||||
``SyndicationFeed.root_attributes(self, )``
|
||||
``SyndicationFeed.root_attributes(self)``
|
||||
Return a ``dict`` of attributes to add to the root feed element
|
||||
(``feed``/``channel``).
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ add it to a ``UserAdmin`` class which is registered with the
|
|||
|
||||
# Define a new User admin
|
||||
class UserAdmin(BaseUserAdmin):
|
||||
inlines = (EmployeeInline, )
|
||||
inlines = (EmployeeInline,)
|
||||
|
||||
# Re-register UserAdmin
|
||||
admin.site.unregister(User)
|
||||
|
|
|
@ -229,15 +229,15 @@ class EmployeeAdmin(ModelAdmin):
|
|||
|
||||
|
||||
class DepartmentFilterEmployeeAdmin(EmployeeAdmin):
|
||||
list_filter = [DepartmentListFilterLookupWithNonStringValue, ]
|
||||
list_filter = [DepartmentListFilterLookupWithNonStringValue]
|
||||
|
||||
|
||||
class DepartmentFilterUnderscoredEmployeeAdmin(EmployeeAdmin):
|
||||
list_filter = [DepartmentListFilterLookupWithUnderscoredParameter, ]
|
||||
list_filter = [DepartmentListFilterLookupWithUnderscoredParameter]
|
||||
|
||||
|
||||
class DepartmentFilterDynamicValueBookAdmin(EmployeeAdmin):
|
||||
list_filter = [DepartmentListFilterLookupWithDynamicValue, ]
|
||||
list_filter = [DepartmentListFilterLookupWithDynamicValue]
|
||||
|
||||
|
||||
class BookmarkAdminGenericRelation(ModelAdmin):
|
||||
|
|
|
@ -27,7 +27,7 @@ class SongInlineDefaultOrdering(admin.StackedInline):
|
|||
|
||||
class SongInlineNewOrdering(admin.StackedInline):
|
||||
model = Song
|
||||
ordering = ('duration', )
|
||||
ordering = ('duration',)
|
||||
|
||||
|
||||
class DynOrderingBandAdmin(admin.ModelAdmin):
|
||||
|
|
|
@ -568,7 +568,7 @@ class StoryForm(forms.ModelForm):
|
|||
class StoryAdmin(admin.ModelAdmin):
|
||||
list_display = ('id', 'title', 'content')
|
||||
list_display_links = ('title',) # 'id' not in list_display_links
|
||||
list_editable = ('content', )
|
||||
list_editable = ('content',)
|
||||
form = StoryForm
|
||||
ordering = ['-id']
|
||||
|
||||
|
@ -576,7 +576,7 @@ class StoryAdmin(admin.ModelAdmin):
|
|||
class OtherStoryAdmin(admin.ModelAdmin):
|
||||
list_display = ('id', 'title', 'content')
|
||||
list_display_links = ('title', 'id') # 'id' in list_display_links
|
||||
list_editable = ('content', )
|
||||
list_editable = ('content',)
|
||||
ordering = ['-id']
|
||||
|
||||
|
||||
|
@ -748,7 +748,7 @@ def callable_on_unknown(obj):
|
|||
|
||||
|
||||
class AttributeErrorRaisingAdmin(admin.ModelAdmin):
|
||||
list_display = [callable_on_unknown, ]
|
||||
list_display = [callable_on_unknown]
|
||||
|
||||
|
||||
class CustomManagerAdmin(admin.ModelAdmin):
|
||||
|
|
|
@ -518,6 +518,6 @@ class CheckAllowedHostsTest(SimpleTestCase):
|
|||
def test_allowed_hosts_empty(self):
|
||||
self.assertEqual(self.func(None), [base.W020])
|
||||
|
||||
@override_settings(ALLOWED_HOSTS=['.example.com', ])
|
||||
@override_settings(ALLOWED_HOSTS=['.example.com'])
|
||||
def test_allowed_hosts_set(self):
|
||||
self.assertEqual(self.func(None), [])
|
||||
|
|
|
@ -30,10 +30,10 @@ class SystemCheckFrameworkTests(SimpleTestCase):
|
|||
return [1, 2, 3]
|
||||
|
||||
def f2(**kwargs):
|
||||
return [4, ]
|
||||
return [4]
|
||||
|
||||
def f3(**kwargs):
|
||||
return [5, ]
|
||||
return [5]
|
||||
|
||||
calls = [0]
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from django.test import TestCase, modify_settings, override_settings
|
|||
from django.utils import translation
|
||||
|
||||
|
||||
@modify_settings(INSTALLED_APPS={'append': ['django.contrib.flatpages', ]})
|
||||
@modify_settings(INSTALLED_APPS={'append': ['django.contrib.flatpages']})
|
||||
@override_settings(SITE_ID=1)
|
||||
class FlatpageAdminFormTests(TestCase):
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ class GDALRasterTests(SimpleTestCase):
|
|||
if numpy:
|
||||
result = result.flatten().tolist()
|
||||
# All band data is equal to nodata value.
|
||||
self.assertEqual(result, [23, ] * 4)
|
||||
self.assertEqual(result, [23] * 4)
|
||||
|
||||
def test_set_nodata_none_on_raster_creation(self):
|
||||
if GDAL_VERSION < (2, 1):
|
||||
|
@ -299,7 +299,7 @@ class GDALRasterTests(SimpleTestCase):
|
|||
})
|
||||
# Set metadata on raster and on a band.
|
||||
metadata = {
|
||||
'DEFAULT': {'OWNER': 'Django', 'VERSION': '1.0', 'AREA_OR_POINT': 'Point', },
|
||||
'DEFAULT': {'OWNER': 'Django', 'VERSION': '1.0', 'AREA_OR_POINT': 'Point'},
|
||||
}
|
||||
source.metadata = metadata
|
||||
source.bands[0].metadata = metadata
|
||||
|
@ -307,13 +307,13 @@ class GDALRasterTests(SimpleTestCase):
|
|||
self.assertEqual(source.bands[0].metadata['DEFAULT'], metadata['DEFAULT'])
|
||||
# Update metadata on raster.
|
||||
metadata = {
|
||||
'DEFAULT': {'VERSION': '2.0', },
|
||||
'DEFAULT': {'VERSION': '2.0'},
|
||||
}
|
||||
source.metadata = metadata
|
||||
self.assertEqual(source.metadata['DEFAULT']['VERSION'], '2.0')
|
||||
# Remove metadata on raster.
|
||||
metadata = {
|
||||
'DEFAULT': {'OWNER': None, },
|
||||
'DEFAULT': {'OWNER': None},
|
||||
}
|
||||
source.metadata = metadata
|
||||
self.assertNotIn('OWNER', source.metadata['DEFAULT'])
|
||||
|
|
|
@ -1264,7 +1264,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
|
|||
mp = MultiPolygon(p1, p2)
|
||||
path, args, kwargs = mp.deconstruct()
|
||||
self.assertEqual(path, 'django.contrib.gis.geos.collections.MultiPolygon')
|
||||
self.assertEqual(args, (p1, p2, ))
|
||||
self.assertEqual(args, (p1, p2))
|
||||
self.assertEqual(kwargs, {})
|
||||
|
||||
poly = Polygon(((0, 0), (0, 1), (1, 1), (0, 0)))
|
||||
|
|
|
@ -1142,7 +1142,7 @@ class MiscTests(SimpleTestCase):
|
|||
('en; q=1.0, * ; q=0.5', [('en', 1.0), ('*', 0.5)]),
|
||||
# Bad headers
|
||||
('en-gb;q=1.0000', []),
|
||||
('en;q=0.1234', [], ),
|
||||
('en;q=0.1234', []),
|
||||
('en;q=.2', []),
|
||||
('abcdefghi-au', []),
|
||||
('**', []),
|
||||
|
|
|
@ -19,7 +19,7 @@ class Author(models.Model):
|
|||
name = models.CharField(max_length=100)
|
||||
|
||||
class Meta:
|
||||
ordering = ('name', )
|
||||
ordering = ('name',)
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
|
@ -40,7 +40,7 @@ class Tag(models.Model):
|
|||
name = models.CharField(max_length=100)
|
||||
|
||||
class Meta:
|
||||
ordering = ('name', )
|
||||
ordering = ('name',)
|
||||
|
||||
|
||||
class NulledTextField(models.TextField):
|
||||
|
|
|
@ -87,7 +87,7 @@ class M2mThroughTests(TestCase):
|
|||
|
||||
self.assertQuerysetEqual(
|
||||
self.rock.members.all(),
|
||||
['Jim', ],
|
||||
['Jim'],
|
||||
attrgetter("name")
|
||||
)
|
||||
|
||||
|
@ -156,7 +156,7 @@ class M2mThroughTests(TestCase):
|
|||
|
||||
self.assertQuerysetEqual(
|
||||
self.bob.group_set.all(),
|
||||
['Rock', ],
|
||||
['Rock'],
|
||||
attrgetter('name')
|
||||
)
|
||||
|
||||
|
@ -192,7 +192,7 @@ class M2mThroughTests(TestCase):
|
|||
|
||||
self.assertQuerysetEqual(
|
||||
Group.objects.filter(members__name='Bob'),
|
||||
['Roll', ],
|
||||
['Roll'],
|
||||
attrgetter("name")
|
||||
)
|
||||
|
||||
|
|
|
@ -237,13 +237,13 @@ class AutodetectorTests(TestCase):
|
|||
author_proxy_options = ModelState("testapp", "AuthorProxy", [], {
|
||||
"proxy": True,
|
||||
"verbose_name": "Super Author",
|
||||
}, ("testapp.author", ))
|
||||
author_proxy_notproxy = ModelState("testapp", "AuthorProxy", [], {}, ("testapp.author", ))
|
||||
author_proxy_third = ModelState("thirdapp", "AuthorProxy", [], {"proxy": True}, ("testapp.author", ))
|
||||
author_proxy_third_notproxy = ModelState("thirdapp", "AuthorProxy", [], {}, ("testapp.author", ))
|
||||
author_proxy_proxy = ModelState("testapp", "AAuthorProxyProxy", [], {"proxy": True}, ("testapp.authorproxy", ))
|
||||
author_unmanaged = ModelState("testapp", "AuthorUnmanaged", [], {"managed": False}, ("testapp.author", ))
|
||||
author_unmanaged_managed = ModelState("testapp", "AuthorUnmanaged", [], {}, ("testapp.author", ))
|
||||
}, ("testapp.author",))
|
||||
author_proxy_notproxy = ModelState("testapp", "AuthorProxy", [], {}, ("testapp.author",))
|
||||
author_proxy_third = ModelState("thirdapp", "AuthorProxy", [], {"proxy": True}, ("testapp.author",))
|
||||
author_proxy_third_notproxy = ModelState("thirdapp", "AuthorProxy", [], {}, ("testapp.author",))
|
||||
author_proxy_proxy = ModelState("testapp", "AAuthorProxyProxy", [], {"proxy": True}, ("testapp.authorproxy",))
|
||||
author_unmanaged = ModelState("testapp", "AuthorUnmanaged", [], {"managed": False}, ("testapp.author",))
|
||||
author_unmanaged_managed = ModelState("testapp", "AuthorUnmanaged", [], {}, ("testapp.author",))
|
||||
author_unmanaged_default_pk = ModelState("testapp", "Author", [("id", models.AutoField(primary_key=True))])
|
||||
author_unmanaged_custom_pk = ModelState("testapp", "Author", [
|
||||
("pk_field", models.IntegerField(primary_key=True)),
|
||||
|
@ -430,14 +430,14 @@ class AutodetectorTests(TestCase):
|
|||
custom_user = ModelState("thirdapp", "CustomUser", [
|
||||
("id", models.AutoField(primary_key=True)),
|
||||
("username", models.CharField(max_length=255)),
|
||||
], bases=(AbstractBaseUser, ))
|
||||
], bases=(AbstractBaseUser,))
|
||||
custom_user_no_inherit = ModelState("thirdapp", "CustomUser", [
|
||||
("id", models.AutoField(primary_key=True)),
|
||||
("username", models.CharField(max_length=255)),
|
||||
])
|
||||
aardvark = ModelState("thirdapp", "Aardvark", [("id", models.AutoField(primary_key=True))])
|
||||
aardvark_testapp = ModelState("testapp", "Aardvark", [("id", models.AutoField(primary_key=True))])
|
||||
aardvark_based_on_author = ModelState("testapp", "Aardvark", [], bases=("testapp.Author", ))
|
||||
aardvark_based_on_author = ModelState("testapp", "Aardvark", [], bases=("testapp.Author",))
|
||||
aardvark_pk_fk_author = ModelState("testapp", "Aardvark", [
|
||||
("id", models.OneToOneField("testapp.Author", models.CASCADE, primary_key=True)),
|
||||
])
|
||||
|
@ -2071,7 +2071,7 @@ class AutodetectorTests(TestCase):
|
|||
tenant = ModelState("a", "Tenant", [
|
||||
("id", models.AutoField(primary_key=True)),
|
||||
("primary_address", models.ForeignKey("b.Address", models.CASCADE))],
|
||||
bases=(AbstractBaseUser, )
|
||||
bases=(AbstractBaseUser,)
|
||||
)
|
||||
address = ModelState("b", "Address", [
|
||||
("id", models.AutoField(primary_key=True)),
|
||||
|
@ -2105,7 +2105,7 @@ class AutodetectorTests(TestCase):
|
|||
tenant = ModelState("b", "Tenant", [
|
||||
("id", models.AutoField(primary_key=True)),
|
||||
("primary_address", models.ForeignKey("a.Address", models.CASCADE))],
|
||||
bases=(AbstractBaseUser, )
|
||||
bases=(AbstractBaseUser,)
|
||||
)
|
||||
changes = self.get_changes([], [address, tenant])
|
||||
# Right number/type of migrations?
|
||||
|
|
|
@ -554,14 +554,14 @@ class ExecutorTests(MigrationTestBase):
|
|||
|
||||
migrations = executor.loader.graph.nodes
|
||||
expected = [
|
||||
("render_start", ),
|
||||
("render_success", ),
|
||||
("render_start",),
|
||||
("render_success",),
|
||||
("apply_start", migrations['migrations', '0001_initial'], False),
|
||||
("apply_success", migrations['migrations', '0001_initial'], False),
|
||||
("apply_start", migrations['migrations', '0002_second'], False),
|
||||
("apply_success", migrations['migrations', '0002_second'], False),
|
||||
("render_start", ),
|
||||
("render_success", ),
|
||||
("render_start",),
|
||||
("render_success",),
|
||||
("unapply_start", migrations['migrations', '0002_second'], False),
|
||||
("unapply_success", migrations['migrations', '0002_second'], False),
|
||||
("unapply_start", migrations['migrations', '0001_initial'], False),
|
||||
|
|
|
@ -147,7 +147,7 @@ class GraphTests(SimpleTestCase):
|
|||
graph.add_dependency("app_b.0001", ("app_b", "0001"), ("app_a", "0003"))
|
||||
# Test whole graph
|
||||
with self.assertRaises(CircularDependencyError):
|
||||
graph.forwards_plan(("app_a", "0003"), )
|
||||
graph.forwards_plan(("app_a", "0003"))
|
||||
|
||||
def test_circular_graph_2(self):
|
||||
graph = MigrationGraph()
|
||||
|
|
|
@ -409,7 +409,7 @@ class OperationTests(OperationTestBase):
|
|||
"ProxyPony",
|
||||
[],
|
||||
options={"proxy": True},
|
||||
bases=("test_crprmo.Pony", ),
|
||||
bases=("test_crprmo.Pony",),
|
||||
)
|
||||
self.assertEqual(operation.describe(), "Create proxy model ProxyPony")
|
||||
new_state = project_state.clone()
|
||||
|
@ -443,7 +443,7 @@ class OperationTests(OperationTestBase):
|
|||
"UnmanagedPony",
|
||||
[],
|
||||
options={"proxy": True},
|
||||
bases=("test_crummo.Pony", ),
|
||||
bases=("test_crummo.Pony",),
|
||||
)
|
||||
self.assertEqual(operation.describe(), "Create proxy model UnmanagedPony")
|
||||
new_state = project_state.clone()
|
||||
|
|
|
@ -243,7 +243,7 @@ class OptimizerTests(SimpleTestCase):
|
|||
self.assertDoesNotOptimize(
|
||||
[
|
||||
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
|
||||
migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo", )),
|
||||
migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo",)),
|
||||
migrations.DeleteModel("Foo"),
|
||||
],
|
||||
)
|
||||
|
@ -252,11 +252,11 @@ class OptimizerTests(SimpleTestCase):
|
|||
self.assertOptimizesTo(
|
||||
[
|
||||
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
|
||||
migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo", )),
|
||||
migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo",)),
|
||||
migrations.DeleteModel("Foo"),
|
||||
],
|
||||
[
|
||||
migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo", )),
|
||||
migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo",)),
|
||||
],
|
||||
app_label="otherapp",
|
||||
)
|
||||
|
@ -264,7 +264,7 @@ class OptimizerTests(SimpleTestCase):
|
|||
self.assertDoesNotOptimize(
|
||||
[
|
||||
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
|
||||
migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo", )),
|
||||
migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo",)),
|
||||
migrations.DeleteModel("Foo"),
|
||||
],
|
||||
app_label="testapp",
|
||||
|
|
|
@ -129,7 +129,7 @@ class StateTests(SimpleTestCase):
|
|||
author_state.options,
|
||||
{"unique_together": {("name", "bio")}, "index_together": {("bio", "age")}, "indexes": []}
|
||||
)
|
||||
self.assertEqual(author_state.bases, (models.Model, ))
|
||||
self.assertEqual(author_state.bases, (models.Model,))
|
||||
|
||||
self.assertEqual(book_state.app_label, "migrations")
|
||||
self.assertEqual(book_state.name, "Book")
|
||||
|
@ -141,18 +141,18 @@ class StateTests(SimpleTestCase):
|
|||
book_state.options,
|
||||
{"verbose_name": "tome", "db_table": "test_tome", "indexes": [book_index]},
|
||||
)
|
||||
self.assertEqual(book_state.bases, (models.Model, ))
|
||||
self.assertEqual(book_state.bases, (models.Model,))
|
||||
|
||||
self.assertEqual(author_proxy_state.app_label, "migrations")
|
||||
self.assertEqual(author_proxy_state.name, "AuthorProxy")
|
||||
self.assertEqual(author_proxy_state.fields, [])
|
||||
self.assertEqual(author_proxy_state.options, {"proxy": True, "ordering": ["name"], "indexes": []})
|
||||
self.assertEqual(author_proxy_state.bases, ("migrations.author", ))
|
||||
self.assertEqual(author_proxy_state.bases, ("migrations.author",))
|
||||
|
||||
self.assertEqual(sub_author_state.app_label, "migrations")
|
||||
self.assertEqual(sub_author_state.name, "SubAuthor")
|
||||
self.assertEqual(len(sub_author_state.fields), 2)
|
||||
self.assertEqual(sub_author_state.bases, ("migrations.author", ))
|
||||
self.assertEqual(sub_author_state.bases, ("migrations.author",))
|
||||
|
||||
# The default manager is used in migrations
|
||||
self.assertEqual([name for name, mgr in food_state.managers], ['food_mgr'])
|
||||
|
@ -1003,7 +1003,7 @@ class ModelStateTests(SimpleTestCase):
|
|||
self.assertIs(author_state.fields[2][1].null, False)
|
||||
self.assertIs(author_state.fields[3][1].null, True)
|
||||
self.assertEqual(author_state.options, {'swappable': 'TEST_SWAPPABLE_MODEL', 'indexes': []})
|
||||
self.assertEqual(author_state.bases, (models.Model, ))
|
||||
self.assertEqual(author_state.bases, (models.Model,))
|
||||
self.assertEqual(author_state.managers, [])
|
||||
|
||||
@override_settings(TEST_SWAPPABLE_MODEL='migrations.SomeFakeModel')
|
||||
|
@ -1049,7 +1049,7 @@ class ModelStateTests(SimpleTestCase):
|
|||
station_state.options,
|
||||
{'abstract': False, 'swappable': 'TEST_SWAPPABLE_MODEL', 'indexes': []}
|
||||
)
|
||||
self.assertEqual(station_state.bases, ('migrations.searchablelocation', ))
|
||||
self.assertEqual(station_state.bases, ('migrations.searchablelocation',))
|
||||
self.assertEqual(station_state.managers, [])
|
||||
|
||||
@override_settings(TEST_SWAPPABLE_MODEL='migrations.SomeFakeModel')
|
||||
|
|
|
@ -291,7 +291,7 @@ class FormsetTests(TestCase):
|
|||
data = {'test-TOTAL_FORMS': '1',
|
||||
'test-INITIAL_FORMS': '0',
|
||||
'test-MAX_NUM_FORMS': '',
|
||||
'test-0-name': 'Random Place', }
|
||||
'test-0-name': 'Random Place'}
|
||||
with self.assertNumQueries(1):
|
||||
formset = Formset(data, prefix="test")
|
||||
formset.save()
|
||||
|
|
|
@ -625,7 +625,7 @@ class ListFilterTests(CheckTestCase):
|
|||
return 'awesomeness'
|
||||
|
||||
def get_choices(self, request):
|
||||
return (('bit', 'A bit awesome'), ('very', 'Very awesome'), )
|
||||
return (('bit', 'A bit awesome'), ('very', 'Very awesome'))
|
||||
|
||||
def get_queryset(self, cl, qs):
|
||||
return qs
|
||||
|
@ -655,7 +655,7 @@ class ListFilterTests(CheckTestCase):
|
|||
return 'awesomeness'
|
||||
|
||||
def get_choices(self, request):
|
||||
return (('bit', 'A bit awesome'), ('very', 'Very awesome'), )
|
||||
return (('bit', 'A bit awesome'), ('very', 'Very awesome'))
|
||||
|
||||
def get_queryset(self, cl, qs):
|
||||
return qs
|
||||
|
@ -1248,10 +1248,10 @@ class AutocompleteFieldsTests(CheckTestCase):
|
|||
|
||||
def test_autocomplete_is_onetoone(self):
|
||||
class UserAdmin(ModelAdmin):
|
||||
search_fields = ('name', )
|
||||
search_fields = ('name',)
|
||||
|
||||
class Admin(ModelAdmin):
|
||||
autocomplete_fields = ('best_friend', )
|
||||
autocomplete_fields = ('best_friend',)
|
||||
|
||||
site = AdminSite()
|
||||
site.register(User, UserAdmin)
|
||||
|
|
|
@ -18,10 +18,10 @@ class Article(models.Model):
|
|||
author = models.ForeignKey(Author, models.SET_NULL, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return 'Article titled: %s' % (self.title, )
|
||||
return 'Article titled: %s' % self.title
|
||||
|
||||
class Meta:
|
||||
ordering = ['author__name', ]
|
||||
ordering = ['author__name']
|
||||
|
||||
|
||||
# These following 4 models represent a far more complex ordering case.
|
||||
|
|
|
@ -579,7 +579,7 @@ class Order(models.Model):
|
|||
id = models.IntegerField(primary_key=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ('pk', )
|
||||
ordering = ('pk',)
|
||||
|
||||
def __str__(self):
|
||||
return '%s' % self.pk
|
||||
|
@ -590,7 +590,7 @@ class OrderItem(models.Model):
|
|||
status = models.IntegerField()
|
||||
|
||||
class Meta:
|
||||
ordering = ('pk', )
|
||||
ordering = ('pk',)
|
||||
|
||||
def __str__(self):
|
||||
return '%s' % self.pk
|
||||
|
|
|
@ -2351,11 +2351,11 @@ class QuerySetSupportsPythonIdioms(TestCase):
|
|||
|
||||
def test_slicing_cannot_filter_queryset_once_sliced(self):
|
||||
with self.assertRaisesMessage(AssertionError, "Cannot filter a query once a slice has been taken."):
|
||||
Article.objects.all()[0:5].filter(id=1, )
|
||||
Article.objects.all()[0:5].filter(id=1)
|
||||
|
||||
def test_slicing_cannot_reorder_queryset_once_sliced(self):
|
||||
with self.assertRaisesMessage(AssertionError, "Cannot reorder a query once a slice has been taken."):
|
||||
Article.objects.all()[0:5].order_by('id', )
|
||||
Article.objects.all()[0:5].order_by('id')
|
||||
|
||||
def test_slicing_cannot_combine_queries_once_sliced(self):
|
||||
with self.assertRaisesMessage(AssertionError, "Cannot combine queries once a slice has been taken."):
|
||||
|
@ -3581,7 +3581,7 @@ class RelatedLookupTypeTests(TestCase):
|
|||
When passing proxy model objects, child objects, or parent objects,
|
||||
lookups work fine.
|
||||
"""
|
||||
out_a = ['<ObjectA: oa>', ]
|
||||
out_a = ['<ObjectA: oa>']
|
||||
out_b = ['<ObjectB: ob>', '<ObjectB: pob>']
|
||||
out_c = ['<ObjectC: >']
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ class PickleabilityTestCase(TestCase):
|
|||
def test_model_pickle_dynamic(self):
|
||||
class Meta:
|
||||
proxy = True
|
||||
dynclass = type("DynamicEventSubclass", (Event, ), {'Meta': Meta, '__module__': Event.__module__})
|
||||
dynclass = type("DynamicEventSubclass", (Event,), {'Meta': Meta, '__module__': Event.__module__})
|
||||
original = dynclass(pk=1)
|
||||
dumped = pickle.dumps(original)
|
||||
reloaded = pickle.loads(dumped)
|
||||
|
|
|
@ -13,7 +13,7 @@ class StaticTestStorage(storage.StaticFilesStorage):
|
|||
|
||||
@override_settings(
|
||||
STATIC_URL='http://media.example.com/static/',
|
||||
INSTALLED_APPS=('django.contrib.staticfiles', ),
|
||||
INSTALLED_APPS=('django.contrib.staticfiles',),
|
||||
STATICFILES_STORAGE='staticfiles_tests.test_forms.StaticTestStorage',
|
||||
)
|
||||
class StaticFilesFormsMediaTestCase(SimpleTestCase):
|
||||
|
|
|
@ -28,7 +28,7 @@ class GetUniqueCheckTests(unittest.TestCase):
|
|||
self.assertEqual(
|
||||
([(UniqueTogetherModel, ('ifield', 'cfield')),
|
||||
(UniqueTogetherModel, ('ifield', 'efield')),
|
||||
(UniqueTogetherModel, ('id',)), ],
|
||||
(UniqueTogetherModel, ('id',))],
|
||||
[]),
|
||||
m._get_unique_checks()
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue