1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Removed unnecessary trailing commas and spaces in various code.

This commit is contained in:
Mariusz Felisiak 2017-12-28 21:07:29 +01:00 committed by GitHub
parent 058d112ed2
commit 83a36ac49a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 87 additions and 87 deletions

View File

@ -59,7 +59,7 @@ def permission_required(perm, login_url=None, raise_exception=False):
""" """
def check_perms(user): def check_perms(user):
if isinstance(perm, str): if isinstance(perm, str):
perms = (perm, ) perms = (perm,)
else: else:
perms = perm perms = perm
# First check if the user has the permission (even anon users) # First check if the user has the permission (even anon users)

View File

@ -67,7 +67,7 @@ class PermissionRequiredMixin(AccessMixin):
'{0}.get_permission_required().'.format(self.__class__.__name__) '{0}.get_permission_required().'.format(self.__class__.__name__)
) )
if isinstance(self.permission_required, str): if isinstance(self.permission_required, str):
perms = (self.permission_required, ) perms = (self.permission_required,)
else: else:
perms = self.permission_required perms = self.permission_required
return perms return perms

View File

@ -369,7 +369,7 @@ class RasterField(BaseSpatialField):
band_index = int(name) band_index = int(name)
return type( return type(
'SpecificRasterBandTransform', 'SpecificRasterBandTransform',
(RasterBandTransform, ), (RasterBandTransform,),
{'band_index': band_index} {'band_index': band_index}
) )
except ValueError: except ValueError:

View File

@ -52,7 +52,7 @@ class CheckRegistry:
return inner(check) return inner(check)
else: else:
if check: if check:
tags += (check, ) tags += (check,)
return inner return inner
def run_checks(self, app_configs=None, tags=None, include_deployment_checks=False): def run_checks(self, app_configs=None, tags=None, include_deployment_checks=False):

View File

@ -10,7 +10,7 @@ from django.db.models.constants import LOOKUP_SEP
class Command(BaseCommand): class Command(BaseCommand):
help = "Introspects the database tables in the given database and outputs a Django model module." help = "Introspects the database tables in the given database and outputs a Django model module."
requires_system_checks = False requires_system_checks = False
stealth_options = ('table_name_filter', ) stealth_options = ('table_name_filter',)
db_module = 'django.db' db_module = 'django.db'
def add_arguments(self, parser): def add_arguments(self, parser):

View File

