diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index e5d79d2c6d..0d10d29a04 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -2087,9 +2087,11 @@ class InlineModelAdmin(BaseModelAdmin): 'class_name': p._meta.verbose_name, 'instance': p} ) - params = {'class_name': self._meta.model._meta.verbose_name, - 'instance': self.instance, - 'related_objects': get_text_list(objs, _('and'))} + params = { + 'class_name': self._meta.model._meta.verbose_name, + 'instance': self.instance, + 'related_objects': get_text_list(objs, _('and')), + } msg = _("Deleting %(class_name)s %(instance)s would require " "deleting the following protected related objects: " "%(related_objects)s") diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index 99013f0d9f..b03e4b6470 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -36,10 +36,12 @@ def paginator_number(cl, i): elif i == cl.page_num: return format_html('{} ', i + 1) else: - return format_html('{} ', - cl.get_query_string({PAGE_VAR: i}), - mark_safe(' class="end"' if i == cl.paginator.num_pages - 1 else ''), - i + 1) + return format_html( + '{} ', + cl.get_query_string({PAGE_VAR: i}), + mark_safe(' class="end"' if i == cl.paginator.num_pages - 1 else ''), + i + 1, + ) def pagination(cl): @@ -190,8 +192,7 @@ def result_headers(cl): def _boolean_icon(field_val): - icon_url = static('admin/img/icon-%s.svg' % - {True: 'yes', False: 'no', None: 'unknown'}[field_val]) + icon_url = static('admin/img/icon-%s.svg' % {True: 'yes', False: 'no', None: 'unknown'}[field_val]) return format_html('', icon_url, field_val) @@ -279,11 +280,7 @@ def items_for_result(cl, result, form): ) if cl.is_popup else '', result_repr) - yield format_html('<{}{}>{}{}>', - table_tag, - row_class, - link_or_text, - table_tag) + yield format_html('<{}{}>{}{}>', table_tag, row_class, link_or_text, table_tag) else: # By default the fields come from ModelAdmin.list_editable, but if we pull # the fields out of the form instead of list_editable custom admins @@ -334,11 +331,13 @@ def result_list(cl): for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields += 1 - return {'cl': cl, - 'result_hidden_fields': list(result_hidden_fields(cl)), - 'result_headers': headers, - 'num_sorted_fields': num_sorted_fields, - 'results': list(results(cl))} + return { + 'cl': cl, + 'result_hidden_fields': list(result_hidden_fields(cl)), + 'result_headers': headers, + 'num_sorted_fields': num_sorted_fields, + 'results': list(results(cl)), + } @register.tag(name='result_list') diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py index 1056297468..6709e63485 100644 --- a/django/contrib/auth/admin.py +++ b/django/contrib/auth/admin.py @@ -44,8 +44,9 @@ class UserAdmin(admin.ModelAdmin): fieldsets = ( (None, {'fields': ('username', 'password')}), (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}), - (_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', - 'groups', 'user_permissions')}), + (_('Permissions'), { + 'fields': ('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions'), + }), (_('Important dates'), {'fields': ('last_login', 'date_joined')}), ) add_fieldsets = ( diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py index fe74df36ff..9b758a742d 100644 --- a/django/contrib/gis/admin/options.py +++ b/django/contrib/gis/admin/options.py @@ -86,40 +86,41 @@ class GeoModelAdmin(ModelAdmin): wms_options = ["%s: '%s'" % pair for pair in self.wms_options.items()] wms_options = ', %s' % ', '.join(wms_options) - params = {'default_lon': self.default_lon, - 'default_lat': self.default_lat, - 'default_zoom': self.default_zoom, - 'display_wkt': self.debug or self.display_wkt, - 'geom_type': OGRGeomType(db_field.geom_type), - 'field_name': db_field.name, - 'is_collection': is_collection, - 'scrollable': self.scrollable, - 'layerswitcher': self.layerswitcher, - 'collection_type': collection_type, - 'is_generic': db_field.geom_type == 'GEOMETRY', - 'is_linestring': db_field.geom_type in ('LINESTRING', 'MULTILINESTRING'), - 'is_polygon': db_field.geom_type in ('POLYGON', 'MULTIPOLYGON'), - 'is_point': db_field.geom_type in ('POINT', 'MULTIPOINT'), - 'num_zoom': self.num_zoom, - 'max_zoom': self.max_zoom, - 'min_zoom': self.min_zoom, - 'units': self.units, # likely should get from object - 'max_resolution': self.max_resolution, - 'max_extent': self.max_extent, - 'modifiable': self.modifiable, - 'mouse_position': self.mouse_position, - 'scale_text': self.scale_text, - 'map_width': self.map_width, - 'map_height': self.map_height, - 'point_zoom': self.point_zoom, - 'srid': self.map_srid, - 'display_srid': self.display_srid, - 'wms_url': self.wms_url, - 'wms_layer': self.wms_layer, - 'wms_name': self.wms_name, - 'wms_options': wms_options, - 'debug': self.debug, - } + params = { + 'default_lon': self.default_lon, + 'default_lat': self.default_lat, + 'default_zoom': self.default_zoom, + 'display_wkt': self.debug or self.display_wkt, + 'geom_type': OGRGeomType(db_field.geom_type), + 'field_name': db_field.name, + 'is_collection': is_collection, + 'scrollable': self.scrollable, + 'layerswitcher': self.layerswitcher, + 'collection_type': collection_type, + 'is_generic': db_field.geom_type == 'GEOMETRY', + 'is_linestring': db_field.geom_type in ('LINESTRING', 'MULTILINESTRING'), + 'is_polygon': db_field.geom_type in ('POLYGON', 'MULTIPOLYGON'), + 'is_point': db_field.geom_type in ('POINT', 'MULTIPOINT'), + 'num_zoom': self.num_zoom, + 'max_zoom': self.max_zoom, + 'min_zoom': self.min_zoom, + 'units': self.units, # likely should get from object + 'max_resolution': self.max_resolution, + 'max_extent': self.max_extent, + 'modifiable': self.modifiable, + 'mouse_position': self.mouse_position, + 'scale_text': self.scale_text, + 'map_width': self.map_width, + 'map_height': self.map_height, + 'point_zoom': self.point_zoom, + 'srid': self.map_srid, + 'display_srid': self.display_srid, + 'wms_url': self.wms_url, + 'wms_layer': self.wms_layer, + 'wms_name': self.wms_name, + 'wms_options': wms_options, + 'debug': self.debug, + } return OLMap diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py index 7adfe1ad87..6bc5df53cf 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -696,19 +696,20 @@ class MultiPolygon(GeometryCollection): # Class mapping dictionary (using the OGRwkbGeometryType as the key) -GEO_CLASSES = {1: Point, - 2: LineString, - 3: Polygon, - 4: MultiPoint, - 5: MultiLineString, - 6: MultiPolygon, - 7: GeometryCollection, - 101: LinearRing, - 1 + OGRGeomType.wkb25bit: Point, - 2 + OGRGeomType.wkb25bit: LineString, - 3 + OGRGeomType.wkb25bit: Polygon, - 4 + OGRGeomType.wkb25bit: MultiPoint, - 5 + OGRGeomType.wkb25bit: MultiLineString, - 6 + OGRGeomType.wkb25bit: MultiPolygon, - 7 + OGRGeomType.wkb25bit: GeometryCollection, - } +GEO_CLASSES = { + 1: Point, + 2: LineString, + 3: Polygon, + 4: MultiPoint, + 5: MultiLineString, + 6: MultiPolygon, + 7: GeometryCollection, + 101: LinearRing, + 1 + OGRGeomType.wkb25bit: Point, + 2 + OGRGeomType.wkb25bit: LineString, + 3 + OGRGeomType.wkb25bit: Polygon, + 4 + OGRGeomType.wkb25bit: MultiPoint, + 5 + OGRGeomType.wkb25bit: MultiLineString, + 6 + OGRGeomType.wkb25bit: MultiPolygon, + 7 + OGRGeomType.wkb25bit: GeometryCollection, +} diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py index 3e5fea7484..591c680c59 100644 --- a/django/contrib/gis/gdal/geomtype.py +++ b/django/contrib/gis/gdal/geomtype.py @@ -7,25 +7,26 @@ class OGRGeomType: wkb25bit = -2147483648 # Dictionary of acceptable OGRwkbGeometryType s and their string names. - _types = {0: 'Unknown', - 1: 'Point', - 2: 'LineString', - 3: 'Polygon', - 4: 'MultiPoint', - 5: 'MultiLineString', - 6: 'MultiPolygon', - 7: 'GeometryCollection', - 100: 'None', - 101: 'LinearRing', - 102: 'PointZ', - 1 + wkb25bit: 'Point25D', - 2 + wkb25bit: 'LineString25D', - 3 + wkb25bit: 'Polygon25D', - 4 + wkb25bit: 'MultiPoint25D', - 5 + wkb25bit: 'MultiLineString25D', - 6 + wkb25bit: 'MultiPolygon25D', - 7 + wkb25bit: 'GeometryCollection25D', - } + _types = { + 0: 'Unknown', + 1: 'Point', + 2: 'LineString', + 3: 'Polygon', + 4: 'MultiPoint', + 5: 'MultiLineString', + 6: 'MultiPolygon', + 7: 'GeometryCollection', + 100: 'None', + 101: 'LinearRing', + 102: 'PointZ', + 1 + wkb25bit: 'Point25D', + 2 + wkb25bit: 'LineString25D', + 3 + wkb25bit: 'Polygon25D', + 4 + wkb25bit: 'MultiPoint25D', + 5 + wkb25bit: 'MultiLineString25D', + 6 + wkb25bit: 'MultiPolygon25D', + 7 + wkb25bit: 'GeometryCollection25D', + } # Reverse type dictionary, keyed by lowercase of the name. _str_types = {v.lower(): k for k, v in _types.items()} diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py index 1faef51b8b..91537ba3ac 100644 --- a/django/contrib/gis/utils/layermapping.py +++ b/django/contrib/gis/utils/layermapping.py @@ -48,14 +48,14 @@ class LayerMapping: "A class that maps OGR Layers to GeoDjango Models." # Acceptable 'base' types for a multi-geometry type. - MULTI_TYPES = {1: OGRGeomType('MultiPoint'), - 2: OGRGeomType('MultiLineString'), - 3: OGRGeomType('MultiPolygon'), - OGRGeomType('Point25D').num: OGRGeomType('MultiPoint25D'), - OGRGeomType('LineString25D').num: OGRGeomType('MultiLineString25D'), - OGRGeomType('Polygon25D').num: OGRGeomType('MultiPolygon25D'), - } - + MULTI_TYPES = { + 1: OGRGeomType('MultiPoint'), + 2: OGRGeomType('MultiLineString'), + 3: OGRGeomType('MultiPolygon'), + OGRGeomType('Point25D').num: OGRGeomType('MultiPoint25D'), + OGRGeomType('LineString25D').num: OGRGeomType('MultiLineString25D'), + OGRGeomType('Polygon25D').num: OGRGeomType('MultiPolygon25D'), + } # Acceptable Django field types and corresponding acceptable OGR # counterparts. FIELD_TYPES = { diff --git a/django/contrib/gis/utils/srs.py b/django/contrib/gis/utils/srs.py index 4171a37ca4..b10cf263b3 100644 --- a/django/contrib/gis/utils/srs.py +++ b/django/contrib/gis/utils/srs.py @@ -53,12 +53,12 @@ def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None, # Initializing the keyword arguments dictionary for both PostGIS # and SpatiaLite. - kwargs = {'srid': srs.srid, - 'auth_name': auth_name, - 'auth_srid': auth_srid or srs.srid, - 'proj4text': srs.proj4, - } - + kwargs = { + 'srid': srs.srid, + 'auth_name': auth_name, + 'auth_srid': auth_srid or srs.srid, + 'proj4text': srs.proj4, + } # Backend-specific fields for the SpatialRefSys model. srs_field_names = {f.name for f in SpatialRefSys._meta.get_fields()} if 'srtext' in srs_field_names: diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 298fec193d..d0a1324c79 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -854,9 +854,11 @@ class Field(RegisterLookupMixin): def formfield(self, form_class=None, choices_form_class=None, **kwargs): """Return a django.forms.Field instance for this field.""" - defaults = {'required': not self.blank, - 'label': capfirst(self.verbose_name), - 'help_text': self.help_text} + defaults = { + 'required': not self.blank, + 'label': capfirst(self.verbose_name), + 'help_text': self.help_text, + } if self.has_default(): if callable(self.default): defaults['initial'] = self.default diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 1b95bfa4c5..ed93fa852e 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -427,11 +427,17 @@ def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False, # limit is simply max_num + DEFAULT_MAX_NUM (which is 2*DEFAULT_MAX_NUM # if max_num is None in the first place) absolute_max = max_num + DEFAULT_MAX_NUM - attrs = {'form': form, 'extra': extra, - 'can_order': can_order, 'can_delete': can_delete, - 'min_num': min_num, 'max_num': max_num, - 'absolute_max': absolute_max, 'validate_min': validate_min, - 'validate_max': validate_max} + attrs = { + 'form': form, + 'extra': extra, + 'can_order': can_order, + 'can_delete': can_delete, + 'min_num': min_num, + 'max_num': max_num, + 'absolute_max': absolute_max, + 'validate_min': validate_min, + 'validate_max': validate_max, + } return type(form.__name__ + 'FormSet', (formset,), attrs) diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index f9ea6cf535..c4a37c25dd 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -399,15 +399,16 @@ class SpacelessNode(Node): class TemplateTagNode(Node): - mapping = {'openblock': BLOCK_TAG_START, - 'closeblock': BLOCK_TAG_END, - 'openvariable': VARIABLE_TAG_START, - 'closevariable': VARIABLE_TAG_END, - 'openbrace': SINGLE_BRACE_START, - 'closebrace': SINGLE_BRACE_END, - 'opencomment': COMMENT_TAG_START, - 'closecomment': COMMENT_TAG_END, - } + mapping = { + 'openblock': BLOCK_TAG_START, + 'closeblock': BLOCK_TAG_END, + 'openvariable': VARIABLE_TAG_START, + 'closevariable': VARIABLE_TAG_END, + 'openbrace': SINGLE_BRACE_START, + 'closebrace': SINGLE_BRACE_END, + 'opencomment': COMMENT_TAG_START, + 'closecomment': COMMENT_TAG_END, + } def __init__(self, tagtype): self.tagtype = tagtype diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py index 5aba705f5b..f08e89b25c 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -198,8 +198,10 @@ class RssFeed(SyndicationFeed): handler.endElement("rss") def rss_attributes(self): - return {"version": self._version, - "xmlns:atom": "http://www.w3.org/2005/Atom"} + return { + 'version': self._version, + 'xmlns:atom': 'http://www.w3.org/2005/Atom', + } def write_items(self, handler): for item in self.items: diff --git a/tests/admin_filters/tests.py b/tests/admin_filters/tests.py index 01e1076141..4ff7d012e5 100644 --- a/tests/admin_filters/tests.py +++ b/tests/admin_filters/tests.py @@ -322,8 +322,10 @@ class ListFiltersTests(TestCase): request.user = self.alfred changelist = modeladmin.get_changelist(request) - request = self.request_factory.get('/', {'date_registered__gte': self.today, - 'date_registered__lt': self.tomorrow}) + request = self.request_factory.get('/', { + 'date_registered__gte': self.today, + 'date_registered__lt': self.tomorrow}, + ) request.user = self.alfred changelist = modeladmin.get_changelist_instance(request) @@ -344,8 +346,10 @@ class ListFiltersTests(TestCase): ) ) - request = self.request_factory.get('/', {'date_registered__gte': self.today.replace(day=1), - 'date_registered__lt': self.next_month}) + request = self.request_factory.get('/', { + 'date_registered__gte': self.today.replace(day=1), + 'date_registered__lt': self.next_month}, + ) request.user = self.alfred changelist = modeladmin.get_changelist_instance(request) @@ -370,8 +374,10 @@ class ListFiltersTests(TestCase): ) ) - request = self.request_factory.get('/', {'date_registered__gte': self.today.replace(month=1, day=1), - 'date_registered__lt': self.next_year}) + request = self.request_factory.get('/', { + 'date_registered__gte': self.today.replace(month=1, day=1), + 'date_registered__lt': self.next_year}, + ) request.user = self.alfred changelist = modeladmin.get_changelist_instance(request) diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index 5c4151c270..d09e7fa084 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -730,16 +730,20 @@ class RelatedPrepopulatedInline1(admin.StackedInline): model = RelatedPrepopulated extra = 1 autocomplete_fields = ['fk', 'm2m'] - prepopulated_fields = {'slug1': ['name', 'pubdate'], - 'slug2': ['status', 'name']} + prepopulated_fields = { + 'slug1': ['name', 'pubdate'], + 'slug2': ['status', 'name'], + } class RelatedPrepopulatedInline2(admin.TabularInline): model = RelatedPrepopulated extra = 1 autocomplete_fields = ['fk', 'm2m'] - prepopulated_fields = {'slug1': ['name', 'pubdate'], - 'slug2': ['status', 'name']} + prepopulated_fields = { + 'slug1': ['name', 'pubdate'], + 'slug2': ['status', 'name'], + } class RelatedPrepopulatedInline3(admin.TabularInline): diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index d4bd873d2a..93a93454d9 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1650,11 +1650,12 @@ class AdminViewPermissionsTest(TestCase): def test_add_view(self): """Test add view restricts access and actually adds items.""" - add_dict = {'title': 'Døm ikke', - 'content': '
great article
', - 'date_0': '2008-03-18', 'date_1': '10:54:39', - 'section': self.s1.pk} - + add_dict = { + 'title': 'Døm ikke', + 'content': 'great article
', + 'date_0': '2008-03-18', 'date_1': '10:54:39', + 'section': self.s1.pk, + } # Change User should not have access to add articles self.client.force_login(self.changeuser) # make sure the view removes test cookie @@ -1754,10 +1755,12 @@ class AdminViewPermissionsTest(TestCase): def test_change_view(self): """Change view should restrict access and allow users to edit items.""" - change_dict = {'title': 'Ikke fordømt', - 'content': 'edited article
', - 'date_0': '2008-03-18', 'date_1': '10:54:39', - 'section': self.s1.pk} + change_dict = { + 'title': 'Ikke fordømt', + 'content': 'edited article
', + 'date_0': '2008-03-18', 'date_1': '10:54:39', + 'section': self.s1.pk, + } article_change_url = reverse('admin:admin_views_article_change', args=(self.a1.pk,)) article_changelist_url = reverse('admin:admin_views_article_changelist') @@ -6023,15 +6026,16 @@ class AdminViewOnSiteTests(TestCase): # The form validation should fail because 'some_required_info' is # not included on the parent form, and the family_name of the parent # does not match that of the child - post_data = {"family_name": "Test1", - "dependentchild_set-TOTAL_FORMS": "1", - "dependentchild_set-INITIAL_FORMS": "0", - "dependentchild_set-MAX_NUM_FORMS": "1", - "dependentchild_set-0-id": "", - "dependentchild_set-0-parent": "", - "dependentchild_set-0-family_name": "Test2"} - response = self.client.post(reverse('admin:admin_views_parentwithdependentchildren_add'), - post_data) + post_data = { + 'family_name': 'Test1', + 'dependentchild_set-TOTAL_FORMS': '1', + 'dependentchild_set-INITIAL_FORMS': '0', + 'dependentchild_set-MAX_NUM_FORMS': '1', + 'dependentchild_set-0-id': '', + 'dependentchild_set-0-parent': '', + 'dependentchild_set-0-family_name': 'Test2', + } + response = self.client.post(reverse('admin:admin_views_parentwithdependentchildren_add'), post_data) self.assertFormError(response, 'adminform', 'some_required_info', ['This field is required.']) msg = "The form 'adminform' in context 0 does not contain the non-field error 'Error'" with self.assertRaisesMessage(AssertionError, msg): @@ -6050,18 +6054,19 @@ class AdminViewOnSiteTests(TestCase): Verifying that if the parent form fails validation, the inlines also run validation even if validation is contingent on parent form data """ - pwdc = ParentWithDependentChildren.objects.create(some_required_info=6, - family_name="Test1") + pwdc = ParentWithDependentChildren.objects.create(some_required_info=6, family_name='Test1') # The form validation should fail because 'some_required_info' is # not included on the parent form, and the family_name of the parent # does not match that of the child - post_data = {"family_name": "Test2", - "dependentchild_set-TOTAL_FORMS": "1", - "dependentchild_set-INITIAL_FORMS": "0", - "dependentchild_set-MAX_NUM_FORMS": "1", - "dependentchild_set-0-id": "", - "dependentchild_set-0-parent": str(pwdc.id), - "dependentchild_set-0-family_name": "Test1"} + post_data = { + 'family_name': 'Test2', + 'dependentchild_set-TOTAL_FORMS': '1', + 'dependentchild_set-INITIAL_FORMS': '0', + 'dependentchild_set-MAX_NUM_FORMS': '1', + 'dependentchild_set-0-id': '', + 'dependentchild_set-0-parent': str(pwdc.id), + 'dependentchild_set-0-family_name': 'Test1', + } response = self.client.post( reverse('admin:admin_views_parentwithdependentchildren_change', args=(pwdc.id,)), post_data ) diff --git a/tests/fixtures/tests.py b/tests/fixtures/tests.py index 37b21fa296..059b0ed80a 100644 --- a/tests/fixtures/tests.py +++ b/tests/fixtures/tests.py @@ -53,15 +53,19 @@ class DumpDataAssertMixin: use_base_manager=False, exclude_list=[], primary_keys=''): new_io = StringIO() filename = filename and os.path.join(tempfile.gettempdir(), filename) - management.call_command('dumpdata', *args, **{'format': format, - 'stdout': new_io, - 'stderr': new_io, - 'output': filename, - 'use_natural_foreign_keys': natural_foreign_keys, - 'use_natural_primary_keys': natural_primary_keys, - 'use_base_manager': use_base_manager, - 'exclude': exclude_list, - 'primary_keys': primary_keys}) + management.call_command( + 'dumpdata', + *args, + format=format, + stdout=new_io, + stderr=new_io, + output=filename, + use_natural_foreign_keys=natural_foreign_keys, + use_natural_primary_keys=natural_primary_keys, + use_base_manager=use_base_manager, + exclude=exclude_list, + primary_keys=primary_keys, + ) if filename: with open(filename, "r") as f: command_output = f.read() diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index bad24b5230..d4e421d6ac 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -2872,8 +2872,14 @@ Good luck picking a username that doesn't already exist. self.assertEqual(form.errors, {'name': ['bad value not allowed']}) form = NameForm(data={'name': ['should be overly', 'long for the field names']}) self.assertFalse(form.is_valid()) - self.assertEqual(form.errors, {'name': ['Ensure this value has at most 10 characters (it has 16).', - 'Ensure this value has at most 10 characters (it has 24).']}) + self.assertEqual( + form.errors, { + 'name': [ + 'Ensure this value has at most 10 characters (it has 16).', + 'Ensure this value has at most 10 characters (it has 24).', + ], + } + ) form = NameForm(data={'name': ['fname', 'lname']}) self.assertTrue(form.is_valid()) self.assertEqual(form.cleaned_data, {'name': 'fname lname'}) diff --git a/tests/gis_tests/geoapp/sitemaps.py b/tests/gis_tests/geoapp/sitemaps.py index 1a3101290a..91e5d82bb4 100644 --- a/tests/gis_tests/geoapp/sitemaps.py +++ b/tests/gis_tests/geoapp/sitemaps.py @@ -2,6 +2,7 @@ from django.contrib.gis.sitemaps import KMLSitemap, KMZSitemap from .models import City, Country -sitemaps = {'kml': KMLSitemap([City, Country]), - 'kmz': KMZSitemap([City, Country]), - } +sitemaps = { + 'kml': KMLSitemap([City, Country]), + 'kmz': KMZSitemap([City, Country]), +} diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index 4b09cebb3e..e7eec26dd6 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -365,15 +365,17 @@ class GISFunctionsTests(FuncTestMixin, TestCase): if oracle: # SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_GEOM.SDO_POINTONSURFACE(GEOAPP_COUNTRY.MPOLY, 0.05)) # FROM GEOAPP_COUNTRY; - ref = {'New Zealand': fromstr('POINT (174.616364 -36.100861)', srid=4326), - 'Texas': fromstr('POINT (-103.002434 36.500397)', srid=4326), - } + ref = { + 'New Zealand': fromstr('POINT (174.616364 -36.100861)', srid=4326), + 'Texas': fromstr('POINT (-103.002434 36.500397)', srid=4326), + } else: # Using GEOSGeometry to compute the reference point on surface values # -- since PostGIS also uses GEOS these should be the same. - ref = {'New Zealand': Country.objects.get(name='New Zealand').mpoly.point_on_surface, - 'Texas': Country.objects.get(name='Texas').mpoly.point_on_surface - } + ref = { + 'New Zealand': Country.objects.get(name='New Zealand').mpoly.point_on_surface, + 'Texas': Country.objects.get(name='Texas').mpoly.point_on_surface + } qs = Country.objects.annotate(point_on_surface=functions.PointOnSurface('mpoly')) for country in qs: diff --git a/tests/gis_tests/geogapp/tests.py b/tests/gis_tests/geogapp/tests.py index 7f6c441ba5..9cf8ab92f7 100644 --- a/tests/gis_tests/geogapp/tests.py +++ b/tests/gis_tests/geogapp/tests.py @@ -66,11 +66,11 @@ class GeographyTest(TestCase): # Getting the shapefile and mapping dictionary. shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data')) co_shp = os.path.join(shp_path, 'counties', 'counties.shp') - co_mapping = {'name': 'Name', - 'state': 'State', - 'mpoly': 'MULTIPOLYGON', - } - + co_mapping = { + 'name': 'Name', + 'state': 'State', + 'mpoly': 'MULTIPOLYGON', + } # Reference county names, number of polygons, and state names. names = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo'] num_polys = [1, 2, 1, 19, 1] # Number of polygons for each. diff --git a/tests/gis_tests/layermap/models.py b/tests/gis_tests/layermap/models.py index de1dd6c944..7c029a0ee8 100644 --- a/tests/gis_tests/layermap/models.py +++ b/tests/gis_tests/layermap/models.py @@ -77,18 +77,21 @@ co_mapping = { 'mpoly': 'MULTIPOLYGON', # Will convert POLYGON features into MULTIPOLYGONS. } -cofeat_mapping = {'name': 'Name', - 'poly': 'POLYGON', - } +cofeat_mapping = { + 'name': 'Name', + 'poly': 'POLYGON', +} -city_mapping = {'name': 'Name', - 'population': 'Population', - 'density': 'Density', - 'dt': 'Created', - 'point': 'POINT', - } +city_mapping = { + 'name': 'Name', + 'population': 'Population', + 'density': 'Density', + 'dt': 'Created', + 'point': 'POINT', +} -inter_mapping = {'name': 'Name', - 'length': 'Length', - 'path': 'LINESTRING', - } +inter_mapping = { + 'name': 'Name', + 'length': 'Length', + 'path': 'LINESTRING', +} diff --git a/tests/gis_tests/layermap/tests.py b/tests/gis_tests/layermap/tests.py index a1b288eafa..460d6f6a4d 100644 --- a/tests/gis_tests/layermap/tests.py +++ b/tests/gis_tests/layermap/tests.py @@ -261,13 +261,13 @@ class LayerMapTest(TestCase): def test_model_inheritance(self): "Tests LayerMapping on inherited models. See #12093." - icity_mapping = {'name': 'Name', - 'population': 'Population', - 'density': 'Density', - 'point': 'POINT', - 'dt': 'Created', - } - + icity_mapping = { + 'name': 'Name', + 'population': 'Population', + 'density': 'Density', + 'point': 'POINT', + 'dt': 'Created', + } # Parent model has geometry field. lm1 = LayerMapping(ICity1, city_shp, icity_mapping) lm1.save() diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py index c61720d12b..a616ee0f98 100644 --- a/tests/introspection/tests.py +++ b/tests/introspection/tests.py @@ -163,10 +163,10 @@ class IntrospectionTests(TransactionTestCase): def test_get_key_columns(self): with connection.cursor() as cursor: key_columns = connection.introspection.get_key_columns(cursor, Article._meta.db_table) - self.assertEqual( - set(key_columns), - {('reporter_id', Reporter._meta.db_table, 'id'), - ('response_to_id', Article._meta.db_table, 'id')}) + self.assertEqual(set(key_columns), { + ('reporter_id', Reporter._meta.db_table, 'id'), + ('response_to_id', Article._meta.db_table, 'id'), + }) def test_get_primary_key_column(self): with connection.cursor() as cursor: diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py index 37010ab7d0..3ab905eab6 100644 --- a/tests/logging_tests/tests.py +++ b/tests/logging_tests/tests.py @@ -537,9 +537,10 @@ format=%(message)s self.temp_file = NamedTemporaryFile() self.temp_file.write(logging_conf.encode()) self.temp_file.flush() - sdict = {'LOGGING_CONFIG': '"logging.config.fileConfig"', - 'LOGGING': 'r"%s"' % self.temp_file.name} - self.write_settings('settings.py', sdict=sdict) + self.write_settings('settings.py', sdict={ + 'LOGGING_CONFIG': '"logging.config.fileConfig"', + 'LOGGING': 'r"%s"' % self.temp_file.name, + }) def tearDown(self): self.temp_file.close() diff --git a/tests/mail/tests.py b/tests/mail/tests.py index f0f91e7b40..f06e053074 100644 --- a/tests/mail/tests.py +++ b/tests/mail/tests.py @@ -323,9 +323,13 @@ class MailTests(HeadersCheckMixin, SimpleTestCase): ) def test_unicode_headers(self): - email = EmailMessage("Gżegżółka", "Content", "from@example.com", ["to@example.com"], - headers={"Sender": '"Firstname Sürname"