From ae48d77ef8e14dae76fddcd5a677b897c7c7c4ae Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 23 Oct 2013 06:09:29 -0400 Subject: [PATCH] Fixed E225 pep8 warnings. --- .../gis/db/backends/postgis/operations.py | 2 +- django/contrib/gis/db/models/proxy.py | 2 +- django/contrib/gis/gdal/geomtype.py | 2 +- django/contrib/gis/gdal/prototypes/srs.py | 2 +- django/contrib/gis/geos/linestring.py | 2 +- .../contrib/gis/geos/prototypes/prepared.py | 2 +- django/contrib/gis/maps/google/gmap.py | 2 +- django/contrib/gis/maps/google/overlays.py | 4 ++-- django/contrib/gis/maps/google/zoom.py | 2 +- django/contrib/gis/tests/test_geoforms.py | 14 ++++++------ django/contrib/gis/tests/test_measure.py | 2 +- django/contrib/messages/tests/base.py | 12 +++++----- django/contrib/redirects/models.py | 2 +- django/contrib/sites/managers.py | 2 +- .../core/management/commands/makemessages.py | 2 +- django/dispatch/saferef.py | 2 +- django/forms/widgets.py | 2 +- django/utils/datastructures.py | 2 +- django/utils/dateformat.py | 2 +- django/utils/datetime_safe.py | 2 +- docs/conf.py | 2 +- setup.cfg | 2 +- tests/admin_inlines/admin.py | 4 ++-- tests/admin_validation/tests.py | 2 +- tests/admin_views/admin.py | 6 ++--- tests/admin_widgets/tests.py | 2 +- tests/backends/tests.py | 4 ++-- tests/cache/tests.py | 4 ++-- tests/defer/models.py | 2 +- tests/dispatch/tests/test_saferef.py | 2 +- tests/distinct_on_fields/tests.py | 4 ++-- tests/expressions_regress/tests.py | 12 +++++----- tests/forms_tests/tests/test_widgets.py | 17 +++++++++++--- tests/i18n/commands/compilation.py | 12 +++++----- tests/i18n/commands/extraction.py | 8 +++---- tests/m2m_and_m2o/tests.py | 4 ++-- tests/m2m_through_regress/tests.py | 2 +- tests/model_forms/tests.py | 2 +- tests/model_inheritance_regress/tests.py | 2 +- tests/multiple_database/tests.py | 6 ++--- tests/queries/tests.py | 6 ++--- tests/select_related_regress/tests.py | 22 +++++++++---------- tests/validation/tests.py | 2 +- 43 files changed, 102 insertions(+), 91 deletions(-) diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index 1d29b394e08..80bcb10e9c0 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -456,7 +456,7 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations): def exactly_two(np): return np == 2 def two_to_three(np): - return np >= 2 and np <=3 + return np >= 2 and np <= 3 if (lookup_type in self.distance_functions and lookup_type != 'dwithin'): return two_to_three(num_param) diff --git a/django/contrib/gis/db/models/proxy.py b/django/contrib/gis/db/models/proxy.py index d55397fd448..513bf921bd8 100644 --- a/django/contrib/gis/db/models/proxy.py +++ b/django/contrib/gis/db/models/proxy.py @@ -32,7 +32,7 @@ class GeometryProxy(object): if isinstance(geom_value, self._klass): geom = geom_value - elif (geom_value is None) or (geom_value==''): + elif (geom_value is None) or (geom_value == ''): geom = None else: # Otherwise, a Geometry object is built using the field's contents, diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py index 8a1ce5e5444..1b1547c341b 100644 --- a/django/contrib/gis/gdal/geomtype.py +++ b/django/contrib/gis/gdal/geomtype.py @@ -37,7 +37,7 @@ class OGRGeomType(object): elif isinstance(type_input, six.string_types): type_input = type_input.lower() if type_input == 'geometry': - type_input='unknown' + type_input = 'unknown' num = self._str_types.get(type_input, None) if num is None: raise OGRException('Invalid OGR String Type "%s"' % type_input) diff --git a/django/contrib/gis/gdal/prototypes/srs.py b/django/contrib/gis/gdal/prototypes/srs.py index 58ceb754562..29a73ddcc7a 100644 --- a/django/contrib/gis/gdal/prototypes/srs.py +++ b/django/contrib/gis/gdal/prototypes/srs.py @@ -67,5 +67,5 @@ islocal = int_output(lgdal.OSRIsLocal, [c_void_p]) isprojected = int_output(lgdal.OSRIsProjected, [c_void_p]) # Coordinate transformation -new_ct= srs_output(std_call('OCTNewCoordinateTransformation'), [c_void_p, c_void_p]) +new_ct = srs_output(std_call('OCTNewCoordinateTransformation'), [c_void_p, c_void_p]) destroy_ct = void_output(std_call('OCTDestroyCoordinateTransformation'), [c_void_p], errcheck=False) diff --git a/django/contrib/gis/geos/linestring.py b/django/contrib/gis/geos/linestring.py index 5346ee6cec8..0182646fa0d 100644 --- a/django/contrib/gis/geos/linestring.py +++ b/django/contrib/gis/geos/linestring.py @@ -58,7 +58,7 @@ class LineString(GEOSGeometry): # Creating a coordinate sequence object because it is easier to # set the points using GEOSCoordSeq.__setitem__(). - cs = GEOSCoordSeq(capi.create_cs(ncoords, ndim), z=bool(ndim==3)) + cs = GEOSCoordSeq(capi.create_cs(ncoords, ndim), z=bool(ndim == 3)) for i in xrange(ncoords): if numpy_coords: diff --git a/django/contrib/gis/geos/prototypes/prepared.py b/django/contrib/gis/geos/prototypes/prepared.py index 7342d7d9667..ff46979de38 100644 --- a/django/contrib/gis/geos/prototypes/prepared.py +++ b/django/contrib/gis/geos/prototypes/prepared.py @@ -14,7 +14,7 @@ prepared_destroy.restype = None # Prepared geometry binary predicate support. def prepared_predicate(func): - func.argtypes= [PREPGEOM_PTR, GEOM_PTR] + func.argtypes = [PREPGEOM_PTR, GEOM_PTR] func.restype = c_char func.errcheck = check_predicate return func diff --git a/django/contrib/gis/maps/google/gmap.py b/django/contrib/gis/maps/google/gmap.py index 4fe9b1198ad..89b625378d5 100644 --- a/django/contrib/gis/maps/google/gmap.py +++ b/django/contrib/gis/maps/google/gmap.py @@ -12,7 +12,7 @@ class GoogleMapException(Exception): # The default Google Maps URL (for the API javascript) # TODO: Internationalize for Japan, UK, etc. -GOOGLE_MAPS_URL='http://maps.google.com/maps?file=api&v=%s&key=' +GOOGLE_MAPS_URL = 'http://maps.google.com/maps?file=api&v=%s&key=' class GoogleMap(object): diff --git a/django/contrib/gis/maps/google/overlays.py b/django/contrib/gis/maps/google/overlays.py index 0869f657a98..6b201cd4e58 100644 --- a/django/contrib/gis/maps/google/overlays.py +++ b/django/contrib/gis/maps/google/overlays.py @@ -52,7 +52,7 @@ class GEvent(object): def __str__(self): "Returns the parameter part of a GEvent." - return mark_safe('"%s", %s' %(self.event, self.action)) + return mark_safe('"%s", %s' % (self.event, self.action)) @python_2_unicode_compatible class GOverlayBase(object): @@ -303,7 +303,7 @@ class GMarker(GOverlayBase): super(GMarker, self).__init__() def latlng_from_coords(self, coords): - return 'new GLatLng(%s,%s)' %(coords[1], coords[0]) + return 'new GLatLng(%s,%s)' % (coords[1], coords[0]) def options(self): result = [] diff --git a/django/contrib/gis/maps/google/zoom.py b/django/contrib/gis/maps/google/zoom.py index 0e702c99059..f4e8a8ec7c8 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/test_geoforms.py b/django/contrib/gis/tests/test_geoforms.py index 7c2f67e551a..bedf1e1568a 100644 --- a/django/contrib/gis/tests/test_geoforms.py +++ b/django/contrib/gis/tests/test_geoforms.py @@ -163,7 +163,7 @@ class SpecializedFieldTest(SimpleTestCase): self.assertFalse(invalid.is_valid()) self.assertTrue('Invalid geometry value' in str(invalid.errors)) - for invalid in [geo for key, geo in self.geometries.items() if key!='point']: + for invalid in [geo for key, geo in self.geometries.items() if key != 'point']: self.assertFalse(PointForm(data={'p': invalid.wkt}).is_valid()) def test_multipointfield(self): @@ -176,7 +176,7 @@ class SpecializedFieldTest(SimpleTestCase): self.assertMapWidget(form) self.assertFalse(PointForm().is_valid()) - for invalid in [geo for key, geo in self.geometries.items() if key!='multipoint']: + for invalid in [geo for key, geo in self.geometries.items() if key != 'multipoint']: self.assertFalse(PointForm(data={'p': invalid.wkt}).is_valid()) def test_linestringfield(self): @@ -189,7 +189,7 @@ class SpecializedFieldTest(SimpleTestCase): self.assertMapWidget(form) self.assertFalse(LineStringForm().is_valid()) - for invalid in [geo for key, geo in self.geometries.items() if key!='linestring']: + for invalid in [geo for key, geo in self.geometries.items() if key != 'linestring']: self.assertFalse(LineStringForm(data={'p': invalid.wkt}).is_valid()) def test_multilinestringfield(self): @@ -202,7 +202,7 @@ class SpecializedFieldTest(SimpleTestCase): self.assertMapWidget(form) self.assertFalse(LineStringForm().is_valid()) - for invalid in [geo for key, geo in self.geometries.items() if key!='multilinestring']: + for invalid in [geo for key, geo in self.geometries.items() if key != 'multilinestring']: self.assertFalse(LineStringForm(data={'p': invalid.wkt}).is_valid()) def test_polygonfield(self): @@ -215,7 +215,7 @@ class SpecializedFieldTest(SimpleTestCase): self.assertMapWidget(form) self.assertFalse(PolygonForm().is_valid()) - for invalid in [geo for key, geo in self.geometries.items() if key!='polygon']: + for invalid in [geo for key, geo in self.geometries.items() if key != 'polygon']: self.assertFalse(PolygonForm(data={'p': invalid.wkt}).is_valid()) def test_multipolygonfield(self): @@ -228,7 +228,7 @@ class SpecializedFieldTest(SimpleTestCase): self.assertMapWidget(form) self.assertFalse(PolygonForm().is_valid()) - for invalid in [geo for key, geo in self.geometries.items() if key!='multipolygon']: + for invalid in [geo for key, geo in self.geometries.items() if key != 'multipolygon']: self.assertFalse(PolygonForm(data={'p': invalid.wkt}).is_valid()) def test_geometrycollectionfield(self): @@ -241,7 +241,7 @@ class SpecializedFieldTest(SimpleTestCase): self.assertMapWidget(form) self.assertFalse(GeometryForm().is_valid()) - for invalid in [geo for key, geo in self.geometries.items() if key!='geometrycollection']: + for invalid in [geo for key, geo in self.geometries.items() if key != 'geometrycollection']: self.assertFalse(GeometryForm(data={'g': invalid.wkt}).is_valid()) def test_osm_widget(self): diff --git a/django/contrib/gis/tests/test_measure.py b/django/contrib/gis/tests/test_measure.py index 21870b6f0cc..5e0db3f9131 100644 --- a/django/contrib/gis/tests/test_measure.py +++ b/django/contrib/gis/tests/test_measure.py @@ -272,5 +272,5 @@ def suite(): def run(verbosity=2): unittest.TextTestRunner(verbosity=verbosity).run(suite()) -if __name__=="__main__": +if __name__ == "__main__": run() diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py index 5e3fba2553d..b247362e1b6 100644 --- a/django/contrib/messages/tests/base.py +++ b/django/contrib/messages/tests/base.py @@ -214,11 +214,11 @@ class BaseTests(object): @override_settings( INSTALLED_APPS=filter( - lambda app:app!='django.contrib.messages', settings.INSTALLED_APPS), + lambda app: app != 'django.contrib.messages', settings.INSTALLED_APPS), MIDDLEWARE_CLASSES=filter( - lambda m:'MessageMiddleware' not in m, settings.MIDDLEWARE_CLASSES), + lambda m: 'MessageMiddleware' not in m, settings.MIDDLEWARE_CLASSES), TEMPLATE_CONTEXT_PROCESSORS=filter( - lambda p:'context_processors.messages' not in p, + lambda p: 'context_processors.messages' not in p, settings.TEMPLATE_CONTEXT_PROCESSORS), MESSAGE_LEVEL=constants.DEBUG ) @@ -239,11 +239,11 @@ class BaseTests(object): @override_settings( INSTALLED_APPS=filter( - lambda app:app!='django.contrib.messages', settings.INSTALLED_APPS), + lambda app: app != 'django.contrib.messages', settings.INSTALLED_APPS), MIDDLEWARE_CLASSES=filter( - lambda m:'MessageMiddleware' not in m, settings.MIDDLEWARE_CLASSES), + lambda m: 'MessageMiddleware' not in m, settings.MIDDLEWARE_CLASSES), TEMPLATE_CONTEXT_PROCESSORS=filter( - lambda p:'context_processors.messages' not in p, + lambda p: 'context_processors.messages' not in p, settings.TEMPLATE_CONTEXT_PROCESSORS), MESSAGE_LEVEL=constants.DEBUG ) diff --git a/django/contrib/redirects/models.py b/django/contrib/redirects/models.py index a0376b55782..b2257cf1661 100644 --- a/django/contrib/redirects/models.py +++ b/django/contrib/redirects/models.py @@ -15,7 +15,7 @@ class Redirect(models.Model): verbose_name = _('redirect') verbose_name_plural = _('redirects') db_table = 'django_redirect' - unique_together=(('site', 'old_path'),) + unique_together = (('site', 'old_path'),) ordering = ('old_path',) def __str__(self): diff --git a/django/contrib/sites/managers.py b/django/contrib/sites/managers.py index 1cd2416377f..ceaccc7ae56 100644 --- a/django/contrib/sites/managers.py +++ b/django/contrib/sites/managers.py @@ -29,7 +29,7 @@ class CurrentSiteManager(models.Manager): try: field = self.model._meta.get_field(self.__field_name) if not isinstance(field, (models.ForeignKey, models.ManyToManyField)): - raise TypeError("%s must be a ForeignKey or ManyToManyField." %self.__field_name) + raise TypeError("%s must be a ForeignKey or ManyToManyField." % self.__field_name) except FieldDoesNotExist: raise ValueError("%s couldn't find a field named %s in %s." % (self.__class__.__name__, self.__field_name, self.model._meta.object_name)) diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py index 120cff096b4..6f837ae1e49 100644 --- a/django/core/management/commands/makemessages.py +++ b/django/core/management/commands/makemessages.py @@ -138,7 +138,7 @@ class TranslatableFile(object): if msgs: if is_templatized: # Remove '.py' suffix - if os.name =='nt': + if os.name == 'nt': # Preserve '.\' prefix on Windows to respect gettext behavior old = '#: ' + work_file new = '#: ' + orig_file diff --git a/django/dispatch/saferef.py b/django/dispatch/saferef.py index 41756a1001e..7c971e44f7c 100644 --- a/django/dispatch/saferef.py +++ b/django/dispatch/saferef.py @@ -83,7 +83,7 @@ class BoundMethodWeakref(object): of already-referenced methods. """ key = cls.calculateKey(target) - current =cls._allInstances.get(key) + current = cls._allInstances.get(key) if current is not None: current.deletionMethods.append(onDelete) return current diff --git a/django/forms/widgets.py b/django/forms/widgets.py index e6f10dd37b3..faee6381a2a 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -274,7 +274,7 @@ class PasswordInput(TextInput): def render(self, name, value, attrs=None): if not self.render_value: - value=None + value = None return super(PasswordInput, self).render(name, value, attrs) class HiddenInput(Input): diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index d73f4aa546e..e5fe4a776a8 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -500,7 +500,7 @@ class ImmutableList(tuple): extend = complain insert = complain pop = complain - remove= complain + remove = complain sort = complain reverse = complain diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py index 3c235d98678..2fe6760a88f 100644 --- a/django/utils/dateformat.py +++ b/django/utils/dateformat.py @@ -170,7 +170,7 @@ class TimeFormat(Formatter): def u(self): "Microseconds; i.e. '000000' to '999999'" - return '%06d' %self.data.microsecond + return '%06d' % self.data.microsecond def Z(self): """ diff --git a/django/utils/datetime_safe.py b/django/utils/datetime_safe.py index ca96fb37b04..286b5f127b0 100644 --- a/django/utils/datetime_safe.py +++ b/django/utils/datetime_safe.py @@ -54,7 +54,7 @@ def _findall(text, substr): if j == -1: break sites.append(j) - i=j+1 + i = j + 1 return sites def strftime(dt, fmt): diff --git a/docs/conf.py b/docs/conf.py index 003d89ef245..f8625e73d91 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -264,7 +264,7 @@ man_pages = [ # List of tuples (startdocname, targetname, title, author, dir_entry, # description, category, toctree_only) -texinfo_documents=[( +texinfo_documents = [( master_doc, "django", "", "", "Django", "Documentation of the Django framework", "Web development", False )] diff --git a/setup.cfg b/setup.cfg index 453d7aa4a86..ca6f8c5661f 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=E124,E125,E127,E128,E225,E226,E241,E251,E302,E501,E203,E231,E261,E301,F401,F403,W601 +ignore=E124,E125,E127,E128,E226,E241,E251,E302,E501,E203,E231,E261,E301,F401,F403,W601 [metadata] license-file = LICENSE diff --git a/tests/admin_inlines/admin.py b/tests/admin_inlines/admin.py index 91578042cc3..98c19befa44 100644 --- a/tests/admin_inlines/admin.py +++ b/tests/admin_inlines/admin.py @@ -107,7 +107,7 @@ class InlineWeakness(admin.TabularInline): class QuestionInline(admin.TabularInline): model = Question - readonly_fields=['call_me'] + readonly_fields = ['call_me'] def call_me(self, obj): return 'Callable in QuestionInline' @@ -122,7 +122,7 @@ class PollAdmin(admin.ModelAdmin): class ChapterInline(admin.TabularInline): model = Chapter - readonly_fields=['call_me'] + readonly_fields = ['call_me'] def call_me(self, obj): return 'Callable in ChapterInline' diff --git a/tests/admin_validation/tests.py b/tests/admin_validation/tests.py index 0deb80c0efd..4bb1f17fd84 100644 --- a/tests/admin_validation/tests.py +++ b/tests/admin_validation/tests.py @@ -193,7 +193,7 @@ class ValidationTestCase(TestCase): def test_nonexistant_field_on_inline(self): class CityInline(admin.TabularInline): model = City - readonly_fields=['i_dont_exist'] # Missing attribute + readonly_fields = ['i_dont_exist'] # Missing attribute self.assertRaisesMessage(ImproperlyConfigured, str_prefix("CityInline.readonly_fields[0], %(_)s'i_dont_exist' is not a callable " diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index 85f6298a185..889c51a6db8 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -47,7 +47,7 @@ class ArticleInline(admin.TabularInline): prepopulated_fields = { 'title' : ('content',) } - fieldsets=( + fieldsets = ( ('Some fields', { 'classes': ('collapse',), 'fields': ('title', 'content') @@ -74,7 +74,7 @@ class ChapterXtra1Admin(admin.ModelAdmin): class ArticleAdmin(admin.ModelAdmin): list_display = ('content', 'date', callable_year, 'model_year', 'modeladmin_year') list_filter = ('date', 'section') - fieldsets=( + fieldsets = ( ('Some fields', { 'classes': ('collapse',), 'fields': ('title', 'content') @@ -465,7 +465,7 @@ class WorkHourAdmin(admin.ModelAdmin): class FoodDeliveryAdmin(admin.ModelAdmin): - list_display=('reference', 'driver', 'restaurant') + list_display = ('reference', 'driver', 'restaurant') list_editable = ('driver', 'restaurant') diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py index ccc9add36e3..ee8b2f3bac4 100644 --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -166,7 +166,7 @@ class AdminFormfieldForDBFieldTests(TestCase): def test_m2m_widgets(self): """m2m fields help text as it applies to admin app (#9321).""" class AdvisorAdmin(admin.ModelAdmin): - filter_vertical=['companies'] + filter_vertical = ['companies'] self.assertFormfield(models.Advisor, 'companies', widgets.FilteredSelectMultiple, filter_vertical=['companies']) diff --git a/tests/backends/tests.py b/tests/backends/tests.py index c6fe4e98f3b..3c0cc67ea23 100644 --- a/tests/backends/tests.py +++ b/tests/backends/tests.py @@ -496,9 +496,9 @@ class BackendTestCase(TestCase): tbl = connection.introspection.table_name_converter(opts.db_table) f1 = connection.ops.quote_name(opts.get_field('root').column) f2 = connection.ops.quote_name(opts.get_field('square').column) - if paramstyle=='format': + if paramstyle == 'format': query = 'INSERT INTO %s (%s, %s) VALUES (%%s, %%s)' % (tbl, f1, f2) - elif paramstyle=='pyformat': + elif paramstyle == 'pyformat': query = 'INSERT INTO %s (%s, %s) VALUES (%%(root)s, %%(square)s)' % (tbl, f1, f2) else: raise ValueError("unsupported paramstyle in test") diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 9681c201ed8..5712f10b4f1 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -1527,8 +1527,8 @@ class CacheI18nTest(TestCase): self.assertEqual(get_cache_data, None) # i18n tests - en_message ="Hello world!" - es_message ="Hola mundo!" + en_message = "Hello world!" + es_message = "Hola mundo!" request = self._get_request_cache() set_cache(request, 'en', en_message) diff --git a/tests/defer/models.py b/tests/defer/models.py index 0688cbc9840..cf3bae86bbb 100644 --- a/tests/defer/models.py +++ b/tests/defer/models.py @@ -27,4 +27,4 @@ class BigChild(Primary): class ChildProxy(Child): class Meta: - proxy=True + proxy = True diff --git a/tests/dispatch/tests/test_saferef.py b/tests/dispatch/tests/test_saferef.py index a9a246304e2..531e8f43deb 100644 --- a/tests/dispatch/tests/test_saferef.py +++ b/tests/dispatch/tests/test_saferef.py @@ -69,4 +69,4 @@ class SaferefTests(unittest.TestCase): def _closure(self, ref): """Dumb utility mechanism to increment deletion counter""" - self.closureCount +=1 + self.closureCount += 1 diff --git a/tests/distinct_on_fields/tests.py b/tests/distinct_on_fields/tests.py index cb88f60321d..505a0470bf8 100644 --- a/tests/distinct_on_fields/tests.py +++ b/tests/distinct_on_fields/tests.py @@ -57,8 +57,8 @@ class DistinctOnTests(TestCase): # Does combining querysets work? ( (Celebrity.objects.filter(fan__in=[self.fan1, self.fan2]). - distinct('name').order_by('name') - |Celebrity.objects.filter(fan__in=[self.fan3]). + distinct('name').order_by('name') | + Celebrity.objects.filter(fan__in=[self.fan3]). distinct('name').order_by('name')), ['', ''], ), diff --git a/tests/expressions_regress/tests.py b/tests/expressions_regress/tests.py index 470ab7c8e5e..0e168e924a2 100644 --- a/tests/expressions_regress/tests.py +++ b/tests/expressions_regress/tests.py @@ -224,7 +224,7 @@ class FTimeDeltaTests(TestCase): e0 = Experiment.objects.create(name='e0', assigned=sday, start=stime, end=end, completed=end.date()) self.deltas.append(delta0) - self.delays.append(e0.start- + self.delays.append(e0.start - datetime.datetime.combine(e0.assigned, midnight)) self.days_long.append(e0.completed-e0.assigned) @@ -239,7 +239,7 @@ class FTimeDeltaTests(TestCase): e1 = Experiment.objects.create(name='e1', assigned=sday, start=stime+delay, end=end, completed=end.date()) self.deltas.append(delta1) - self.delays.append(e1.start- + self.delays.append(e1.start - datetime.datetime.combine(e1.assigned, midnight)) self.days_long.append(e1.completed-e1.assigned) @@ -249,7 +249,7 @@ class FTimeDeltaTests(TestCase): assigned=sday-datetime.timedelta(3), start=stime, end=end, completed=end.date()) self.deltas.append(delta2) - self.delays.append(e2.start- + self.delays.append(e2.start - datetime.datetime.combine(e2.assigned, midnight)) self.days_long.append(e2.completed-e2.assigned) @@ -259,7 +259,7 @@ class FTimeDeltaTests(TestCase): e3 = Experiment.objects.create(name='e3', assigned=sday, start=stime+delay, end=end, completed=end.date()) self.deltas.append(delta3) - self.delays.append(e3.start- + self.delays.append(e3.start - datetime.datetime.combine(e3.assigned, midnight)) self.days_long.append(e3.completed-e3.assigned) @@ -269,7 +269,7 @@ class FTimeDeltaTests(TestCase): assigned=sday-datetime.timedelta(10), start=stime, end=end, completed=end.date()) self.deltas.append(delta4) - self.delays.append(e4.start- + self.delays.append(e4.start - datetime.datetime.combine(e4.assigned, midnight)) self.days_long.append(e4.completed-e4.assigned) self.expnames = [e.name for e in Experiment.objects.all()] @@ -341,7 +341,7 @@ class FTimeDeltaTests(TestCase): self.assertEqual(test_set, self.expnames[:i]) test_set = [e.name for e in - Experiment.objects.filter(start__lte=F('assigned')+delay+ + Experiment.objects.filter(start__lte=F('assigned') + delay + datetime.timedelta(1))] self.assertEqual(test_set, self.expnames[:i+1]) diff --git a/tests/forms_tests/tests/test_widgets.py b/tests/forms_tests/tests/test_widgets.py index e6509e8699b..48bd068b217 100644 --- a/tests/forms_tests/tests/test_widgets.py +++ b/tests/forms_tests/tests/test_widgets.py @@ -340,7 +340,10 @@ class FormsWidgetTestCase(TestCase): """) # Choices can be nested one level in order to create HTML optgroups: - w.choices=(('outer1', 'Outer 1'), ('Group "1"', (('inner1', 'Inner 1'), ('inner2', 'Inner 2')))) + w.choices = ( + ('outer1', 'Outer 1'), + ('Group "1"', (('inner1', 'Inner 1'), ('inner2', 'Inner 2'))), + ) self.assertHTMLEqual(w.render('nestchoice', None), """ Unknown
  • Audio
      @@ -721,7 +728,11 @@ beatle J R Ringo False""") # Choices can be nested for checkboxes: w = CheckboxSelectMultiple() - w.choices=(('unknown', 'Unknown'), ('Audio', (('vinyl', 'Vinyl'), ('cd', 'CD'))), ('Video', (('vhs', 'VHS'), ('dvd', 'DVD')))) + w.choices = ( + ('unknown', 'Unknown'), + ('Audio', (('vinyl', 'Vinyl'), ('cd', 'CD'))), + ('Video', (('vhs', 'VHS'), ('dvd', 'DVD'))), + ) self.assertHTMLEqual(w.render('nestchoice', ('vinyl', 'dvd'), attrs={'id':'media'}), """
      • Audio
          diff --git a/tests/i18n/commands/compilation.py b/tests/i18n/commands/compilation.py index 12bb89ed084..7a159ad1fcf 100644 --- a/tests/i18n/commands/compilation.py +++ b/tests/i18n/commands/compilation.py @@ -37,8 +37,8 @@ class PoFileTests(MessageCompilationTests): class PoFileContentsTests(MessageCompilationTests): # Ticket #11240 - LOCALE='fr' - MO_FILE='locale/%s/LC_MESSAGES/django.mo' % LOCALE + LOCALE = 'fr' + MO_FILE = 'locale/%s/LC_MESSAGES/django.mo' % LOCALE def setUp(self): super(PoFileContentsTests, self).setUp() @@ -53,8 +53,8 @@ class PercentRenderingTests(MessageCompilationTests): # Ticket #11240 -- Testing rendering doesn't belong here but we are trying # to keep tests for all the stack together - LOCALE='it' - MO_FILE='locale/%s/LC_MESSAGES/django.mo' % LOCALE + LOCALE = 'it' + MO_FILE = 'locale/%s/LC_MESSAGES/django.mo' % LOCALE def setUp(self): super(PercentRenderingTests, self).setUp() @@ -101,8 +101,8 @@ class MultipleLocaleCompilationTests(MessageCompilationTests): class CompilationErrorHandling(MessageCompilationTests): - LOCALE='ja' - MO_FILE='locale/%s/LC_MESSAGES/django.mo' % LOCALE + LOCALE = 'ja' + MO_FILE = 'locale/%s/LC_MESSAGES/django.mo' % LOCALE def setUp(self): super(CompilationErrorHandling, self).setUp() diff --git a/tests/i18n/commands/extraction.py b/tests/i18n/commands/extraction.py index 107fd4ab1c2..462af6064c9 100644 --- a/tests/i18n/commands/extraction.py +++ b/tests/i18n/commands/extraction.py @@ -17,11 +17,11 @@ from django.utils.six import StringIO from django.utils.translation import TranslatorCommentWarning -LOCALE='de' +LOCALE = 'de' class ExtractorTests(SimpleTestCase): - PO_FILE='locale/%s/LC_MESSAGES/django.po' % LOCALE + PO_FILE = 'locale/%s/LC_MESSAGES/django.po' % LOCALE def setUp(self): self._cwd = os.getcwd() @@ -255,7 +255,7 @@ class BasicExtractorTests(ExtractorTests): class JavascriptExtractorTests(ExtractorTests): - PO_FILE='locale/%s/LC_MESSAGES/djangojs.po' % LOCALE + PO_FILE = 'locale/%s/LC_MESSAGES/djangojs.po' % LOCALE def test_javascript_literals(self): os.chdir(self.test_dir) @@ -426,7 +426,7 @@ class LocationCommentsTests(ExtractorTests): class KeepPotFileExtractorTests(ExtractorTests): - POT_FILE='locale/django.pot' + POT_FILE = 'locale/django.pot' def setUp(self): super(KeepPotFileExtractorTests, self).setUp() diff --git a/tests/m2m_and_m2o/tests.py b/tests/m2m_and_m2o/tests.py index 646212bf4f4..ee5d77919f0 100644 --- a/tests/m2m_and_m2o/tests.py +++ b/tests/m2m_and_m2o/tests.py @@ -80,8 +80,8 @@ class RelatedObjectUnicodeTests(TestCase): Regression test for #6045: references to other models can be unicode strings, providing they are directly convertible to ASCII. """ - m1=UnicodeReferenceModel.objects.create() - m2=UnicodeReferenceModel.objects.create() + m1 = UnicodeReferenceModel.objects.create() + m2 = UnicodeReferenceModel.objects.create() m2.others.add(m1) # used to cause an error (see ticket #6045) m2.save() list(m2.others.all()) # Force retrieval. diff --git a/tests/m2m_through_regress/tests.py b/tests/m2m_through_regress/tests.py index 3f5702efa84..e0796242aac 100644 --- a/tests/m2m_through_regress/tests.py +++ b/tests/m2m_through_regress/tests.py @@ -68,7 +68,7 @@ class M2MThroughTestCase(TestCase): p = Person.objects.create(name="Bob") g = Group.objects.create(name="Roll") - m =Membership.objects.create(person=p, group=g) + m = Membership.objects.create(person=p, group=g) pks = {"p_pk": p.pk, "g_pk": g.pk, "m_pk": m.pk} diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 4551084eae2..5388ec99d0f 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -791,7 +791,7 @@ class ModelToDictTests(TestCase): Tests for forms.models.model_to_dict """ def test_model_to_dict_many_to_many(self): - categories=[ + categories = [ Category(name='TestName1', slug='TestName1', url='url1'), Category(name='TestName2', slug='TestName2', url='url2'), Category(name='TestName3', slug='TestName3', url='url3') diff --git a/tests/model_inheritance_regress/tests.py b/tests/model_inheritance_regress/tests.py index cd77085fbb0..710cebaa8fc 100644 --- a/tests/model_inheritance_regress/tests.py +++ b/tests/model_inheritance_regress/tests.py @@ -82,7 +82,7 @@ class ModelInheritanceTest(TestCase): italian_restaurant.serves_gnocchi = False italian_restaurant.save_base(raw=True) - place2.name='Derelict lot' + place2.name = 'Derelict lot' place2.save_base(raw=True) park.capacity = 50 diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py index 431d62e112e..b00ff8a6205 100644 --- a/tests/multiple_database/tests.py +++ b/tests/multiple_database/tests.py @@ -39,7 +39,7 @@ class QueryTestCase(TestCase): # Create a book on the default database using a save dive = Book() - dive.title="Dive into Python" + dive.title = "Dive into Python" dive.published = datetime.date(2009, 5, 4) dive.save() @@ -74,7 +74,7 @@ class QueryTestCase(TestCase): # Create a book on the default database using a save dive = Book() - dive.title="Dive into Python" + dive.title = "Dive into Python" dive.published = datetime.date(2009, 5, 4) dive.save(using='other') @@ -1794,7 +1794,7 @@ class RouterAttributeErrorTestCase(TestCase): def test_attribute_error_save(self): "Check that the AttributeError from AttributeErrorRouter bubbles up" dive = Book() - dive.title="Dive into Python" + dive.title = "Dive into Python" dive.published = datetime.date(2009, 5, 4) self.assertRaises(AttributeError, dive.save) diff --git a/tests/queries/tests.py b/tests/queries/tests.py index b1c63360889..dcdd6539e36 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -579,7 +579,7 @@ class Queries1Tests(BaseQuerysetTest): ['datetime.datetime(2007, 12, 19, 0, 0)', 'datetime.datetime(2007, 12, 20, 0, 0)'] ) - name="one" + name = "one" self.assertQuerysetEqual( Item.objects.datetimes('created', 'day').extra(where=['name=%s'], params=[name]), ['datetime.datetime(2007, 12, 19, 0, 0)'] @@ -2670,8 +2670,8 @@ class NullJoinPromotionOrTest(TestCase): # b__c__name generates join to c, which the ORM tried to promote but # failed as that join isn't nullable. q_obj = ( - Q(d__name='foo')| - Q(b__name='foo')| + Q(d__name='foo') | + Q(b__name='foo') | Q(b__c__name='foo') ) qset = ModelA.objects.filter(q_obj) diff --git a/tests/select_related_regress/tests.py b/tests/select_related_regress/tests.py index 59f4c0d94e5..6619105069e 100644 --- a/tests/select_related_regress/tests.py +++ b/tests/select_related_regress/tests.py @@ -23,21 +23,21 @@ class SelectRelatedRegressTests(TestCase): and include some unnecessary bonus joins). """ - b=Building.objects.create(name='101') - dev1=Device.objects.create(name="router", building=b) - dev2=Device.objects.create(name="switch", building=b) - dev3=Device.objects.create(name="server", building=b) - port1=Port.objects.create(port_number='4',device=dev1) - port2=Port.objects.create(port_number='7',device=dev2) - port3=Port.objects.create(port_number='1',device=dev3) - c1=Connection.objects.create(start=port1, end=port2) - c2=Connection.objects.create(start=port2, end=port3) + b = Building.objects.create(name='101') + dev1 = Device.objects.create(name="router", building=b) + dev2 = Device.objects.create(name="switch", building=b) + dev3 = Device.objects.create(name="server", building=b) + port1 = Port.objects.create(port_number='4',device=dev1) + port2 = Port.objects.create(port_number='7',device=dev2) + port3 = Port.objects.create(port_number='1',device=dev3) + c1 = Connection.objects.create(start=port1, end=port2) + c2 = Connection.objects.create(start=port2, end=port3) - connections=Connection.objects.filter(start__device__building=b, end__device__building=b).order_by('id') + connections = Connection.objects.filter(start__device__building=b, end__device__building=b).order_by('id') self.assertEqual([(c.id, six.text_type(c.start), six.text_type(c.end)) for c in connections], [(c1.id, 'router/4', 'switch/7'), (c2.id, 'switch/7', 'server/1')]) - connections=Connection.objects.filter(start__device__building=b, end__device__building=b).select_related().order_by('id') + connections = Connection.objects.filter(start__device__building=b, end__device__building=b).select_related().order_by('id') self.assertEqual([(c.id, six.text_type(c.start), six.text_type(c.end)) for c in connections], [(c1.id, 'router/4', 'switch/7'), (c2.id, 'switch/7', 'server/1')]) diff --git a/tests/validation/tests.py b/tests/validation/tests.py index 34cde3fc8a6..7f028e655b8 100644 --- a/tests/validation/tests.py +++ b/tests/validation/tests.py @@ -24,7 +24,7 @@ class BaseModelValidationTests(ValidationTestCase): self.assertFailsValidation(mtv.full_clean, [NON_FIELD_ERRORS, 'name']) def test_wrong_FK_value_raises_error(self): - mtv=ModelToValidate(number=10, name='Some Name', parent_id=3) + mtv = ModelToValidate(number=10, name='Some Name', parent_id=3) self.assertFailsValidation(mtv.full_clean, ['parent']) def test_correct_FK_value_validates(self):