From 83b9bfea44e23c5770fa14a8921914839929233b Mon Sep 17 00:00:00 2001 From: Larry O'Neill Date: Mon, 14 Oct 2013 20:13:14 +0100 Subject: [PATCH] Fixed #21266 -- Fixed E201,E202 pep8 warnings. --- django/contrib/admin/validation.py | 2 +- django/contrib/comments/moderation.py | 4 +- .../gis/db/backends/postgis/introspection.py | 2 +- django/contrib/gis/db/models/sql/compiler.py | 4 +- django/contrib/gis/db/models/sql/where.py | 4 +- django/contrib/gis/gdal/error.py | 19 +++--- django/contrib/gis/gdal/field.py | 27 ++++---- django/contrib/gis/gdal/geometries.py | 4 +- django/contrib/gis/gdal/tests/test_geom.py | 2 +- django/contrib/gis/geoip/prototypes.py | 7 +- django/contrib/gis/geos/mutable_list.py | 4 +- .../gis/geos/tests/test_mutable_list.py | 6 +- django/contrib/gis/maps/google/zoom.py | 2 +- django/contrib/gis/tests/distapp/tests.py | 2 +- django/contrib/gis/tests/geo3d/tests.py | 2 +- django/contrib/gis/tests/geoapp/tests.py | 16 +++-- django/core/context_processors.py | 2 +- django/dispatch/saferef.py | 24 +++---- django/template/debug.py | 2 +- django/test/_doctest.py | 6 +- django/utils/termcolors.py | 68 +++++++++---------- django/views/debug.py | 4 +- setup.cfg | 2 +- tests/admin_custom_urls/tests.py | 6 +- tests/admin_widgets/tests.py | 4 +- tests/cache/tests.py | 2 +- tests/defaultfilters/tests.py | 4 +- tests/forms_tests/tests/test_fields.py | 4 +- tests/forms_tests/tests/test_formsets.py | 2 +- tests/i18n/tests.py | 4 +- tests/model_forms/tests.py | 2 +- tests/template_tests/filters.py | 22 +++--- tests/template_tests/tests.py | 26 +++---- tests/utils_tests/test_http.py | 2 +- tests/utils_tests/test_text.py | 4 +- 35 files changed, 152 insertions(+), 145 deletions(-) diff --git a/django/contrib/admin/validation.py b/django/contrib/admin/validation.py index e4a12211b52..84f8b67e4db 100644 --- a/django/contrib/admin/validation.py +++ b/django/contrib/admin/validation.py @@ -403,7 +403,7 @@ class InlineValidator(BaseValidator): def check_type(cls, attr, type_): if getattr(cls, attr, None) is not None and not isinstance(getattr(cls, attr), type_): raise ImproperlyConfigured("'%s.%s' should be a %s." - % (cls.__name__, attr, type_.__name__ )) + % (cls.__name__, attr, type_.__name__)) def check_isseq(cls, label, obj): if not isinstance(obj, (list, tuple)): diff --git a/django/contrib/comments/moderation.py b/django/contrib/comments/moderation.py index cdf00a9a24d..03c3583e68b 100644 --- a/django/contrib/comments/moderation.py +++ b/django/contrib/comments/moderation.py @@ -238,8 +238,8 @@ class CommentModerator(object): return recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS] t = loader.get_template('comments/comment_notification_email.txt') - c = Context({ 'comment': comment, - 'content_object': content_object }) + c = Context({'comment': comment, + 'content_object': content_object}) subject = '[%s] New comment posted on "%s"' % (get_current_site(request).name, content_object) message = t.render(c) diff --git a/django/contrib/gis/db/backends/postgis/introspection.py b/django/contrib/gis/db/backends/postgis/introspection.py index 7df09d09371..0b179934b6f 100644 --- a/django/contrib/gis/db/backends/postgis/introspection.py +++ b/django/contrib/gis/db/backends/postgis/introspection.py @@ -32,7 +32,7 @@ class PostGISIntrospection(DatabaseIntrospection): try: cursor.execute(oid_sql, ('geometry',)) GEOM_TYPE = cursor.fetchone()[0] - postgis_types = { GEOM_TYPE : 'GeometryField' } + postgis_types = {GEOM_TYPE : 'GeometryField'} if self.connection.ops.geography: cursor.execute(oid_sql, ('geography',)) GEOG_TYPE = cursor.fetchone()[0] diff --git a/django/contrib/gis/db/models/sql/compiler.py b/django/contrib/gis/db/models/sql/compiler.py index 94ce30ba5da..31249d0a00d 100644 --- a/django/contrib/gis/db/models/sql/compiler.py +++ b/django/contrib/gis/db/models/sql/compiler.py @@ -226,8 +226,8 @@ class GeoSQLCompiler(compiler.SQLCompiler): # transformed geometries have an SRID different than that of the # field -- this is only used by `transform` for Oracle and # SpatiaLite backends. - if self.query.transformed_srid and ( self.connection.ops.oracle or - self.connection.ops.spatialite ): + if self.query.transformed_srid and (self.connection.ops.oracle or + self.connection.ops.spatialite): sel_fmt = "'SRID=%d;'||%s" % (self.query.transformed_srid, sel_fmt) else: sel_fmt = '%s' diff --git a/django/contrib/gis/db/models/sql/where.py b/django/contrib/gis/db/models/sql/where.py index c29533bf840..b37cda21858 100644 --- a/django/contrib/gis/db/models/sql/where.py +++ b/django/contrib/gis/db/models/sql/where.py @@ -36,8 +36,8 @@ class GeoWhereNode(WhereNode): def _prepare_data(self, data): if isinstance(data, (list, tuple)): obj, lookup_type, value = data - if ( isinstance(obj, Constraint) and - isinstance(obj.field, GeometryField) ): + if (isinstance(obj, Constraint) and + isinstance(obj.field, GeometryField)): data = (GeoConstraint(obj), lookup_type, value) return super(GeoWhereNode, self)._prepare_data(data) diff --git a/django/contrib/gis/gdal/error.py b/django/contrib/gis/gdal/error.py index bd337adbb1c..b121258ac8c 100644 --- a/django/contrib/gis/gdal/error.py +++ b/django/contrib/gis/gdal/error.py @@ -19,15 +19,16 @@ class OGRIndexError(OGRException, KeyError): #### OGR error checking codes and routine #### # OGR Error Codes -OGRERR_DICT = { 1 : (OGRException, 'Not enough data.'), - 2 : (OGRException, 'Not enough memory.'), - 3 : (OGRException, 'Unsupported geometry type.'), - 4 : (OGRException, 'Unsupported operation.'), - 5 : (OGRException, 'Corrupt data.'), - 6 : (OGRException, 'OGR failure.'), - 7 : (SRSException, 'Unsupported SRS.'), - 8 : (OGRException, 'Invalid handle.'), - } +OGRERR_DICT = { + 1: (OGRException, 'Not enough data.'), + 2: (OGRException, 'Not enough memory.'), + 3: (OGRException, 'Unsupported geometry type.'), + 4: (OGRException, 'Unsupported operation.'), + 5: (OGRException, 'Corrupt data.'), + 6: (OGRException, 'OGR failure.'), + 7: (SRSException, 'Unsupported SRS.'), + 8: (OGRException, 'Invalid handle.'), +} OGRERR_NONE = 0 def check_err(code): diff --git a/django/contrib/gis/gdal/field.py b/django/contrib/gis/gdal/field.py index 39f5fd59bff..287942e5959 100644 --- a/django/contrib/gis/gdal/field.py +++ b/django/contrib/gis/gdal/field.py @@ -178,17 +178,18 @@ class OFTStringList(Field): pass class OFTWideStringList(Field): pass # Class mapping dictionary for OFT Types and reverse mapping. -OGRFieldTypes = { 0 : OFTInteger, - 1 : OFTIntegerList, - 2 : OFTReal, - 3 : OFTRealList, - 4 : OFTString, - 5 : OFTStringList, - 6 : OFTWideString, - 7 : OFTWideStringList, - 8 : OFTBinary, - 9 : OFTDate, - 10 : OFTTime, - 11 : OFTDateTime, - } +OGRFieldTypes = { + 0: OFTInteger, + 1: OFTIntegerList, + 2: OFTReal, + 3: OFTRealList, + 4: OFTString, + 5: OFTStringList, + 6: OFTWideString, + 7: OFTWideStringList, + 8: OFTBinary, + 9: OFTDate, + 10: OFTTime, + 11: OFTDateTime, +} ROGRFieldTypes = dict((cls, num) for num, cls in OGRFieldTypes.items()) diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py index a168c796861..2b051cdca8c 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -151,8 +151,8 @@ class OGRGeometry(GDALBase): def from_bbox(cls, bbox): "Constructs a Polygon from a bounding box (4-tuple)." x0, y0, x1, y1 = bbox - return OGRGeometry( 'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % ( - x0, y0, x0, y1, x1, y1, x1, y0, x0, y0) ) + return OGRGeometry('POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % ( + x0, y0, x0, y1, x1, y1, x1, y0, x0, y0)) ### Geometry set-like operations ### # g = g1 | g2 diff --git a/django/contrib/gis/gdal/tests/test_geom.py b/django/contrib/gis/gdal/tests/test_geom.py index 65207bf0c8f..f041e8cc587 100644 --- a/django/contrib/gis/gdal/tests/test_geom.py +++ b/django/contrib/gis/gdal/tests/test_geom.py @@ -205,7 +205,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin): # Testing `from_bbox` class method bbox = (-180, -90, 180, 90) - p = OGRGeometry.from_bbox( bbox ) + p = OGRGeometry.from_bbox(bbox) self.assertEqual(bbox, p.extent) prev = OGRGeometry('POINT(0 0)') diff --git a/django/contrib/gis/geoip/prototypes.py b/django/contrib/gis/geoip/prototypes.py index c13dd8aba2e..fd7c8024265 100644 --- a/django/contrib/gis/geoip/prototypes.py +++ b/django/contrib/gis/geoip/prototypes.py @@ -22,9 +22,10 @@ class GeoIPRecord(Structure): ('continent_code', c_char_p), ] geoip_char_fields = [name for name, ctype in GeoIPRecord._fields_ if ctype is c_char_p] -geoip_encodings = { 0: 'iso-8859-1', - 1: 'utf8', - } +geoip_encodings = { + 0: 'iso-8859-1', + 1: 'utf8', +} class GeoIPTag(Structure): pass diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py index 0418282bfe9..7184f78f842 100644 --- a/django/contrib/gis/geos/mutable_list.py +++ b/django/contrib/gis/geos/mutable_list.py @@ -96,9 +96,9 @@ class ListMixin(object): indexRange = range(*index.indices(origLen)) newLen = origLen - len(indexRange) - newItems = ( self._get_single_internal(i) + newItems = (self._get_single_internal(i) for i in xrange(origLen) - if i not in indexRange ) + if i not in indexRange) self._rebuild(newLen, newItems) diff --git a/django/contrib/gis/geos/tests/test_mutable_list.py b/django/contrib/gis/geos/tests/test_mutable_list.py index 4507be53741..1a3bc16d302 100644 --- a/django/contrib/gis/geos/tests/test_mutable_list.py +++ b/django/contrib/gis/geos/tests/test_mutable_list.py @@ -116,7 +116,7 @@ class ListMixinTest(unittest.TestCase): self.assertEqual(pl, ul[:], 'set slice [%d:%d]' % (i, j)) for k in self.step_range(): - ssl = nextRange( len(ul[i:j:k]) ) + ssl = nextRange(len(ul[i:j:k])) ul[i:j:k] = ssl pl[i:j:k] = ssl self.assertEqual(pl, ul[:], 'set slice [%d:%d:%d]' % (i, j, k)) @@ -127,12 +127,12 @@ class ListMixinTest(unittest.TestCase): self.assertRaises(ValueError, setfcn, ul, i, j, k, sliceLen - 1) for k in self.step_range(): - ssl = nextRange( len(ul[i::k]) ) + ssl = nextRange(len(ul[i::k])) ul[i::k] = ssl pl[i::k] = ssl self.assertEqual(pl, ul[:], 'set slice [%d::%d]' % (i, k)) - ssl = nextRange( len(ul[:i:k]) ) + ssl = nextRange(len(ul[:i:k])) ul[:i:k] = ssl pl[:i:k] = ssl self.assertEqual(pl, ul[:], 'set slice [:%d:%d]' % (i, k)) diff --git a/django/contrib/gis/maps/google/zoom.py b/django/contrib/gis/maps/google/zoom.py index c93cf4ef486..af1dee14e60 100644 --- a/django/contrib/gis/maps/google/zoom.py +++ b/django/contrib/gis/maps/google/zoom.py @@ -95,7 +95,7 @@ class GoogleZoom(object): lon = (px[0] - npix) / self._degpp[zoom] # Calculating the latitude value. - lat = RTOD * ( 2 * atan(exp((px[1] - npix)/ (-1.0 * self._radpp[zoom]))) - 0.5 * pi) + lat = RTOD * (2 * atan(exp((px[1] - npix)/ (-1.0 * self._radpp[zoom]))) - 0.5 * pi) # Returning the longitude, latitude coordinate pair. return (lon, lat) diff --git a/django/contrib/gis/tests/distapp/tests.py b/django/contrib/gis/tests/distapp/tests.py index 67dbad0ecbf..e9298b97e15 100644 --- a/django/contrib/gis/tests/distapp/tests.py +++ b/django/contrib/gis/tests/distapp/tests.py @@ -140,7 +140,7 @@ class DistanceTest(TestCase): # Testing geodetic distance calculation with a non-point geometry # (a LineString of Wollongong and Shellharbour coords). - ls = LineString( ( (150.902, -34.4245), (150.87, -34.5789) ) ) + ls = LineString(((150.902, -34.4245), (150.87, -34.5789))) if oracle or connection.ops.geography: # Reference query: # SELECT ST_distance_sphere(point, ST_GeomFromText('LINESTRING(150.9020 -34.4245,150.8700 -34.5789)', 4326)) FROM distapp_australiacity ORDER BY name; diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py index 6fdf67042b1..3dc8451bac8 100644 --- a/django/contrib/gis/tests/geo3d/tests.py +++ b/django/contrib/gis/tests/geo3d/tests.py @@ -46,7 +46,7 @@ city_dict = dict((name, coords) for name, coords in city_data) interstate_data = ( ('I-45', 'LINESTRING(-95.3708481 29.7765870 11.339,-95.3694580 29.7787980 4.536,-95.3690305 29.7797359 9.762,-95.3691886 29.7812450 12.448,-95.3696447 29.7850144 10.457,-95.3702511 29.7868518 9.418,-95.3706724 29.7881286 14.858,-95.3711632 29.7896157 15.386,-95.3714525 29.7936267 13.168,-95.3717848 29.7955007 15.104,-95.3717719 29.7969804 16.516,-95.3717305 29.7982117 13.923,-95.3717254 29.8000778 14.385,-95.3719875 29.8013539 15.160,-95.3720575 29.8026785 15.544,-95.3721321 29.8040912 14.975,-95.3722074 29.8050998 15.688,-95.3722779 29.8060430 16.099,-95.3733818 29.8076750 15.197,-95.3741563 29.8103686 17.268,-95.3749458 29.8129927 19.857,-95.3763564 29.8144557 15.435)', - ( 11.339, 4.536, 9.762, 12.448, 10.457, 9.418, 14.858, + (11.339, 4.536, 9.762, 12.448, 10.457, 9.418, 14.858, 15.386, 13.168, 15.104, 16.516, 13.923, 14.385, 15.16 , 15.544, 14.975, 15.688, 16.099, 15.197, 17.268, 19.857, 15.435), diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py index adb8426f677..2ef8a5349c9 100644 --- a/django/contrib/gis/tests/geoapp/tests.py +++ b/django/contrib/gis/tests/geoapp/tests.py @@ -459,12 +459,14 @@ class GeoQuerySetTest(TestCase): @no_spatialite def test_force_rhr(self): "Testing GeoQuerySet.force_rhr()." - rings = ( ( (0, 0), (5, 0), (0, 5), (0, 0) ), - ( (1, 1), (1, 3), (3, 1), (1, 1) ), - ) - rhr_rings = ( ( (0, 0), (0, 5), (5, 0), (0, 0) ), - ( (1, 1), (3, 1), (1, 3), (1, 1) ), - ) + rings = ( + ((0, 0), (5, 0), (0, 5), (0, 0)), + ((1, 1), (1, 3), (3, 1), (1, 1)), + ) + rhr_rings = ( + ((0, 0), (0, 5), (5, 0), (0, 0)), + ((1, 1), (3, 1), (1, 3), (1, 1)), + ) State.objects.create(name='Foo', poly=Polygon(*rings)) s = State.objects.force_rhr().get(name='Foo') self.assertEqual(rhr_rings, s.force_rhr.coords) @@ -648,7 +650,7 @@ class GeoQuerySetTest(TestCase): @no_spatialite def test_reverse_geom(self): "Testing GeoQuerySet.reverse_geom()." - coords = [ (-95.363151, 29.763374), (-95.448601, 29.713803) ] + coords = [(-95.363151, 29.763374), (-95.448601, 29.713803)] Track.objects.create(name='Foo', line=LineString(coords)) t = Track.objects.reverse_geom().get(name='Foo') coords.reverse() diff --git a/django/core/context_processors.py b/django/core/context_processors.py index ca1ac68f555..910ceb72d5d 100644 --- a/django/core/context_processors.py +++ b/django/core/context_processors.py @@ -31,7 +31,7 @@ def csrf(request): return smart_text(token) _get_val = lazy(_get_val, six.text_type) - return {'csrf_token': _get_val() } + return {'csrf_token': _get_val()} def debug(request): "Returns context variables helpful for debugging." diff --git a/django/dispatch/saferef.py b/django/dispatch/saferef.py index b816e711595..41756a1001e 100644 --- a/django/dispatch/saferef.py +++ b/django/dispatch/saferef.py @@ -32,7 +32,7 @@ def safeRef(target, onDelete = None): if callable(onDelete): return weakref.ref(target, onDelete) else: - return weakref.ref( target ) + return weakref.ref(target) class BoundMethodWeakref(object): """'Safe' and reusable weak references to instance methods @@ -70,7 +70,7 @@ class BoundMethodWeakref(object): _allInstances = weakref.WeakValueDictionary() - def __new__( cls, target, onDelete=None, *arguments,**named ): + def __new__(cls, target, onDelete=None, *arguments,**named): """Create new instance or return current instance Basically this method of construction allows us to @@ -85,12 +85,12 @@ class BoundMethodWeakref(object): key = cls.calculateKey(target) current =cls._allInstances.get(key) if current is not None: - current.deletionMethods.append( onDelete) + current.deletionMethods.append(onDelete) return current else: - base = super( BoundMethodWeakref, cls).__new__( cls ) + base = super(BoundMethodWeakref, cls).__new__(cls) cls._allInstances[key] = base - base.__init__( target, onDelete, *arguments,**named) + base.__init__(target, onDelete, *arguments,**named) return base def __init__(self, target, onDelete=None): @@ -112,13 +112,13 @@ class BoundMethodWeakref(object): methods = self.deletionMethods[:] del self.deletionMethods[:] try: - del self.__class__._allInstances[ self.key ] + del self.__class__._allInstances[self.key] except KeyError: pass for function in methods: try: - if callable( function ): - function( self ) + if callable(function): + function(self) except Exception as e: try: traceback.print_exc() @@ -127,20 +127,20 @@ class BoundMethodWeakref(object): self, function, e) ) self.deletionMethods = [onDelete] - self.key = self.calculateKey( target ) + self.key = self.calculateKey(target) self.weakSelf = weakref.ref(target.__self__, remove) self.weakFunc = weakref.ref(target.__func__, remove) self.selfName = str(target.__self__) self.funcName = str(target.__func__.__name__) - def calculateKey( cls, target ): + def calculateKey(cls, target): """Calculate the reference key for this reference Currently this is a two-tuple of the id()'s of the target object and the target function respectively. """ return (id(target.__self__),id(target.__func__)) - calculateKey = classmethod( calculateKey ) + calculateKey = classmethod(calculateKey) def __str__(self): """Give a friendly representation of the object""" @@ -155,7 +155,7 @@ class BoundMethodWeakref(object): def __hash__(self): return hash(self.key) - def __bool__( self ): + def __bool__(self): """Whether we are still a valid reference""" return self() is not None diff --git a/django/template/debug.py b/django/template/debug.py index 043dd91b4ed..94065512511 100644 --- a/django/template/debug.py +++ b/django/template/debug.py @@ -36,7 +36,7 @@ class DebugParser(Parser): self.command_stack = [] def enter_command(self, command, token): - self.command_stack.append( (command, token.source) ) + self.command_stack.append((command, token.source)) def exit_command(self): self.command_stack.pop() diff --git a/django/test/_doctest.py b/django/test/_doctest.py index 4f4837f3c68..2b90f1dc2e9 100644 --- a/django/test/_doctest.py +++ b/django/test/_doctest.py @@ -613,10 +613,10 @@ class DocTestParser: self._parse_example(m, name, lineno) # Create an Example, and add it to the list. if not self._IS_BLANK_OR_COMMENT(source): - output.append( Example(source, want, exc_msg, + output.append(Example(source, want, exc_msg, lineno=lineno, indent=min_indent+len(m.group('indent')), - options=options) ) + options=options)) # Update lineno (lines inside this example) lineno += string.count('\n', m.start(), m.end()) # Update charno. @@ -1498,7 +1498,7 @@ class DocTestRunner: if t == 0: notests.append(name) elif f == 0: - passed.append( (name, t) ) + passed.append((name, t)) else: failed.append(x) if verbose: diff --git a/django/utils/termcolors.py b/django/utils/termcolors.py index 8c66e338de9..2aabf089033 100644 --- a/django/utils/termcolors.py +++ b/django/utils/termcolors.py @@ -92,42 +92,42 @@ PALETTES = { 'MIGRATE_FAILURE': {}, }, DARK_PALETTE: { - 'ERROR': { 'fg': 'red', 'opts': ('bold',) }, - 'NOTICE': { 'fg': 'red' }, - 'SQL_FIELD': { 'fg': 'green', 'opts': ('bold',) }, - 'SQL_COLTYPE': { 'fg': 'green' }, - 'SQL_KEYWORD': { 'fg': 'yellow' }, - 'SQL_TABLE': { 'opts': ('bold',) }, - 'HTTP_INFO': { 'opts': ('bold',) }, - 'HTTP_SUCCESS': { }, - 'HTTP_REDIRECT': { 'fg': 'green' }, - 'HTTP_NOT_MODIFIED': { 'fg': 'cyan' }, - 'HTTP_BAD_REQUEST': { 'fg': 'red', 'opts': ('bold',) }, - 'HTTP_NOT_FOUND': { 'fg': 'yellow' }, - 'HTTP_SERVER_ERROR': { 'fg': 'magenta', 'opts': ('bold',) }, - 'MIGRATE_HEADING': { 'fg': 'cyan', 'opts': ('bold',) }, - 'MIGRATE_LABEL': { 'opts': ('bold',) }, - 'MIGRATE_SUCCESS': { 'fg': 'green', 'opts': ('bold',) }, - 'MIGRATE_FAILURE': { 'fg': 'red', 'opts': ('bold',) }, + 'ERROR': {'fg': 'red', 'opts': ('bold',)}, + 'NOTICE': {'fg': 'red'}, + 'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)}, + 'SQL_COLTYPE': {'fg': 'green'}, + 'SQL_KEYWORD': {'fg': 'yellow'}, + 'SQL_TABLE': {'opts': ('bold',)}, + 'HTTP_INFO': {'opts': ('bold',)}, + 'HTTP_SUCCESS': {}, + 'HTTP_REDIRECT': {'fg': 'green'}, + 'HTTP_NOT_MODIFIED': {'fg': 'cyan'}, + 'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)}, + 'HTTP_NOT_FOUND': {'fg': 'yellow'}, + 'HTTP_SERVER_ERROR': {'fg': 'magenta', 'opts': ('bold',)}, + 'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)}, + 'MIGRATE_LABEL': {'opts': ('bold',)}, + 'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)}, + 'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)}, }, LIGHT_PALETTE: { - 'ERROR': { 'fg': 'red', 'opts': ('bold',) }, - 'NOTICE': { 'fg': 'red' }, - 'SQL_FIELD': { 'fg': 'green', 'opts': ('bold',) }, - 'SQL_COLTYPE': { 'fg': 'green' }, - 'SQL_KEYWORD': { 'fg': 'blue' }, - 'SQL_TABLE': { 'opts': ('bold',) }, - 'HTTP_INFO': { 'opts': ('bold',) }, - 'HTTP_SUCCESS': { }, - 'HTTP_REDIRECT': { 'fg': 'green', 'opts': ('bold',) }, - 'HTTP_NOT_MODIFIED': { 'fg': 'green' }, - 'HTTP_BAD_REQUEST': { 'fg': 'red', 'opts': ('bold',) }, - 'HTTP_NOT_FOUND': { 'fg': 'red' }, - 'HTTP_SERVER_ERROR': { 'fg': 'magenta', 'opts': ('bold',) }, - 'MIGRATE_HEADING': { 'fg': 'cyan', 'opts': ('bold',) }, - 'MIGRATE_LABEL': { 'opts': ('bold',) }, - 'MIGRATE_SUCCESS': { 'fg': 'green', 'opts': ('bold',) }, - 'MIGRATE_FAILURE': { 'fg': 'red', 'opts': ('bold',) }, + 'ERROR': {'fg': 'red', 'opts': ('bold',)}, + 'NOTICE': {'fg': 'red'}, + 'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)}, + 'SQL_COLTYPE': {'fg': 'green'}, + 'SQL_KEYWORD': {'fg': 'blue'}, + 'SQL_TABLE': {'opts': ('bold',)}, + 'HTTP_INFO': {'opts': ('bold',)}, + 'HTTP_SUCCESS': {}, + 'HTTP_REDIRECT': {'fg': 'green', 'opts': ('bold',)}, + 'HTTP_NOT_MODIFIED': {'fg': 'green'}, + 'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)}, + 'HTTP_NOT_FOUND': {'fg': 'red'}, + 'HTTP_SERVER_ERROR': {'fg': 'magenta', 'opts': ('bold',)}, + 'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)}, + 'MIGRATE_LABEL': {'opts': ('bold',)}, + 'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)}, + 'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)}, } } DEFAULT_PALETTE = DARK_PALETTE diff --git a/django/views/debug.py b/django/views/debug.py index ffb343f12ba..71b35364047 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -343,7 +343,7 @@ class ExceptionReporter(object): before = escape(template_source[upto:start]) during = escape(template_source[start:end]) after = escape(template_source[end:next]) - source_lines.append( (num, escape(template_source[upto:next])) ) + source_lines.append((num, escape(template_source[upto:next]))) upto = next total = len(source_lines) @@ -450,7 +450,7 @@ class ExceptionReporter(object): """ import traceback frames = self.get_traceback_frames() - tb = [ (f['filename'], f['lineno'], f['function'], f['context_line']) for f in frames ] + tb = [(f['filename'], f['lineno'], f['function'], f['context_line']) for f in frames] list = ['Traceback (most recent call last):\n'] list += traceback.format_list(tb) list += traceback.format_exception_only(self.exc_type, self.exc_value) diff --git a/setup.cfg b/setup.cfg index 6f3ccc6e53b..1eebbb21c6e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh [flake8] exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py -ignore=E123,E124,E125,E126,E127,E128,E225,E226,E241,E251,E302,E501,E121,E122,E201,E202,E203,E221,E227,E231,E261,E301,E303,E502,E701,F401,F403,F841,W601 +ignore=E123,E124,E125,E126,E127,E128,E225,E226,E241,E251,E302,E501,E121,E122,E203,E221,E227,E231,E261,E301,E303,E502,E701,F401,F403,F841,W601 [metadata] license-file = LICENSE diff --git a/tests/admin_custom_urls/tests.py b/tests/admin_custom_urls/tests.py index 1dc9da7efdc..7b46f4848ae 100644 --- a/tests/admin_custom_urls/tests.py +++ b/tests/admin_custom_urls/tests.py @@ -101,7 +101,7 @@ class CustomRedirects(TestCase): new object. Refs 8001, 18310, 19505. """ - post_data = { 'name': 'John Doe', } + post_data = {'name': 'John Doe'} self.assertEqual(Person.objects.count(), 0) response = self.client.post( reverse('admin:admin_custom_urls_person_add'), post_data) @@ -120,7 +120,7 @@ class CustomRedirects(TestCase): Person.objects.create(name='John Doe') self.assertEqual(Person.objects.count(), 1) person = Person.objects.all()[0] - post_data = { 'name': 'Jack Doe', } + post_data = {'name': 'Jack Doe'} response = self.client.post( reverse('admin:admin_custom_urls_person_change', args=[person.pk]), post_data) self.assertRedirects( @@ -131,7 +131,7 @@ class CustomRedirects(TestCase): Ensures that the ModelAdmin.response_add()'s parameter `post_url_continue` controls the redirection after an object has been created. """ - post_data = { 'name': 'SuperFast', '_continue': '1' } + post_data = {'name': 'SuperFast', '_continue': '1'} self.assertEqual(Car.objects.count(), 0) response = self.client.post( reverse('admin:admin_custom_urls_car_add'), post_data) diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py index c75ffe5def0..3613fa2207f 100644 --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -367,7 +367,9 @@ class AdminFileWidgetTest(DjangoTestCase): w = widgets.AdminFileWidget() self.assertHTMLEqual( w.render('test', album.cover_art), - '

Currently: albums\hybrid_theory.jpg
Change:

' % { 'STORAGE_URL': default_storage.url('') }, + '

Currently: albums\hybrid_theory.jpg
Change:

' % { + 'STORAGE_URL': default_storage.url('') + }, ) self.assertHTMLEqual( diff --git a/tests/cache/tests.py b/tests/cache/tests.py index c04decbad8d..ee6df48b031 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -353,7 +353,7 @@ class BaseCacheTests(object): 'ascii': 'ascii_value', 'unicode_ascii': 'Iñtërnâtiônàlizætiøn1', 'Iñtërnâtiônàlizætiøn': 'Iñtërnâtiônàlizætiøn2', - 'ascii2': {'x' : 1 } + 'ascii2': {'x' : 1} } # Test `set` for (key, value) in stuff.items(): diff --git a/tests/defaultfilters/tests.py b/tests/defaultfilters/tests.py index adae44dad34..d51bebcd7d0 100644 --- a/tests/defaultfilters/tests.py +++ b/tests/defaultfilters/tests.py @@ -315,9 +315,9 @@ class DefaultFiltersTests(TestCase): # Check urlize handles brackets properly (#19070) self.assertEqual(urlize('[see www.example.com]'), - '[see www.example.com]' ) + '[see www.example.com]') self.assertEqual(urlize('see test[at[example.com'), - 'see test[at[example.com' ) + 'see test[at[example.com') self.assertEqual(urlize('[http://168.192.0.1](http://168.192.0.1)'), '[http://168.192.0.1](http://168.192.0.1)') diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py index b49d8f000f5..1ac2c62d667 100644 --- a/tests/forms_tests/tests/test_fields.py +++ b/tests/forms_tests/tests/test_fields.py @@ -978,7 +978,7 @@ class FieldsTests(SimpleTestCase): class HiddenNullBooleanForm(Form): hidden_nullbool1 = NullBooleanField(widget=HiddenInput, initial=True) hidden_nullbool2 = NullBooleanField(widget=HiddenInput, initial=False) - f = HiddenNullBooleanForm({ 'hidden_nullbool1': 'True', 'hidden_nullbool2': 'False' }) + f = HiddenNullBooleanForm({'hidden_nullbool1': 'True', 'hidden_nullbool2': 'False'}) self.assertEqual(None, f.full_clean()) self.assertEqual(True, f.cleaned_data['hidden_nullbool1']) self.assertEqual(False, f.cleaned_data['hidden_nullbool2']) @@ -991,7 +991,7 @@ class FieldsTests(SimpleTestCase): nullbool0 = NullBooleanField(widget=RadioSelect(choices=NULLBOOL_CHOICES)) nullbool1 = NullBooleanField(widget=RadioSelect(choices=NULLBOOL_CHOICES)) nullbool2 = NullBooleanField(widget=RadioSelect(choices=NULLBOOL_CHOICES)) - f = MySQLNullBooleanForm({ 'nullbool0': '1', 'nullbool1': '0', 'nullbool2': '' }) + f = MySQLNullBooleanForm({'nullbool0': '1', 'nullbool1': '0', 'nullbool2': ''}) self.assertEqual(None, f.full_clean()) self.assertEqual(True, f.cleaned_data['nullbool0']) self.assertEqual(False, f.cleaned_data['nullbool1']) diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py index 6eadf6028d9..e36d8c2b775 100644 --- a/tests/forms_tests/tests/test_formsets.py +++ b/tests/forms_tests/tests/test_formsets.py @@ -1205,7 +1205,7 @@ class TestEmptyFormSet(TestCase): """Test that an empty formset still calls clean()""" EmptyFsetWontValidateFormset = formset_factory(FavoriteDrinkForm, extra=0, formset=EmptyFsetWontValidate) formset = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS':'0', 'form-TOTAL_FORMS':'0'},prefix="form") - formset2 = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS':'0', 'form-TOTAL_FORMS':'1', 'form-0-name':'bah' },prefix="form") + formset2 = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS':'0', 'form-TOTAL_FORMS':'1', 'form-0-name':'bah'},prefix="form") self.assertFalse(formset.is_valid()) self.assertFalse(formset2.is_valid()) diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index dc6c2ea5b22..6d8910bf04b 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -755,7 +755,7 @@ class FormattingTests(TransRealMixin, TestCase): """ Tests the {% localize %} templatetag """ - context = Context({'value': 3.14 }) + context = Context({'value': 3.14}) template1 = Template("{% load l10n %}{% localize %}{{ value }}{% endlocalize %};{% localize on %}{{ value }}{% endlocalize %}") template2 = Template("{% load l10n %}{{ value }};{% localize off %}{{ value }};{% endlocalize %}{{ value }}") template3 = Template('{% load l10n %}{{ value }};{{ value|unlocalize }}') @@ -789,7 +789,7 @@ class FormattingTests(TransRealMixin, TestCase): 'cents_paid': decimal.Decimal('59.47'), 'products_delivered': 12000, }) - context = Context({'form': form }) + context = Context({'form': form}) self.assertTrue(form.is_valid()) self.assertHTMLEqual( diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 6e23a0b6768..8acc88b33fa 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -696,7 +696,7 @@ class UniqueTest(TestCase): def test_explicitpk_unspecified(self): """Test for primary_key being in the form and failing validation.""" - form = ExplicitPKForm({'key': '', 'desc': '' }) + form = ExplicitPKForm({'key': '', 'desc': ''}) self.assertFalse(form.is_valid()) def test_explicitpk_unique(self): diff --git a/tests/template_tests/filters.py b/tests/template_tests/filters.py index 87c64298354..3addec24a70 100644 --- a/tests/template_tests/filters.py +++ b/tests/template_tests/filters.py @@ -50,10 +50,10 @@ def get_filter_tests(): 'filter-timesince06' : ('{{ a|timesince:b }}', {'a':now_tz - timedelta(hours=8), 'b':now_tz}, '8\xa0hours'), # Regression for #7443 - 'filter-timesince07': ('{{ earlier|timesince }}', { 'earlier': now - timedelta(days=7) }, '1\xa0week'), - 'filter-timesince08': ('{{ earlier|timesince:now }}', { 'now': now, 'earlier': now - timedelta(days=7) }, '1\xa0week'), - 'filter-timesince09': ('{{ later|timesince }}', { 'later': now + timedelta(days=7) }, '0\xa0minutes'), - 'filter-timesince10': ('{{ later|timesince:now }}', { 'now': now, 'later': now + timedelta(days=7) }, '0\xa0minutes'), + 'filter-timesince07': ('{{ earlier|timesince }}', {'earlier': now - timedelta(days=7)}, '1\xa0week'), + 'filter-timesince08': ('{{ earlier|timesince:now }}', {'now': now, 'earlier': now - timedelta(days=7)}, '1\xa0week'), + 'filter-timesince09': ('{{ later|timesince }}', {'later': now + timedelta(days=7)}, '0\xa0minutes'), + 'filter-timesince10': ('{{ later|timesince:now }}', {'now': now, 'later': now + timedelta(days=7)}, '0\xa0minutes'), # Ensures that differing timezones are calculated correctly # Tests trying to compare a timezone-aware 'now' to now aren't supported on no-tz-support systems (e.g Windows). @@ -78,10 +78,10 @@ def get_filter_tests(): 'filter-timeuntil05' : ('{{ a|timeuntil:b }}', {'a':now - timedelta(days=2), 'b':now - timedelta(days=2, minutes=1)}, '1\xa0minute'), # Regression for #7443 - 'filter-timeuntil06': ('{{ earlier|timeuntil }}', { 'earlier': now - timedelta(days=7) }, '0\xa0minutes'), - 'filter-timeuntil07': ('{{ earlier|timeuntil:now }}', { 'now': now, 'earlier': now - timedelta(days=7) }, '0\xa0minutes'), - 'filter-timeuntil08': ('{{ later|timeuntil }}', { 'later': now + timedelta(days=7, hours=1) }, '1\xa0week'), - 'filter-timeuntil09': ('{{ later|timeuntil:now }}', { 'now': now, 'later': now + timedelta(days=7) }, '1\xa0week'), + 'filter-timeuntil06': ('{{ earlier|timeuntil }}', {'earlier': now - timedelta(days=7)}, '0\xa0minutes'), + 'filter-timeuntil07': ('{{ earlier|timeuntil:now }}', {'now': now, 'earlier': now - timedelta(days=7)}, '0\xa0minutes'), + 'filter-timeuntil08': ('{{ later|timeuntil }}', {'later': now + timedelta(days=7, hours=1)}, '1\xa0week'), + 'filter-timeuntil09': ('{{ later|timeuntil:now }}', {'now': now, 'later': now + timedelta(days=7)}, '1\xa0week'), # Ensures that differing timezones are calculated correctly # Tests trying to compare a timezone-aware 'now' to now aren't supported on no-tz-support systems (e.g Windows). @@ -267,8 +267,8 @@ def get_filter_tests(): 'filter-default_if_none01': ('{{ a|default:"x<" }}', {"a": None}, "x<"), 'filter-default_if_none02': ('{% autoescape off %}{{ a|default:"x<" }}{% endautoescape %}', {"a": None}, "x<"), - 'filter-phone2numeric01': ('{{ a|phone2numeric }} {{ b|phone2numeric }}', {"a": "<1-800-call-me>", "b": mark_safe("<1-800-call-me>") }, "<1-800-2255-63> <1-800-2255-63>"), - 'filter-phone2numeric02': ('{% autoescape off %}{{ a|phone2numeric }} {{ b|phone2numeric }}{% endautoescape %}', {"a": "<1-800-call-me>", "b": mark_safe("<1-800-call-me>") }, "<1-800-2255-63> <1-800-2255-63>"), + 'filter-phone2numeric01': ('{{ a|phone2numeric }} {{ b|phone2numeric }}', {"a": "<1-800-call-me>", "b": mark_safe("<1-800-call-me>")}, "<1-800-2255-63> <1-800-2255-63>"), + 'filter-phone2numeric02': ('{% autoescape off %}{{ a|phone2numeric }} {{ b|phone2numeric }}{% endautoescape %}', {"a": "<1-800-call-me>", "b": mark_safe("<1-800-call-me>")}, "<1-800-2255-63> <1-800-2255-63>"), 'filter-phone2numeric03': ('{{ a|phone2numeric }}', {"a": "How razorback-jumping frogs can level six piqued gymnasts!"}, "469 729672225-5867464 37647 226 53835 749 747833 49662787!"), # Ensure iriencode keeps safe strings: @@ -347,7 +347,7 @@ def get_filter_tests(): # Test that joining with unsafe joiners don't result in unsafe strings (#11377) 'join05': (r'{{ a|join:var }}', {'a': ['alpha', 'beta & me'], 'var': ' & '}, 'alpha & beta & me'), 'join06': (r'{{ a|join:var }}', {'a': ['alpha', 'beta & me'], 'var': mark_safe(' & ')}, 'alpha & beta & me'), - 'join07': (r'{{ a|join:var|lower }}', {'a': ['Alpha', 'Beta & me'], 'var': ' & ' }, 'alpha & beta & me'), + 'join07': (r'{{ a|join:var|lower }}', {'a': ['Alpha', 'Beta & me'], 'var': ' & '}, 'alpha & beta & me'), 'join08': (r'{{ a|join:var|lower }}', {'a': ['Alpha', 'Beta & me'], 'var': mark_safe(' & ')}, 'alpha & beta & me'), 'date01': (r'{{ d|date:"m" }}', {'d': datetime(2008, 1, 1)}, '01'), diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py index 2551d438901..353d99ee83c 100644 --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -1102,19 +1102,19 @@ class TemplateTests(TransRealMixin, TestCase): 'ifchanged08': ('{% for data in datalist %}{% for c,d in data %}{% if c %}{% ifchanged %}{{ d }}{% endifchanged %}{% endif %}{% endfor %}{% endfor %}', {'datalist': [[(1, 'a'), (1, 'a'), (0, 'b'), (1, 'c')], [(0, 'a'), (1, 'c'), (1, 'd'), (1, 'd'), (0, 'e')]]}, 'accd'), # Test one parameter given to ifchanged. - 'ifchanged-param01': ('{% for n in num %}{% ifchanged n %}..{% endifchanged %}{{ n }}{% endfor %}', { 'num': (1,2,3) }, '..1..2..3'), - 'ifchanged-param02': ('{% for n in num %}{% for x in numx %}{% ifchanged n %}..{% endifchanged %}{{ x }}{% endfor %}{% endfor %}', { 'num': (1,2,3), 'numx': (5,6,7) }, '..567..567..567'), + 'ifchanged-param01': ('{% for n in num %}{% ifchanged n %}..{% endifchanged %}{{ n }}{% endfor %}', {'num': (1,2,3)}, '..1..2..3'), + 'ifchanged-param02': ('{% for n in num %}{% for x in numx %}{% ifchanged n %}..{% endifchanged %}{{ x }}{% endfor %}{% endfor %}', {'num': (1,2,3), 'numx': (5,6,7)}, '..567..567..567'), # Test multiple parameters to ifchanged. - 'ifchanged-param03': ('{% for n in num %}{{ n }}{% for x in numx %}{% ifchanged x n %}{{ x }}{% endifchanged %}{% endfor %}{% endfor %}', { 'num': (1,1,2), 'numx': (5,6,6) }, '156156256'), + 'ifchanged-param03': ('{% for n in num %}{{ n }}{% for x in numx %}{% ifchanged x n %}{{ x }}{% endifchanged %}{% endfor %}{% endfor %}', {'num': (1,1,2), 'numx': (5,6,6)}, '156156256'), # Test a date+hour like construct, where the hour of the last day # is the same but the date had changed, so print the hour anyway. - 'ifchanged-param04': ('{% for d in days %}{% ifchanged %}{{ d.day }}{% endifchanged %}{% for h in d.hours %}{% ifchanged d h %}{{ h }}{% endifchanged %}{% endfor %}{% endfor %}', {'days':[{'day':1, 'hours':[1,2,3]},{'day':2, 'hours':[3]},] }, '112323'), + 'ifchanged-param04': ('{% for d in days %}{% ifchanged %}{{ d.day }}{% endifchanged %}{% for h in d.hours %}{% ifchanged d h %}{{ h }}{% endifchanged %}{% endfor %}{% endfor %}', {'days':[{'day':1, 'hours':[1,2,3]},{'day':2, 'hours':[3]},]}, '112323'), # Logically the same as above, just written with explicit # ifchanged for the day. - 'ifchanged-param05': ('{% for d in days %}{% ifchanged d.day %}{{ d.day }}{% endifchanged %}{% for h in d.hours %}{% ifchanged d.day h %}{{ h }}{% endifchanged %}{% endfor %}{% endfor %}', {'days':[{'day':1, 'hours':[1,2,3]},{'day':2, 'hours':[3]},] }, '112323'), + 'ifchanged-param05': ('{% for d in days %}{% ifchanged d.day %}{{ d.day }}{% endifchanged %}{% for h in d.hours %}{% ifchanged d.day h %}{{ h }}{% endifchanged %}{% endfor %}{% endfor %}', {'days':[{'day':1, 'hours':[1,2,3]},{'day':2, 'hours':[3]},]}, '112323'), # Test the else clause of ifchanged. 'ifchanged-else01': ('{% for id in ids %}{{ id }}{% ifchanged id %}-first{% else %}-other{% endifchanged %},{% endfor %}', {'ids': [1,1,2,2,2,3]}, '1-first,1-other,2-first,2-other,2-other,3-first,'), @@ -1512,11 +1512,11 @@ class TemplateTests(TransRealMixin, TestCase): '{{ item.foo }}' '{% endfor %},' '{% endfor %}', - {'data': [ {'foo':'c', 'bar':1}, + {'data': [{'foo':'c', 'bar':1}, {'foo':'d', 'bar':1}, {'foo':'a', 'bar':2}, {'foo':'b', 'bar':2}, - {'foo':'x', 'bar':3} ]}, + {'foo':'x', 'bar':3}]}, '1:cd,2:ab,3:x,'), # Test for silent failure when target variable isn't found @@ -1640,8 +1640,8 @@ class TemplateTests(TransRealMixin, TestCase): 'widthratio16': ('{% widthratio a b 100 as variable %}-{{ variable }}-', {'a':50,'b':100}, '-50-'), 'widthratio17': ('{% widthratio a b 100 as variable %}-{{ variable }}-', {'a':100,'b':100}, '-100-'), - 'widthratio18': ('{% widthratio a b 100 as %}', { }, template.TemplateSyntaxError), - 'widthratio19': ('{% widthratio a b 100 not_as variable %}', { }, template.TemplateSyntaxError), + 'widthratio18': ('{% widthratio a b 100 as %}', {}, template.TemplateSyntaxError), + 'widthratio19': ('{% widthratio a b 100 not_as variable %}', {}, template.TemplateSyntaxError), ### WITH TAG ######################################################## 'with01': ('{% with key=dict.key %}{{ key }}{% endwith %}', {'dict': {'key': 50}}, '50'), @@ -1778,11 +1778,11 @@ class TemplateTests(TransRealMixin, TestCase): 'autoescape-filtertag01': ("{{ first }}{% filter safe %}{{ first }} x"}, template.TemplateSyntaxError), # ifqeual compares unescaped vales. - 'autoescape-ifequal01': ('{% ifequal var "this & that" %}yes{% endifequal %}', { "var": "this & that" }, "yes"), + 'autoescape-ifequal01': ('{% ifequal var "this & that" %}yes{% endifequal %}', {"var": "this & that"}, "yes"), # Arguments to filters are 'safe' and manipulate their input unescaped. - 'autoescape-filters01': ('{{ var|cut:"&" }}', { "var": "this & that" }, "this that" ), - 'autoescape-filters02': ('{{ var|join:" & \" }}', { "var": ("Tom", "Dick", "Harry") }, "Tom & Dick & Harry"), + 'autoescape-filters01': ('{{ var|cut:"&" }}', {"var": "this & that"}, "this that"), + 'autoescape-filters02': ('{{ var|join:" & \" }}', {"var": ("Tom", "Dick", "Harry")}, "Tom & Dick & Harry"), # Literal strings are safe. 'autoescape-literals01': ('{{ "this & that" }}',{}, "this & that"), @@ -1791,7 +1791,7 @@ class TemplateTests(TransRealMixin, TestCase): 'autoescape-stringiterations01': ('{% for l in var %}{{ l }},{% endfor %}', {'var': 'K&R'}, "K,&,R,"), # Escape requirement survives lookup. - 'autoescape-lookup01': ('{{ var.key }}', { "var": {"key": "this & that" }}, "this & that"), + 'autoescape-lookup01': ('{{ var.key }}', {"var": {"key": "this & that"}}, "this & that"), # Static template tags 'static-prefixtag01': ('{% load static %}{% get_static_prefix %}', {}, settings.STATIC_URL), diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py index f68ac335034..9f6bcce8303 100644 --- a/tests/utils_tests/test_http.py +++ b/tests/utils_tests/test_http.py @@ -36,7 +36,7 @@ class TestUtilsHttp(unittest.TestCase): self.assertEqual(result, 'a=1&b=2&c=3') # A dictionary - result = http.urlencode({ 'a': 1, 'b': 2, 'c': 3}) + result = http.urlencode({'a': 1, 'b': 2, 'c': 3}) acceptable_results = [ # Need to allow all of these as dictionaries have to be treated as # unordered diff --git a/tests/utils_tests/test_text.py b/tests/utils_tests/test_text.py index 62f13335170..1b1642e2ce7 100644 --- a/tests/utils_tests/test_text.py +++ b/tests/utils_tests/test_text.py @@ -76,11 +76,11 @@ class TestUtilsText(SimpleTestCase): truncator = text.Truncator('
The
quick brown fox jumped over' ' the lazy dog.') self.assertEqual('
The
quick brown...', - truncator.words(3, '...', html=True )) + truncator.words(3, '...', html=True)) truncator = text.Truncator('
The
quick brown fox ' 'jumped over the lazy dog.') self.assertEqual('
The
quick brown...', - truncator.words(3, '...', html=True )) + truncator.words(3, '...', html=True)) # Test html entities truncator = text.Truncator('Buenos días!'