From dfb4cb9970f86487f0aaa88c5dfcfafa31e4f430 Mon Sep 17 00:00:00 2001 From: Alasdair Nicol Date: Thu, 17 Oct 2013 23:27:45 +0100 Subject: [PATCH] Fixed #21285 -- Fixed E121,E122 pep8 warnings --- django/conf/global_settings.py | 10 +- django/contrib/admin/filters.py | 5 +- django/contrib/admin/options.py | 14 +-- django/contrib/admin/views/main.py | 6 +- django/contrib/auth/tests/test_forms.py | 2 +- django/contrib/auth/tests/test_management.py | 2 +- .../tests/wizard/wizardtests/urls.py | 12 +-- django/contrib/gis/admin/widgets.py | 4 +- django/contrib/gis/db/models/__init__.py | 6 +- django/contrib/gis/forms/widgets.py | 4 +- django/contrib/messages/storage/base.py | 2 +- django/contrib/messages/tests/base.py | 4 +- django/core/management/validation.py | 6 +- django/db/backends/creation.py | 6 +- django/db/models/base.py | 4 +- django/db/models/fields/__init__.py | 4 +- django/db/models/fields/related.py | 4 +- django/template/base.py | 2 +- django/test/testcases.py | 11 +-- django/utils/jslex.py | 4 +- django/views/decorators/debug.py | 5 +- docs/conf.py | 4 +- setup.cfg | 2 +- tests/bulk_create/tests.py | 8 +- tests/cache/tests.py | 2 +- tests/extra_regress/tests.py | 4 +- tests/forms_tests/tests/test_media.py | 92 +++++++++---------- tests/model_regress/tests.py | 2 +- tests/prefetch_related/tests.py | 6 +- tests/serializers/tests.py | 6 +- tests/serializers_regress/tests.py | 28 +++--- tests/signals_regress/tests.py | 6 +- tests/template_tests/filters.py | 16 ++-- tests/test_utils/tests.py | 6 +- 34 files changed, 149 insertions(+), 150 deletions(-) diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py index 6dd25e18f9..377c010b32 100644 --- a/django/conf/global_settings.py +++ b/django/conf/global_settings.py @@ -198,7 +198,7 @@ TEMPLATE_DIRS = () TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', -# 'django.template.loaders.eggs.Loader', + # 'django.template.loaders.eggs.Loader', ) # List of processors used by RequestContext to populate the context. @@ -211,7 +211,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.media', 'django.core.context_processors.static', 'django.core.context_processors.tz', -# 'django.core.context_processors.request', + # 'django.core.context_processors.request', 'django.contrib.messages.context_processors.messages', ) @@ -456,8 +456,8 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', -# 'django.middleware.http.ConditionalGetMiddleware', -# 'django.middleware.gzip.GZipMiddleware', + # 'django.middleware.http.ConditionalGetMiddleware', + # 'django.middleware.gzip.GZipMiddleware', ) ############ @@ -607,7 +607,7 @@ STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', -# 'django.contrib.staticfiles.finders.DefaultStorageFinder', + # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) ############## diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py index 9c5fbf7d8c..5f9d69dee4 100644 --- a/django/contrib/admin/filters.py +++ b/django/contrib/admin/filters.py @@ -166,9 +166,8 @@ class RelatedFieldListFilter(FieldListFilter): rel_name = other_model._meta.pk.name self.lookup_kwarg = '%s__%s__exact' % (field_path, rel_name) self.lookup_kwarg_isnull = '%s__isnull' % field_path - self.lookup_val = request.GET.get(self.lookup_kwarg, None) - self.lookup_val_isnull = request.GET.get( - self.lookup_kwarg_isnull, None) + self.lookup_val = request.GET.get(self.lookup_kwarg) + self.lookup_val_isnull = request.GET.get(self.lookup_kwarg_isnull) self.lookup_choices = field.get_choices(include_blank=False) super(RelatedFieldListFilter, self).__init__( field, request, params, model, model_admin, field_path) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index e27672773c..6d3195a868 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -1198,9 +1198,9 @@ class ModelAdmin(BaseModelAdmin): self.message_user(request, _( 'The %(name)s "%(obj)s" was deleted successfully.') % { - 'name': force_text(opts.verbose_name), - 'obj': force_text(obj_display)}, - messages.SUCCESS) + 'name': force_text(opts.verbose_name), + 'obj': force_text(obj_display) + }, messages.SUCCESS) if self.has_change_permission(request, None): post_url = reverse('admin:%s_%s_changelist' % @@ -1221,10 +1221,10 @@ class ModelAdmin(BaseModelAdmin): return TemplateResponse(request, self.delete_confirmation_template or [ - "admin/{}/{}/delete_confirmation.html".format(app_label, opts.model_name), - "admin/{}/delete_confirmation.html".format(app_label), - "admin/delete_confirmation.html" - ], context, current_app=self.admin_site.name) + "admin/{}/{}/delete_confirmation.html".format(app_label, opts.model_name), + "admin/{}/delete_confirmation.html".format(app_label), + "admin/delete_confirmation.html" + ], context, current_app=self.admin_site.name) @csrf_protect_m @transaction.atomic diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index dbe59f831b..04977eeef8 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -49,9 +49,9 @@ def _is_changelist_popup(request): IS_LEGACY_POPUP_VAR = 'pop' if IS_LEGACY_POPUP_VAR in request.GET: warnings.warn( - "The `%s` GET parameter has been renamed to `%s`." % - (IS_LEGACY_POPUP_VAR, IS_POPUP_VAR), - DeprecationWarning, 2) + "The `%s` GET parameter has been renamed to `%s`." % + (IS_LEGACY_POPUP_VAR, IS_POPUP_VAR), + DeprecationWarning, 2) return True return False diff --git a/django/contrib/auth/tests/test_forms.py b/django/contrib/auth/tests/test_forms.py index fa21d2f917..718e8fff18 100644 --- a/django/contrib/auth/tests/test_forms.py +++ b/django/contrib/auth/tests/test_forms.py @@ -106,7 +106,7 @@ class AuthenticationFormTest(TestCase): self.assertFalse(form.is_valid()) self.assertEqual(form.non_field_errors(), [force_text(form.error_messages['invalid_login'] % { - 'username': User._meta.get_field('username').verbose_name + 'username': User._meta.get_field('username').verbose_name })]) def test_inactive_user(self): diff --git a/django/contrib/auth/tests/test_management.py b/django/contrib/auth/tests/test_management.py index edf433c835..795b72b52e 100644 --- a/django/contrib/auth/tests/test_management.py +++ b/django/contrib/auth/tests/test_management.py @@ -217,7 +217,7 @@ class PermissionTestCase(TestCase): """ # check duplicated default permission models.Permission._meta.permissions = [ - ('change_permission', 'Can edit permission (duplicate)')] + ('change_permission', 'Can edit permission (duplicate)')] six.assertRaisesRegex(self, CommandError, "The permission codename 'change_permission' clashes with a " "builtin permission for model 'auth.Permission'.", diff --git a/django/contrib/formtools/tests/wizard/wizardtests/urls.py b/django/contrib/formtools/tests/wizard/wizardtests/urls.py index dabce5306a..d2e7c575cc 100644 --- a/django/contrib/formtools/tests/wizard/wizardtests/urls.py +++ b/django/contrib/formtools/tests/wizard/wizardtests/urls.py @@ -13,10 +13,10 @@ urlpatterns = patterns('', ('form2', Page2), ('form3', Page3), ('form4', Page4)])), - url(r'^wiz_other_template/$', CookieContactWizard.as_view( - [('form1', Page1), - ('form2', Page2), - ('form3', Page3), - ('form4', Page4)], - template_name='other_wizard_form.html')), + url(r'^wiz_other_template/$', CookieContactWizard.as_view( + [('form1', Page1), + ('form2', Page2), + ('form3', Page3), + ('form4', Page4)], + template_name='other_wizard_form.html')), ) diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py index 0011223617..8c90195f8e 100644 --- a/django/contrib/gis/admin/widgets.py +++ b/django/contrib/gis/admin/widgets.py @@ -36,7 +36,7 @@ class OpenLayersWidget(Textarea): except (GEOSException, ValueError) as err: logger.error( "Error creating geometry from value '%s' (%s)" % ( - value, err) + value, err) ) value = None @@ -68,7 +68,7 @@ class OpenLayersWidget(Textarea): except OGRException as err: logger.error( "Error transforming geometry from srid '%s' to srid '%s' (%s)" % ( - value.srid, srid, err) + value.srid, srid, err) ) wkt = '' else: diff --git a/django/contrib/gis/db/models/__init__.py b/django/contrib/gis/db/models/__init__.py index e36aa36fc2..19e85b1364 100644 --- a/django/contrib/gis/db/models/__init__.py +++ b/django/contrib/gis/db/models/__init__.py @@ -9,6 +9,6 @@ from django.contrib.gis.db.models.manager import GeoManager # The geographic-enabled fields. from django.contrib.gis.db.models.fields import ( - GeometryField, PointField, LineStringField, PolygonField, - MultiPointField, MultiLineStringField, MultiPolygonField, - GeometryCollectionField) + GeometryField, PointField, LineStringField, PolygonField, + MultiPointField, MultiLineStringField, MultiPolygonField, + GeometryCollectionField) diff --git a/django/contrib/gis/forms/widgets.py b/django/contrib/gis/forms/widgets.py index e8322b950c..0b08624cc9 100644 --- a/django/contrib/gis/forms/widgets.py +++ b/django/contrib/gis/forms/widgets.py @@ -43,7 +43,7 @@ class BaseGeometryWidget(Widget): except (GEOSException, ValueError) as err: logger.error( "Error creating geometry from value '%s' (%s)" % ( - value, err) + value, err) ) return None @@ -63,7 +63,7 @@ class BaseGeometryWidget(Widget): except gdal.OGRException as err: logger.error( "Error transforming geometry from srid '%s' to srid '%s' (%s)" % ( - value.srid, self.map_srid, err) + value.srid, self.map_srid, err) ) context = self.build_attrs(attrs, diff --git a/django/contrib/messages/storage/base.py b/django/contrib/messages/storage/base.py index c021fbd2ae..f682a9bbc3 100644 --- a/django/contrib/messages/storage/base.py +++ b/django/contrib/messages/storage/base.py @@ -34,7 +34,7 @@ class Message(object): def __eq__(self, other): return isinstance(other, Message) and self.level == other.level and \ - self.message == other.message + self.message == other.message def __str__(self): return force_text(self.message) diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py index b17883959f..5ed12a7e46 100644 --- a/django/contrib/messages/tests/base.py +++ b/django/contrib/messages/tests/base.py @@ -219,7 +219,7 @@ class BaseTests(object): lambda m:'MessageMiddleware' not in m, settings.MIDDLEWARE_CLASSES), TEMPLATE_CONTEXT_PROCESSORS=filter( lambda p:'context_processors.messages' not in p, - settings.TEMPLATE_CONTEXT_PROCESSORS), + settings.TEMPLATE_CONTEXT_PROCESSORS), MESSAGE_LEVEL=constants.DEBUG ) def test_middleware_disabled(self): @@ -244,7 +244,7 @@ class BaseTests(object): lambda m:'MessageMiddleware' not in m, settings.MIDDLEWARE_CLASSES), TEMPLATE_CONTEXT_PROCESSORS=filter( lambda p:'context_processors.messages' not in p, - settings.TEMPLATE_CONTEXT_PROCESSORS), + settings.TEMPLATE_CONTEXT_PROCESSORS), MESSAGE_LEVEL=constants.DEBUG ) def test_middleware_disabled_fail_silently(self): diff --git a/django/core/management/validation.py b/django/core/management/validation.py index 9beb47e542..4ec421c699 100644 --- a/django/core/management/validation.py +++ b/django/core/management/validation.py @@ -251,9 +251,9 @@ def get_validation_errors(outfile, app=None): "than one foreign key to %s, which is " "ambiguous and is not permitted." % ( f.rel.through._meta.object_name, - from_model._meta.object_name - ) - ) + from_model._meta.object_name + ) + ) else: seen_from = True elif rel_to == to_model: diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py index e4c870c01b..866031447d 100644 --- a/django/db/backends/creation.py +++ b/django/db/backends/creation.py @@ -439,9 +439,9 @@ class BaseDatabaseCreation(object): settings_dict['NAME'] = old_database_name backend = load_backend(settings_dict['ENGINE']) new_connection = backend.DatabaseWrapper( - settings_dict, - alias='__destroy_test_db__', - allow_thread_sharing=False) + settings_dict, + alias='__destroy_test_db__', + allow_thread_sharing=False) new_connection.creation._destroy_test_db(test_database_name, verbosity) def _destroy_test_db(self, test_database_name, verbosity): diff --git a/django/db/models/base.py b/django/db/models/base.py index c7c62ea367..cd872a3559 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -566,8 +566,8 @@ class Model(six.with_metaclass(ModelBase)): deferred_fields = [ f.attname for f in self._meta.fields if f.attname not in self.__dict__ - and isinstance(self.__class__.__dict__[f.attname], - DeferredAttribute)] + and isinstance(self.__class__.__dict__[f.attname], + DeferredAttribute)] loaded_fields = field_names.difference(deferred_fields) if loaded_fields: diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 019714af6e..8fe1c9e4e4 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -704,7 +704,7 @@ class AutoField(Field): def __init__(self, *args, **kwargs): assert kwargs.get('primary_key', False) is True, \ - "%ss must have primary_key=True." % self.__class__.__name__ + "%ss must have primary_key=True." % self.__class__.__name__ kwargs['blank'] = True Field.__init__(self, *args, **kwargs) @@ -746,7 +746,7 @@ class AutoField(Field): def contribute_to_class(self, cls, name): assert not cls._meta.has_auto_field, \ - "A model can't have more than one AutoField." + "A model can't have more than one AutoField." super(AutoField, self).contribute_to_class(cls, name) cls._meta.has_auto_field = True cls._meta.auto_field = self diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 8252cce672..f82fdc91b9 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -1247,8 +1247,8 @@ class ForeignKey(ForeignObject): using = router.db_for_read(model_instance.__class__, instance=model_instance) qs = self.rel.to._default_manager.using(using).filter( - **{self.rel.field_name: value} - ) + **{self.rel.field_name: value} + ) qs = qs.complex_filter(self.rel.limit_choices_to) if not qs.exists(): raise exceptions.ValidationError( diff --git a/django/template/base.py b/django/template/base.py index 39b3bcae5c..b1df21f519 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -515,7 +515,7 @@ filter_raw_string = r""" 'var_chars': "\w\.", 'filter_sep': re.escape(FILTER_SEPARATOR), 'arg_sep': re.escape(FILTER_ARGUMENT_SEPARATOR), - } +} filter_re = re.compile(filter_raw_string, re.UNICODE | re.VERBOSE) diff --git a/django/test/testcases.py b/django/test/testcases.py index 3ce96b09b9..fb6d518427 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -282,8 +282,7 @@ class SimpleTestCase(unittest.TestCase): " response code was %d (expected %d)" % (path, redirect_response.status_code, target_status_code)) - e_scheme, e_netloc, e_path, e_query, e_fragment = urlsplit( - expected_url) + e_scheme, e_netloc, e_path, e_query, e_fragment = urlsplit(expected_url) if not (e_scheme or e_netloc): expected_url = urlunsplit(('http', host or 'testserver', e_path, e_query, e_fragment)) @@ -850,10 +849,10 @@ class TestCase(TransactionTestCase): try: call_command('loaddata', *self.fixtures, **{ - 'verbosity': 0, - 'commit': False, - 'database': db_name, - 'skip_validation': True, + 'verbosity': 0, + 'commit': False, + 'database': db_name, + 'skip_validation': True, }) except Exception: self._fixture_teardown() diff --git a/django/utils/jslex.py b/django/utils/jslex.py index c17d751faa..f042d2e5ee 100644 --- a/django/utils/jslex.py +++ b/django/utils/jslex.py @@ -145,12 +145,12 @@ class JsLexer(Lexer): states = { 'div': # slash will mean division both_before + [ - Tok("punct", literals("/= /"), next='reg'), + Tok("punct", literals("/= /"), next='reg'), ] + both_after, 'reg': # slash will mean regex both_before + [ - Tok("regex", + Tok("regex", r""" / # opening slash # First character is.. diff --git a/django/views/decorators/debug.py b/django/views/decorators/debug.py index a611981e79..318759f052 100644 --- a/django/views/decorators/debug.py +++ b/django/views/decorators/debug.py @@ -65,8 +65,9 @@ def sensitive_post_parameters(*parameters): @functools.wraps(view) def sensitive_post_parameters_wrapper(request, *args, **kwargs): assert isinstance(request, HttpRequest), ( - "sensitive_post_parameters didn't receive an HttpRequest. If you " - "are decorating a classmethod, be sure to use @method_decorator." + "sensitive_post_parameters didn't receive an HttpRequest. " + "If you are decorating a classmethod, be sure to use " + "@method_decorator." ) if parameters: request.sensitive_post_parameters = parameters diff --git a/docs/conf.py b/docs/conf.py index b9e60d0bde..003d89ef24 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -226,8 +226,8 @@ latex_elements = { # (source start file, target name, title, author, document class [howto/manual]). #latex_documents = [] latex_documents = [ - ('contents', 'django.tex', 'Django Documentation', - 'Django Software Foundation', 'manual'), + ('contents', 'django.tex', 'Django Documentation', + 'Django Software Foundation', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/setup.cfg b/setup.cfg index 9cbc9d1ce2..48414caad0 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,E203,E221,E227,E231,E261,E301,E303,E502,F401,F403,F841,W601 +ignore=E123,E124,E125,E126,E127,E128,E225,E226,E241,E251,E302,E501,E203,E221,E227,E231,E261,E301,E303,E502,F401,F403,F841,W601 [metadata] license-file = LICENSE diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py index 94258ca711..dada5326c9 100644 --- a/tests/bulk_create/tests.py +++ b/tests/bulk_create/tests.py @@ -94,8 +94,8 @@ class BulkCreateTests(TestCase): with override_settings(DEBUG=True): connection.queries = [] TwoFields.objects.bulk_create([ - TwoFields(f1=i, f2=i+1) for i in range(0, 1001) - ]) + TwoFields(f1=i, f2=i+1) for i in range(0, 1001) + ]) self.assertEqual(TwoFields.objects.count(), 1001) self.assertEqual( TwoFields.objects.filter(f1__gte=450, f1__lte=550).count(), @@ -115,8 +115,8 @@ class BulkCreateTests(TestCase): with override_settings(DEBUG=True): connection.queries = [] TwoFields.objects.bulk_create([ - TwoFields(f1=i, f2=i+1) for i in range(0, 1001) - ]) + TwoFields(f1=i, f2=i+1) for i in range(0, 1001) + ]) self.assertTrue(len(connection.queries) < 10) def test_large_batch_mixed(self): diff --git a/tests/cache/tests.py b/tests/cache/tests.py index ee6df48b03..a8b23f139d 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -867,7 +867,7 @@ class DBCacheTests(BaseCacheTests, TransactionTestCase): def test_second_call_doesnt_crash(self): stdout = six.StringIO() management.call_command( - 'createcachetable', + 'createcachetable', stdout=stdout ) self.assertEqual(stdout.getvalue(), diff --git a/tests/extra_regress/tests.py b/tests/extra_regress/tests.py index ae8f1b4423..a34c1f5a5f 100644 --- a/tests/extra_regress/tests.py +++ b/tests/extra_regress/tests.py @@ -306,14 +306,14 @@ class ExtraRegressTests(TestCase): self.assertQuerysetEqual( TestObject.objects.filter( - pk__in=TestObject.objects.values('pk').extra(select={'extra': 1}) + pk__in=TestObject.objects.values('pk').extra(select={'extra': 1}) ), [''] ) self.assertQuerysetEqual( TestObject.objects.filter(pk=obj.pk) | - TestObject.objects.extra(where=["id > %s"], params=[obj.pk]), + TestObject.objects.extra(where=["id > %s"], params=[obj.pk]), [''] ) diff --git a/tests/forms_tests/tests/test_media.py b/tests/forms_tests/tests/test_media.py index 7061759bc3..9c175c5c99 100644 --- a/tests/forms_tests/tests/test_media.py +++ b/tests/forms_tests/tests/test_media.py @@ -23,7 +23,7 @@ class FormsMediaTestCase(TestCase): class Foo: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -52,7 +52,7 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -77,21 +77,21 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2','/path/to/css3') } js = ('/path/to/js1','/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -158,7 +158,7 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -185,7 +185,7 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -203,7 +203,7 @@ class FormsMediaTestCase(TestCase): class MyWidget8(MyWidget1): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -222,7 +222,7 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -249,7 +249,7 @@ class FormsMediaTestCase(TestCase): class Media: extend = False css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -264,7 +264,7 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -272,7 +272,7 @@ class FormsMediaTestCase(TestCase): class Media: extend = True css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -290,7 +290,7 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -298,7 +298,7 @@ class FormsMediaTestCase(TestCase): class Media: extend = ('css',) css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -318,9 +318,9 @@ class FormsMediaTestCase(TestCase): class MultimediaWidget(TextInput): class Media: css = { - 'screen, print': ('/file1','/file2'), - 'screen': ('/file3',), - 'print': ('/file4',) + 'screen, print': ('/file1','/file2'), + 'screen': ('/file3',), + 'print': ('/file4',) } js = ('/path/to/js1','/path/to/js4') @@ -340,21 +340,21 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2','/path/to/css3') } js = ('/path/to/js1','/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -382,21 +382,21 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2','/path/to/css3') } js = ('/path/to/js1','/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -474,7 +474,7 @@ class StaticFormsMediaTestCase(TestCase): class Foo: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -503,7 +503,7 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -528,21 +528,21 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2','/path/to/css3') } js = ('/path/to/js1','/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -609,7 +609,7 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -636,7 +636,7 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -654,7 +654,7 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget8(MyWidget1): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -673,7 +673,7 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -700,7 +700,7 @@ class StaticFormsMediaTestCase(TestCase): class Media: extend = False css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -715,7 +715,7 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -723,7 +723,7 @@ class StaticFormsMediaTestCase(TestCase): class Media: extend = True css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -741,7 +741,7 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') @@ -749,7 +749,7 @@ class StaticFormsMediaTestCase(TestCase): class Media: extend = ('css',) css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -769,9 +769,9 @@ class StaticFormsMediaTestCase(TestCase): class MultimediaWidget(TextInput): class Media: css = { - 'screen, print': ('/file1','/file2'), - 'screen': ('/file3',), - 'print': ('/file4',) + 'screen, print': ('/file1','/file2'), + 'screen': ('/file3',), + 'print': ('/file4',) } js = ('/path/to/js1','/path/to/js4') @@ -791,21 +791,21 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2','/path/to/css3') } js = ('/path/to/js1','/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') @@ -833,21 +833,21 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1','/path/to/css2') } js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2','/path/to/css3') } js = ('/path/to/js1','/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3','path/to/css1') } js = ('/path/to/js1','/path/to/js4') diff --git a/tests/model_regress/tests.py b/tests/model_regress/tests.py index a0293975aa..fdb3b1f87c 100644 --- a/tests/model_regress/tests.py +++ b/tests/model_regress/tests.py @@ -131,7 +131,7 @@ class ModelTests(TestCase): datetime.date(1, 3, 3), ], attrgetter("when") - ) + ) if (3,) <= sys.version_info < (3, 3) and connection.vendor == 'mysql': # In Python < 3.3, datetime.strftime raises an exception for years diff --git a/tests/prefetch_related/tests.py b/tests/prefetch_related/tests.py index 6e0b617161..6f51d8d035 100644 --- a/tests/prefetch_related/tests.py +++ b/tests/prefetch_related/tests.py @@ -440,9 +440,9 @@ class ForeignKeyToFieldTest(TestCase): with self.assertNumQueries(3): qs = Author.objects.all().prefetch_related('favorite_authors', 'favors_me') favorites = [( - [six.text_type(i_like) for i_like in author.favorite_authors.all()], - [six.text_type(likes_me) for likes_me in author.favors_me.all()] - ) for author in qs] + [six.text_type(i_like) for i_like in author.favorite_authors.all()], + [six.text_type(likes_me) for likes_me in author.favors_me.all()] + ) for author in qs] self.assertEqual( favorites, [ diff --git a/tests/serializers/tests.py b/tests/serializers/tests.py index 34878adfd2..9b911191a4 100644 --- a/tests/serializers/tests.py +++ b/tests/serializers/tests.py @@ -246,9 +246,9 @@ class SerializersTestBase(object): # Regression for #12524 -- dates before 1000AD get prefixed # 0's on the year a = Article.objects.create( - author = self.jane, - headline = "Nobody remembers the early years", - pub_date = datetime(1, 2, 3, 4, 5, 6)) + author = self.jane, + headline = "Nobody remembers the early years", + pub_date = datetime(1, 2, 3, 4, 5, 6)) serial_str = serializers.serialize(self.serializer_name, [a]) date_values = self._get_field_values(serial_str, "pub_date") diff --git a/tests/serializers_regress/tests.py b/tests/serializers_regress/tests.py index 83561e9c46..a35d7851e0 100644 --- a/tests/serializers_regress/tests.py +++ b/tests/serializers_regress/tests.py @@ -121,13 +121,13 @@ def data_compare(testcase, pk, klass, data): if klass == BinaryData and data is not None: testcase.assertEqual(bytes(data), bytes(instance.data), "Objects with PK=%d not equal; expected '%s' (%s), got '%s' (%s)" % ( - pk, repr(bytes(data)), type(data), repr(bytes(instance.data)), - type(instance.data)) + pk, repr(bytes(data)), type(data), repr(bytes(instance.data)), + type(instance.data)) ) else: testcase.assertEqual(data, instance.data, "Objects with PK=%d not equal; expected '%s' (%s), got '%s' (%s)" % ( - pk, data, type(data), instance, type(instance.data)) + pk, data, type(data), instance, type(instance.data)) ) def generic_compare(testcase, pk, klass, data): @@ -205,7 +205,7 @@ test_data = [ (data_obj, 41, EmailData, None), (data_obj, 42, EmailData, ""), (data_obj, 50, FileData, 'file:///foo/bar/whiz.txt'), -# (data_obj, 51, FileData, None), + # (data_obj, 51, FileData, None), (data_obj, 52, FileData, ""), (data_obj, 60, FilePathData, "/foo/bar/whiz.txt"), (data_obj, 61, FilePathData, None), @@ -308,10 +308,10 @@ The end."""), (pk_obj, 601, BooleanPKData, True), (pk_obj, 602, BooleanPKData, False), (pk_obj, 610, CharPKData, "Test Char PKData"), -# (pk_obj, 620, DatePKData, datetime.date(2006,6,16)), -# (pk_obj, 630, DateTimePKData, datetime.datetime(2006,6,16,10,42,37)), + # (pk_obj, 620, DatePKData, datetime.date(2006,6,16)), + # (pk_obj, 630, DateTimePKData, datetime.datetime(2006,6,16,10,42,37)), (pk_obj, 640, EmailPKData, "hovercraft@example.com"), -# (pk_obj, 650, FilePKData, 'file:///foo/bar/whiz.txt'), + # (pk_obj, 650, FilePKData, 'file:///foo/bar/whiz.txt'), (pk_obj, 660, FilePathPKData, "/foo/bar/whiz.txt"), (pk_obj, 670, DecimalPKData, decimal.Decimal('12.345')), (pk_obj, 671, DecimalPKData, decimal.Decimal('-12.345')), @@ -322,7 +322,7 @@ The end."""), (pk_obj, 680, IntegerPKData, 123456789), (pk_obj, 681, IntegerPKData, -123456789), (pk_obj, 682, IntegerPKData, 0), -# (XX, ImagePKData + # (XX, ImagePKData (pk_obj, 690, IPAddressPKData, "127.0.0.1"), (pk_obj, 695, GenericIPAddressPKData, "fe80:1424:2223:6cff:fe8a:2e8a:2151:abcd"), # (pk_obj, 700, NullBooleanPKData, True), @@ -333,12 +333,12 @@ The end."""), (pk_obj, 750, SmallPKData, 12), (pk_obj, 751, SmallPKData, -12), (pk_obj, 752, SmallPKData, 0), -# (pk_obj, 760, TextPKData, """This is a long piece of text. -# It contains line breaks. -# Several of them. -# The end."""), -# (pk_obj, 770, TimePKData, datetime.time(10,42,37)), -# (pk_obj, 790, XMLPKData, ""), + # (pk_obj, 760, TextPKData, """This is a long piece of text. + # It contains line breaks. + # Several of them. + # The end."""), + # (pk_obj, 770, TimePKData, datetime.time(10,42,37)), + # (pk_obj, 790, XMLPKData, ""), (data_obj, 800, AutoNowDateTimeData, datetime.datetime(2006,6,16,10,42,37)), (data_obj, 810, ModifyingSaveData, 42), diff --git a/tests/signals_regress/tests.py b/tests/signals_regress/tests.py index 328e699b9d..6d15553c26 100644 --- a/tests/signals_regress/tests.py +++ b/tests/signals_regress/tests.py @@ -45,9 +45,9 @@ class SignalsRegressTests(TestCase): # Save up the number of connected signals so that we can check at the end # that all the signals we register get properly unregistered (#9989) self.pre_signals = (len(models.signals.pre_save.receivers), - len(models.signals.post_save.receivers), - len(models.signals.pre_delete.receivers), - len(models.signals.post_delete.receivers)) + len(models.signals.post_save.receivers), + len(models.signals.pre_delete.receivers), + len(models.signals.post_delete.receivers)) models.signals.pre_save.connect(self.pre_save_test) models.signals.post_save.connect(self.post_save_test) diff --git a/tests/template_tests/filters.py b/tests/template_tests/filters.py index 3addec24a7..2845bc9ff6 100644 --- a/tests/template_tests/filters.py +++ b/tests/template_tests/filters.py @@ -371,12 +371,12 @@ def get_filter_tests(): 'time05': (r'{{ d|time:"P:e:O:T:Z" }}', {'d': today}, ''), 'time06': (r'{{ obj|time:"P:e:O:T:Z" }}', {'obj': 'non-datetime-value'}, ''), - # Tests for #11687 and #16676 - 'add01': (r'{{ i|add:"5" }}', {'i': 2000}, '2005'), - 'add02': (r'{{ i|add:"napis" }}', {'i': 2000}, ''), - 'add03': (r'{{ i|add:16 }}', {'i': 'not_an_int'}, ''), - 'add04': (r'{{ i|add:"16" }}', {'i': 'not_an_int'}, 'not_an_int16'), - 'add05': (r'{{ l1|add:l2 }}', {'l1': [1, 2], 'l2': [3, 4]}, '[1, 2, 3, 4]'), - 'add06': (r'{{ t1|add:t2 }}', {'t1': (3, 4), 't2': (1, 2)}, '(3, 4, 1, 2)'), - 'add07': (r'{{ d|add:t }}', {'d': date(2000, 1, 1), 't': timedelta(10)}, 'Jan. 11, 2000'), + # Tests for #11687 and #16676 + 'add01': (r'{{ i|add:"5" }}', {'i': 2000}, '2005'), + 'add02': (r'{{ i|add:"napis" }}', {'i': 2000}, ''), + 'add03': (r'{{ i|add:16 }}', {'i': 'not_an_int'}, ''), + 'add04': (r'{{ i|add:"16" }}', {'i': 'not_an_int'}, 'not_an_int16'), + 'add05': (r'{{ l1|add:l2 }}', {'l1': [1, 2], 'l2': [3, 4]}, '[1, 2, 3, 4]'), + 'add06': (r'{{ t1|add:t2 }}', {'t1': (3, 4), 't2': (1, 2)}, '(3, 4, 1, 2)'), + 'add07': (r'{{ d|add:t }}', {'d': date(2000, 1, 1), 't': timedelta(10)}, 'Jan. 11, 2000'), } diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index 94ba95455b..af2eef6747 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -397,13 +397,13 @@ class HTMLEqualTests(TestCase): def test_complex_examples(self): self.assertHTMLEqual( - """ + """ """, - """ + """ @@ -416,7 +416,7 @@ class HTMLEqualTests(TestCase): """) self.assertHTMLEqual( - """ + """