@ -276,7 +276,7 @@ class Command(BaseCommand):
biggest_number = max(x for x in numbers if x is not None) biggest_number = max(x for x in numbers if x is not None)
except ValueError: except ValueError:
biggest_number = 1 biggest_number = 1
subclass = type("Migration", (Migration, ), { subclass = type("Migration", (Migration,), {
"dependencies": [(app_label, migration.name) for migration in merge_migrations], "dependencies": [(app_label, migration.name) for migration in merge_migrations],
}) })
migration_name = "%04i_%s" % ( migration_name = "%04i_%s" % (

View File

@ -148,7 +148,7 @@ class Command(BaseCommand):
else: else:
if targets[0][1] is None: if targets[0][1] is None:
self.stdout.write(self.style.MIGRATE_LABEL( self.stdout.write(self.style.MIGRATE_LABEL(
" Unapply all migrations: ") + "%s" % (targets[0][0], ) " Unapply all migrations: ") + "%s" % (targets[0][0],)
) )
else: else:
self.stdout.write(self.style.MIGRATE_LABEL( self.stdout.write(self.style.MIGRATE_LABEL(

View File

@ -153,7 +153,7 @@ class Command(BaseCommand):
replaces.append((migration.app_label, migration.name)) replaces.append((migration.app_label, migration.name))
# Make a new migration with those operations # Make a new migration with those operations
subclass = type("Migration", (migrations.Migration, ), { subclass = type("Migration", (migrations.Migration,), {
"dependencies": dependencies, "dependencies": dependencies,
"operations": new_operations, "operations": new_operations,
"replaces": replaces, "replaces": replaces,

View File

@ -419,7 +419,7 @@ class MigrationAutodetector:
) )
# Unknown dependency. Raise an error. # Unknown dependency. Raise an error.
else: 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): def add_operation(self, app_label, operation, dependencies=None, beginning=False):
# Dependencies are (app_label, model_name, field_name, create/delete as True/False) # Dependencies are (app_label, model_name, field_name, create/delete as True/False)

View File

@ -43,7 +43,7 @@ class NodeNotFoundError(LookupError):
return self.message return self.message
def __repr__(self): def __repr__(self):
return "NodeNotFoundError(%r)" % (self.node, ) return "NodeNotFoundError(%r)" % (self.node,)
class MigrationSchemaMissing(DatabaseError): class MigrationSchemaMissing(DatabaseError):

View File

@ -178,7 +178,7 @@ class MigrationGraph:
except KeyError as err: except KeyError as err:
raise NodeNotFoundError( raise NodeNotFoundError(
"Unable to find replacement node %r. It was either never added" "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 replacement
) from err ) from err
for replaced_key in replaced: for replaced_key in replaced:
@ -214,7 +214,7 @@ class MigrationGraph:
except KeyError as err: except KeyError as err:
raise NodeNotFoundError( raise NodeNotFoundError(
"Unable to remove replacement node %r. It was either never added" "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 replacement
) from err ) from err
replaced_nodes = set() replaced_nodes = set()
@ -256,7 +256,7 @@ class MigrationGraph:
follow if applying the migrations to a database. follow if applying the migrations to a database.
""" """
if target not in self.nodes: 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 # 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.ensure_not_cyclic(target, lambda x: (parent.key for parent in self.node_map[x].parents))
self.cached = True self.cached = True
@ -275,7 +275,7 @@ class MigrationGraph:
would follow if removing the migrations from a database. would follow if removing the migrations from a database.
""" """
if target not in self.nodes: 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 # 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.ensure_not_cyclic(target, lambda x: (child.key for child in self.node_map[x].children))
self.cached = True self.cached = True

View File

@ -249,7 +249,7 @@ class DeleteModel(ModelOperation):
schema_editor.create_model(model) schema_editor.create_model(model)
def describe(self): def describe(self):
return "Delete model %s" % (self.name, ) return "Delete model %s" % self.name
class RenameModel(ModelOperation): class RenameModel(ModelOperation):
@ -701,7 +701,7 @@ class AlterModelOptions(ModelOptionOperation):
pass pass
def describe(self): def describe(self):
return "Change Meta options on %s" % (self.name, ) return "Change Meta options on %s" % self.name
class AlterModelManagers(ModelOptionOperation): class AlterModelManagers(ModelOptionOperation):
@ -732,7 +732,7 @@ class AlterModelManagers(ModelOptionOperation):
pass pass
def describe(self): def describe(self):
return "Change managers on %s" % (self.name, ) return "Change managers on %s" % self.name
class IndexOperation(Operation): class IndexOperation(Operation):

View File

@ -362,7 +362,7 @@ class ModelState:
self.fields = fields self.fields = fields
self.options = options or {} self.options = options or {}
self.options.setdefault('indexes', []) self.options.setdefault('indexes', [])
self.bases = bases or (models.Model, ) self.bases = bases or (models.Model,)
self.managers = managers or [] self.managers = managers or []
# Sanity-check that fields is NOT a dict. It must be ordered. # Sanity-check that fields is NOT a dict. It must be ordered.
if isinstance(self.fields, dict): if isinstance(self.fields, dict):

View File

@ -284,7 +284,7 @@ man_pages = [(
'Utility script for the Django Web framework', 'Utility script for the Django Web framework',
['Django Software Foundation'], ['Django Software Foundation'],
1 1
), ] )]
# -- Options for Texinfo output ------------------------------------------------ # -- Options for Texinfo output ------------------------------------------------

View File

@ -193,7 +193,7 @@ registering a custom ``ModelAdmin`` for ``FlatPage``::
fieldsets = ( fieldsets = (
(None, {'fields': ('url', 'title', 'content', 'sites')}), (None, {'fields': ('url', 'title', 'content', 'sites')}),
(_('Advanced options'), { (_('Advanced options'), {
'classes': ('collapse', ), 'classes': ('collapse',),
'fields': ( 'fields': (
'enable_comments', 'enable_comments',
'registration_required', 'registration_required',

View File

@ -1029,7 +1029,7 @@ attributes. Thus, you can subclass the appropriate feed generator class
.. _georss: http://georss.org/ .. _georss: http://georss.org/
.. _itunes podcast format: https://www.apple.com/itunes/podcasts/specs.html .. _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 Return a ``dict`` of attributes to add to the root feed element
(``feed``/``channel``). (``feed``/``channel``).

View File

@ -348,7 +348,7 @@ add it to a ``UserAdmin`` class which is registered with the
# Define a new User admin # Define a new User admin
class UserAdmin(BaseUserAdmin): class UserAdmin(BaseUserAdmin):
inlines = (EmployeeInline, ) inlines = (EmployeeInline,)
# Re-register UserAdmin # Re-register UserAdmin
admin.site.unregister(User) admin.site.unregister(User)

View File

@ -229,15 +229,15 @@ class EmployeeAdmin(ModelAdmin):
class DepartmentFilterEmployeeAdmin(EmployeeAdmin): class DepartmentFilterEmployeeAdmin(EmployeeAdmin):
list_filter = [DepartmentListFilterLookupWithNonStringValue, ] list_filter = [DepartmentListFilterLookupWithNonStringValue]
class DepartmentFilterUnderscoredEmployeeAdmin(EmployeeAdmin): class DepartmentFilterUnderscoredEmployeeAdmin(EmployeeAdmin):
list_filter = [DepartmentListFilterLookupWithUnderscoredParameter, ] list_filter = [DepartmentListFilterLookupWithUnderscoredParameter]
class DepartmentFilterDynamicValueBookAdmin(EmployeeAdmin): class DepartmentFilterDynamicValueBookAdmin(EmployeeAdmin):
list_filter = [DepartmentListFilterLookupWithDynamicValue, ] list_filter = [DepartmentListFilterLookupWithDynamicValue]
class BookmarkAdminGenericRelation(ModelAdmin): class BookmarkAdminGenericRelation(ModelAdmin):

View File

@ -27,7 +27,7 @@ class SongInlineDefaultOrdering(admin.StackedInline):
class SongInlineNewOrdering(admin.StackedInline): class SongInlineNewOrdering(admin.StackedInline):
model = Song model = Song
ordering = ('duration', ) ordering = ('duration',)
class DynOrderingBandAdmin(admin.ModelAdmin): class DynOrderingBandAdmin(admin.ModelAdmin):

View File

@ -568,7 +568,7 @@ class StoryForm(forms.ModelForm):
class StoryAdmin(admin.ModelAdmin): class StoryAdmin(admin.ModelAdmin):
list_display = ('id', 'title', 'content') list_display = ('id', 'title', 'content')
list_display_links = ('title',) # 'id' not in list_display_links list_display_links = ('title',) # 'id' not in list_display_links
list_editable = ('content', ) list_editable = ('content',)
form = StoryForm form = StoryForm
ordering = ['-id'] ordering = ['-id']
@ -576,7 +576,7 @@ class StoryAdmin(admin.ModelAdmin):
class OtherStoryAdmin(admin.ModelAdmin): class OtherStoryAdmin(admin.ModelAdmin):
list_display = ('id', 'title', 'content') list_display = ('id', 'title', 'content')
list_display_links = ('title', 'id') # 'id' in list_display_links list_display_links = ('title', 'id') # 'id' in list_display_links
list_editable = ('content', ) list_editable = ('content',)
ordering = ['-id'] ordering = ['-id']
@ -748,7 +748,7 @@ def callable_on_unknown(obj):
class AttributeErrorRaisingAdmin(admin.ModelAdmin): class AttributeErrorRaisingAdmin(admin.ModelAdmin):
list_display = [callable_on_unknown, ] list_display = [callable_on_unknown]
class CustomManagerAdmin(admin.ModelAdmin): class CustomManagerAdmin(admin.ModelAdmin):

View File

@ -518,6 +518,6 @@ class CheckAllowedHostsTest(SimpleTestCase):
def test_allowed_hosts_empty(self): def test_allowed_hosts_empty(self):
self.assertEqual(self.func(None), [base.W020]) 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): def test_allowed_hosts_set(self):
self.assertEqual(self.func(None), []) self.assertEqual(self.func(None), [])

View File

@ -30,10 +30,10 @@ class SystemCheckFrameworkTests(SimpleTestCase):
return [1, 2, 3] return [1, 2, 3]
def f2(**kwargs): def f2(**kwargs):
return [4, ] return [4]
def f3(**kwargs): def f3(**kwargs):
return [5, ] return [5]
calls = [0] calls = [0]

View File

@ -6,7 +6,7 @@ from django.test import TestCase, modify_settings, override_settings
from django.utils import translation 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) @override_settings(SITE_ID=1)
class FlatpageAdminFormTests(TestCase): class FlatpageAdminFormTests(TestCase):

View File

@ -256,7 +256,7 @@ class GDALRasterTests(SimpleTestCase):
if numpy: if numpy:
result = result.flatten().tolist() result = result.flatten().tolist()
# All band data is equal to nodata value. # 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): def test_set_nodata_none_on_raster_creation(self):
if GDAL_VERSION < (2, 1): if GDAL_VERSION < (2, 1):
@ -299,7 +299,7 @@ class GDALRasterTests(SimpleTestCase):
}) })
# Set metadata on raster and on a band. # Set metadata on raster and on a band.
metadata = { 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.metadata = metadata
source.bands[0].metadata = metadata source.bands[0].metadata = metadata
@ -307,13 +307,13 @@ class GDALRasterTests(SimpleTestCase):
self.assertEqual(source.bands[0].metadata['DEFAULT'], metadata['DEFAULT']) self.assertEqual(source.bands[0].metadata['DEFAULT'], metadata['DEFAULT'])
# Update metadata on raster. # Update metadata on raster.
metadata = { metadata = {
'DEFAULT': {'VERSION': '2.0', }, 'DEFAULT': {'VERSION': '2.0'},
} }
source.metadata = metadata source.metadata = metadata
self.assertEqual(source.metadata['DEFAULT']['VERSION'], '2.0') self.assertEqual(source.metadata['DEFAULT']['VERSION'], '2.0')
# Remove metadata on raster. # Remove metadata on raster.
metadata = { metadata = {
'DEFAULT': {'OWNER': None, }, 'DEFAULT': {'OWNER': None},
} }
source.metadata = metadata source.metadata = metadata
self.assertNotIn('OWNER', source.metadata['DEFAULT']) self.assertNotIn('OWNER', source.metadata['DEFAULT'])

View File

@ -1264,7 +1264,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
mp = MultiPolygon(p1, p2) mp = MultiPolygon(p1, p2)
path, args, kwargs = mp.deconstruct() path, args, kwargs = mp.deconstruct()
self.assertEqual(path, 'django.contrib.gis.geos.collections.MultiPolygon') self.assertEqual(path, 'django.contrib.gis.geos.collections.MultiPolygon')
self.assertEqual(args, (p1, p2, )) self.assertEqual(args, (p1, p2))
self.assertEqual(kwargs, {}) self.assertEqual(kwargs, {})
poly = Polygon(((0, 0), (0, 1), (1, 1), (0, 0))) poly = Polygon(((0, 0), (0, 1), (1, 1), (0, 0)))

View File

@ -1142,7 +1142,7 @@ class MiscTests(SimpleTestCase):
('en; q=1.0, * ; q=0.5', [('en', 1.0), ('*', 0.5)]), ('en; q=1.0, * ; q=0.5', [('en', 1.0), ('*', 0.5)]),
# Bad headers # Bad headers
('en-gb;q=1.0000', []), ('en-gb;q=1.0000', []),
('en;q=0.1234', [], ), ('en;q=0.1234', []),
('en;q=.2', []), ('en;q=.2', []),
('abcdefghi-au', []), ('abcdefghi-au', []),
('**', []), ('**', []),

View File

@ -19,7 +19,7 @@ class Author(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
class Meta: class Meta:
ordering = ('name', ) ordering = ('name',)
class Article(models.Model): class Article(models.Model):
@ -40,7 +40,7 @@ class Tag(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
class Meta: class Meta:
ordering = ('name', ) ordering = ('name',)
class NulledTextField(models.TextField): class NulledTextField(models.TextField):

View File

@ -87,7 +87,7 @@ class M2mThroughTests(TestCase):
self.assertQuerysetEqual( self.assertQuerysetEqual(
self.rock.members.all(), self.rock.members.all(),
['Jim', ], ['Jim'],
attrgetter("name") attrgetter("name")
) )
@ -156,7 +156,7 @@ class M2mThroughTests(TestCase):
self.assertQuerysetEqual( self.assertQuerysetEqual(
self.bob.group_set.all(), self.bob.group_set.all(),
['Rock', ], ['Rock'],
attrgetter('name') attrgetter('name')
) )
@ -192,7 +192,7 @@ class M2mThroughTests(TestCase):
self.assertQuerysetEqual( self.assertQuerysetEqual(
Group.objects.filter(members__name='Bob'), Group.objects.filter(members__name='Bob'),
['Roll', ], ['Roll'],
attrgetter("name") attrgetter("name")
) )

View File

@ -237,13 +237,13 @@ class AutodetectorTests(TestCase):
author_proxy_options = ModelState("testapp", "AuthorProxy", [], { author_proxy_options = ModelState("testapp", "AuthorProxy", [], {
"proxy": True, "proxy": True,
"verbose_name": "Super Author", "verbose_name": "Super Author",
}, ("testapp.author", )) }, ("testapp.author",))
author_proxy_notproxy = ModelState("testapp", "AuthorProxy", [], {}, ("testapp.author", )) author_proxy_notproxy = ModelState("testapp", "AuthorProxy", [], {}, ("testapp.author",))
author_proxy_third = ModelState("thirdapp", "AuthorProxy", [], {"proxy": True}, ("testapp.author", )) author_proxy_third = ModelState("thirdapp", "AuthorProxy", [], {"proxy": True}, ("testapp.author",))
author_proxy_third_notproxy = ModelState("thirdapp", "AuthorProxy", [], {}, ("testapp.author", )) author_proxy_third_notproxy = ModelState("thirdapp", "AuthorProxy", [], {}, ("testapp.author",))
author_proxy_proxy = ModelState("testapp", "AAuthorProxyProxy", [], {"proxy": True}, ("testapp.authorproxy", )) author_proxy_proxy = ModelState("testapp", "AAuthorProxyProxy", [], {"proxy": True}, ("testapp.authorproxy",))
author_unmanaged = ModelState("testapp", "AuthorUnmanaged", [], {"managed": False}, ("testapp.author", )) author_unmanaged = ModelState("testapp", "AuthorUnmanaged", [], {"managed": False}, ("testapp.author",))
author_unmanaged_managed = ModelState("testapp", "AuthorUnmanaged", [], {}, ("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_default_pk = ModelState("testapp", "Author", [("id", models.AutoField(primary_key=True))])
author_unmanaged_custom_pk = ModelState("testapp", "Author", [ author_unmanaged_custom_pk = ModelState("testapp", "Author", [
("pk_field", models.IntegerField(primary_key=True)), ("pk_field", models.IntegerField(primary_key=True)),
@ -430,14 +430,14 @@ class AutodetectorTests(TestCase):
custom_user = ModelState("thirdapp", "CustomUser", [ custom_user = ModelState("thirdapp", "CustomUser", [
("id", models.AutoField(primary_key=True)), ("id", models.AutoField(primary_key=True)),
("username", models.CharField(max_length=255)), ("username", models.CharField(max_length=255)),
], bases=(AbstractBaseUser, )) ], bases=(AbstractBaseUser,))
custom_user_no_inherit = ModelState("thirdapp", "CustomUser", [ custom_user_no_inherit = ModelState("thirdapp", "CustomUser", [
("id", models.AutoField(primary_key=True)), ("id", models.AutoField(primary_key=True)),
("username", models.CharField(max_length=255)), ("username", models.CharField(max_length=255)),
]) ])
aardvark = ModelState("thirdapp", "Aardvark", [("id", models.AutoField(primary_key=True))]) aardvark = ModelState("thirdapp", "Aardvark", [("id", models.AutoField(primary_key=True))])
aardvark_testapp = ModelState("testapp", "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", [ aardvark_pk_fk_author = ModelState("testapp", "Aardvark", [
("id", models.OneToOneField("testapp.Author", models.CASCADE, primary_key=True)), ("id", models.OneToOneField("testapp.Author", models.CASCADE, primary_key=True)),
]) ])
@ -2071,7 +2071,7 @@ class AutodetectorTests(TestCase):
tenant = ModelState("a", "Tenant", [ tenant = ModelState("a", "Tenant", [
("id", models.AutoField(primary_key=True)), ("id", models.AutoField(primary_key=True)),
("primary_address", models.ForeignKey("b.Address", models.CASCADE))], ("primary_address", models.ForeignKey("b.Address", models.CASCADE))],
bases=(AbstractBaseUser, ) bases=(AbstractBaseUser,)
) )
address = ModelState("b", "Address", [ address = ModelState("b", "Address", [
("id", models.AutoField(primary_key=True)), ("id", models.AutoField(primary_key=True)),
@ -2105,7 +2105,7 @@ class AutodetectorTests(TestCase):
tenant = ModelState("b", "Tenant", [ tenant = ModelState("b", "Tenant", [
("id", models.AutoField(primary_key=True)), ("id", models.AutoField(primary_key=True)),
("primary_address", models.ForeignKey("a.Address", models.CASCADE))], ("primary_address", models.ForeignKey("a.Address", models.CASCADE))],
bases=(AbstractBaseUser, ) bases=(AbstractBaseUser,)
) )
changes = self.get_changes([], [address, tenant]) changes = self.get_changes([], [address, tenant])
# Right number/type of migrations? # Right number/type of migrations?

View File

@ -554,14 +554,14 @@ class ExecutorTests(MigrationTestBase):
migrations = executor.loader.graph.nodes migrations = executor.loader.graph.nodes
expected = [ expected = [
("render_start", ), ("render_start",),
("render_success", ), ("render_success",),
("apply_start", migrations['migrations', '0001_initial'], False), ("apply_start", migrations['migrations', '0001_initial'], False),
("apply_success", migrations['migrations', '0001_initial'], False), ("apply_success", migrations['migrations', '0001_initial'], False),
("apply_start", migrations['migrations', '0002_second'], False), ("apply_start", migrations['migrations', '0002_second'], False),
("apply_success", migrations['migrations', '0002_second'], False), ("apply_success", migrations['migrations', '0002_second'], False),
("render_start", ), ("render_start",),
("render_success", ), ("render_success",),
("unapply_start", migrations['migrations', '0002_second'], False), ("unapply_start", migrations['migrations', '0002_second'], False),
("unapply_success", migrations['migrations', '0002_second'], False), ("unapply_success", migrations['migrations', '0002_second'], False),
("unapply_start", migrations['migrations', '0001_initial'], False), ("unapply_start", migrations['migrations', '0001_initial'], False),

View File

@ -147,7 +147,7 @@ class GraphTests(SimpleTestCase):
graph.add_dependency("app_b.0001", ("app_b", "0001"), ("app_a", "0003")) graph.add_dependency("app_b.0001", ("app_b", "0001"), ("app_a", "0003"))
# Test whole graph # Test whole graph
with self.assertRaises(CircularDependencyError): with self.assertRaises(CircularDependencyError):
graph.forwards_plan(("app_a", "0003"), ) graph.forwards_plan(("app_a", "0003"))
def test_circular_graph_2(self): def test_circular_graph_2(self):
graph = MigrationGraph() graph = MigrationGraph()

View File

@ -409,7 +409,7 @@ class OperationTests(OperationTestBase):
"ProxyPony", "ProxyPony",
[], [],
options={"proxy": True}, options={"proxy": True},
bases=("test_crprmo.Pony", ), bases=("test_crprmo.Pony",),
) )
self.assertEqual(operation.describe(), "Create proxy model ProxyPony") self.assertEqual(operation.describe(), "Create proxy model ProxyPony")
new_state = project_state.clone() new_state = project_state.clone()
@ -443,7 +443,7 @@ class OperationTests(OperationTestBase):
"UnmanagedPony", "UnmanagedPony",
[], [],
options={"proxy": True}, options={"proxy": True},
bases=("test_crummo.Pony", ), bases=("test_crummo.Pony",),
) )
self.assertEqual(operation.describe(), "Create proxy model UnmanagedPony") self.assertEqual(operation.describe(), "Create proxy model UnmanagedPony")
new_state = project_state.clone() new_state = project_state.clone()

View File

@ -243,7 +243,7 @@ class OptimizerTests(SimpleTestCase):
self.assertDoesNotOptimize( self.assertDoesNotOptimize(
[ [
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]), 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.DeleteModel("Foo"),
], ],
) )
@ -252,11 +252,11 @@ class OptimizerTests(SimpleTestCase):
self.assertOptimizesTo( self.assertOptimizesTo(
[ [
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]), 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.DeleteModel("Foo"),
], ],
[ [
migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo", )), migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo",)),
], ],
app_label="otherapp", app_label="otherapp",
) )
@ -264,7 +264,7 @@ class OptimizerTests(SimpleTestCase):
self.assertDoesNotOptimize( self.assertDoesNotOptimize(
[ [
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]), 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.DeleteModel("Foo"),
], ],
app_label="testapp", app_label="testapp",

View File

@ -129,7 +129,7 @@ class StateTests(SimpleTestCase):
author_state.options, author_state.options,
{"unique_together": {("name", "bio")}, "index_together": {("bio", "age")}, "indexes": []} {"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.app_label, "migrations")
self.assertEqual(book_state.name, "Book") self.assertEqual(book_state.name, "Book")
@ -141,18 +141,18 @@ class StateTests(SimpleTestCase):
book_state.options, book_state.options,
{"verbose_name": "tome", "db_table": "test_tome", "indexes": [book_index]}, {"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.app_label, "migrations")
self.assertEqual(author_proxy_state.name, "AuthorProxy") self.assertEqual(author_proxy_state.name, "AuthorProxy")
self.assertEqual(author_proxy_state.fields, []) self.assertEqual(author_proxy_state.fields, [])
self.assertEqual(author_proxy_state.options, {"proxy": True, "ordering": ["name"], "indexes": []}) 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.app_label, "migrations")
self.assertEqual(sub_author_state.name, "SubAuthor") self.assertEqual(sub_author_state.name, "SubAuthor")
self.assertEqual(len(sub_author_state.fields), 2) 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 # The default manager is used in migrations
self.assertEqual([name for name, mgr in food_state.managers], ['food_mgr']) 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[2][1].null, False)
self.assertIs(author_state.fields[3][1].null, True) self.assertIs(author_state.fields[3][1].null, True)
self.assertEqual(author_state.options, {'swappable': 'TEST_SWAPPABLE_MODEL', 'indexes': []}) 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, []) self.assertEqual(author_state.managers, [])
@override_settings(TEST_SWAPPABLE_MODEL='migrations.SomeFakeModel') @override_settings(TEST_SWAPPABLE_MODEL='migrations.SomeFakeModel')
@ -1049,7 +1049,7 @@ class ModelStateTests(SimpleTestCase):
station_state.options, station_state.options,
{'abstract': False, 'swappable': 'TEST_SWAPPABLE_MODEL', 'indexes': []} {'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, []) self.assertEqual(station_state.managers, [])
@override_settings(TEST_SWAPPABLE_MODEL='migrations.SomeFakeModel') @override_settings(TEST_SWAPPABLE_MODEL='migrations.SomeFakeModel')

View File

@ -291,7 +291,7 @@ class FormsetTests(TestCase):
data = {'test-TOTAL_FORMS': '1', data = {'test-TOTAL_FORMS': '1',
'test-INITIAL_FORMS': '0', 'test-INITIAL_FORMS': '0',
'test-MAX_NUM_FORMS': '', 'test-MAX_NUM_FORMS': '',
'test-0-name': 'Random Place', } 'test-0-name': 'Random Place'}
with self.assertNumQueries(1): with self.assertNumQueries(1):
formset = Formset(data, prefix="test") formset = Formset(data, prefix="test")
formset.save() formset.save()

View File

@ -625,7 +625,7 @@ class ListFilterTests(CheckTestCase):
return 'awesomeness' return 'awesomeness'
def get_choices(self, request): 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): def get_queryset(self, cl, qs):
return qs return qs
@ -655,7 +655,7 @@ class ListFilterTests(CheckTestCase):
return 'awesomeness' return 'awesomeness'
def get_choices(self, request): 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): def get_queryset(self, cl, qs):
return qs return qs
@ -1248,10 +1248,10 @@ class AutocompleteFieldsTests(CheckTestCase):
def test_autocomplete_is_onetoone(self): def test_autocomplete_is_onetoone(self):
class UserAdmin(ModelAdmin): class UserAdmin(ModelAdmin):
search_fields = ('name', ) search_fields = ('name',)
class Admin(ModelAdmin): class Admin(ModelAdmin):
autocomplete_fields = ('best_friend', ) autocomplete_fields = ('best_friend',)
site = AdminSite() site = AdminSite()
site.register(User, UserAdmin) site.register(User, UserAdmin)

View File

@ -18,10 +18,10 @@ class Article(models.Model):
author = models.ForeignKey(Author, models.SET_NULL, null=True) author = models.ForeignKey(Author, models.SET_NULL, null=True)
def __str__(self): def __str__(self):
return 'Article titled: %s' % (self.title, ) return 'Article titled: %s' % self.title
class Meta: class Meta:
ordering = ['author__name', ] ordering = ['author__name']
# These following 4 models represent a far more complex ordering case. # These following 4 models represent a far more complex ordering case.

View File

@ -579,7 +579,7 @@ class Order(models.Model):
id = models.IntegerField(primary_key=True) id = models.IntegerField(primary_key=True)
class Meta: class Meta:
ordering = ('pk', ) ordering = ('pk',)
def __str__(self): def __str__(self):
return '%s' % self.pk return '%s' % self.pk
@ -590,7 +590,7 @@ class OrderItem(models.Model):
status = models.IntegerField() status = models.IntegerField()
class Meta: class Meta:
ordering = ('pk', ) ordering = ('pk',)
def __str__(self): def __str__(self):
return '%s' % self.pk return '%s' % self.pk

View File

@ -2351,11 +2351,11 @@ class QuerySetSupportsPythonIdioms(TestCase):
def test_slicing_cannot_filter_queryset_once_sliced(self): def test_slicing_cannot_filter_queryset_once_sliced(self):
with self.assertRaisesMessage(AssertionError, "Cannot filter a query once a slice has been taken."): 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): def test_slicing_cannot_reorder_queryset_once_sliced(self):
with self.assertRaisesMessage(AssertionError, "Cannot reorder a query once a slice has been taken."): 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): def test_slicing_cannot_combine_queries_once_sliced(self):
with self.assertRaisesMessage(AssertionError, "Cannot combine queries once a slice has been taken."): 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, When passing proxy model objects, child objects, or parent objects,
lookups work fine. lookups work fine.
""" """
out_a = ['<ObjectA: oa>', ] out_a = ['<ObjectA: oa>']
out_b = ['<ObjectB: ob>', '<ObjectB: pob>'] out_b = ['<ObjectB: ob>', '<ObjectB: pob>']
out_c = ['<ObjectC: >'] out_c = ['<ObjectC: >']

View File

@ -102,7 +102,7 @@ class PickleabilityTestCase(TestCase):
def test_model_pickle_dynamic(self): def test_model_pickle_dynamic(self):
class Meta: class Meta:
proxy = True proxy = True
dynclass = type("DynamicEventSubclass", (Event, ), {'Meta': Meta, '__module__': Event.__module__}) dynclass = type("DynamicEventSubclass", (Event,), {'Meta': Meta, '__module__': Event.__module__})
original = dynclass(pk=1) original = dynclass(pk=1)
dumped = pickle.dumps(original) dumped = pickle.dumps(original)
reloaded = pickle.loads(dumped) reloaded = pickle.loads(dumped)

View File

@ -13,7 +13,7 @@ class StaticTestStorage(storage.StaticFilesStorage):
@override_settings( @override_settings(
STATIC_URL='http://media.example.com/static/', STATIC_URL='http://media.example.com/static/',
INSTALLED_APPS=('django.contrib.staticfiles', ), INSTALLED_APPS=('django.contrib.staticfiles',),
STATICFILES_STORAGE='staticfiles_tests.test_forms.StaticTestStorage', STATICFILES_STORAGE='staticfiles_tests.test_forms.StaticTestStorage',
) )
class StaticFilesFormsMediaTestCase(SimpleTestCase): class StaticFilesFormsMediaTestCase(SimpleTestCase):

View File

@ -28,7 +28,7 @@ class GetUniqueCheckTests(unittest.TestCase):
self.assertEqual( self.assertEqual(
([(UniqueTogetherModel, ('ifield', 'cfield')), ([(UniqueTogetherModel, ('ifield', 'cfield')),
(UniqueTogetherModel, ('ifield', 'efield')), (UniqueTogetherModel, ('ifield', 'efield')),
(UniqueTogetherModel, ('id',)), ], (UniqueTogetherModel, ('id',))],
[]), []),
m._get_unique_checks() m._get_unique_checks()
) )