From e4937b6dde5c30f34c8a65960d7d48b5d7ade356 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Mon, 29 Jul 2013 17:07:50 +0200 Subject: Add utf-8 preamble to admin_scripts temp settings file As some settings are copied from current user settings, we cannot be sure the characters are pure ascii. --- tests/admin_scripts/tests.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/admin_scripts') diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 28f2dcb841..6e1f916996 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -45,6 +45,7 @@ class AdminScriptTestCase(unittest.TestCase): settings_file_path = os.path.join(test_dir, filename) with open(settings_file_path, 'w') as settings_file: + settings_file.write('# -*- coding: utf-8 -*\n') settings_file.write('# Settings file automatically generated by admin_scripts test case\n') exports = [ 'DATABASES', -- cgit v1.3 From 5c1143910e071c73671424036408c4548742d24f Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Mon, 29 Jul 2013 19:19:04 +0200 Subject: Removed most of absolute_import imports Should be unneeded with Python 2.7 and up. Added some unicode_literals along the way. --- django/contrib/admindocs/tests/test_fields.py | 2 +- django/contrib/comments/views/comments.py | 2 -- django/contrib/comments/views/moderation.py | 2 -- django/contrib/formtools/tests/urls.py | 2 -- django/contrib/gis/geoip/__init__.py | 2 -- django/contrib/gis/tests/distapp/tests.py | 2 +- django/contrib/gis/tests/geo3d/tests.py | 2 +- django/contrib/gis/tests/geoadmin/tests.py | 2 +- django/contrib/gis/tests/geoapp/feeds.py | 2 +- django/contrib/gis/tests/geoapp/sitemaps.py | 2 -- django/contrib/gis/tests/geoapp/test_feeds.py | 2 +- django/contrib/gis/tests/geoapp/test_regress.py | 2 +- django/contrib/gis/tests/geoapp/test_sitemaps.py | 2 +- django/contrib/gis/tests/geoapp/tests.py | 2 +- django/contrib/gis/tests/geoapp/urls.py | 2 +- django/contrib/gis/tests/geogapp/tests.py | 2 +- django/contrib/gis/tests/inspectapp/tests.py | 2 +- django/contrib/gis/tests/layermap/tests.py | 2 +- django/contrib/gis/tests/relatedapp/tests.py | 2 +- django/contrib/messages/__init__.py | 2 -- django/core/cache/utils.py | 2 +- django/core/management/utils.py | 2 +- django/core/serializers/json.py | 1 + django/db/models/sql/__init__.py | 2 -- django/db/models/sql/where.py | 2 -- django/forms/__init__.py | 2 -- django/forms/extras/__init__.py | 2 -- django/forms/fields.py | 2 +- django/forms/forms.py | 2 +- django/forms/formsets.py | 2 +- django/forms/models.py | 2 +- django/forms/widgets.py | 2 +- django/http/cookie.py | 2 +- django/http/request.py | 2 +- django/http/response.py | 2 +- django/template/base.py | 2 +- tests/admin_changelist/admin.py | 2 -- tests/admin_changelist/tests.py | 2 +- tests/admin_custom_urls/tests.py | 2 +- tests/admin_docs/urls.py | 3 --- tests/admin_filters/tests.py | 2 +- tests/admin_inlines/admin.py | 2 -- tests/admin_inlines/tests.py | 2 +- tests/admin_inlines/urls.py | 2 -- tests/admin_ordering/tests.py | 2 +- tests/admin_registration/tests.py | 2 +- tests/admin_scripts/complex_app/admin/foo.py | 2 -- tests/admin_scripts/complex_app/models/bar.py | 2 -- tests/admin_scripts/simple_app/models.py | 2 -- tests/admin_util/tests.py | 2 +- tests/admin_validation/tests.py | 9 ++++++--- tests/admin_views/admin.py | 2 +- tests/admin_views/customadmin.py | 2 +- tests/admin_views/tests.py | 2 +- tests/admin_views/urls.py | 2 -- tests/admin_widgets/tests.py | 2 +- tests/admin_widgets/urls.py | 2 -- tests/admin_widgets/widgetadmin.py | 7 +------ tests/aggregation/tests.py | 2 +- tests/aggregation_regress/tests.py | 2 +- tests/app_loading/tests.py | 2 +- tests/backends/tests.py | 2 +- tests/basic/tests.py | 2 +- tests/bug639/tests.py | 2 -- tests/bug8245/admin.py | 2 -- tests/bulk_create/tests.py | 2 +- tests/cache/tests.py | 2 +- tests/choices/tests.py | 2 -- tests/comment_tests/tests/__init__.py | 2 -- tests/comment_tests/tests/test_app_api.py | 2 -- tests/comment_tests/tests/test_comment_form.py | 2 -- tests/comment_tests/tests/test_comment_utils_moderators.py | 2 -- tests/comment_tests/tests/test_comment_view.py | 2 +- tests/comment_tests/tests/test_feeds.py | 2 -- tests/comment_tests/tests/test_models.py | 2 -- tests/comment_tests/tests/test_moderation_views.py | 2 +- tests/comment_tests/tests/test_templatetags.py | 2 -- tests/comment_tests/urls.py | 2 -- tests/conditional_processing/views.py | 3 --- tests/contenttypes_tests/models.py | 2 +- tests/contenttypes_tests/tests.py | 2 +- tests/contenttypes_tests/urls.py | 2 +- tests/context_processors/urls.py | 2 -- tests/custom_columns/tests.py | 2 +- tests/custom_columns_regress/tests.py | 2 +- tests/custom_managers/tests.py | 2 +- tests/custom_managers_regress/tests.py | 2 +- tests/custom_methods/tests.py | 2 +- tests/custom_pk/models.py | 2 +- tests/custom_pk/tests.py | 2 +- tests/datatypes/tests.py | 2 +- tests/dates/tests.py | 2 +- tests/datetimes/tests.py | 2 +- tests/defer/tests.py | 2 +- tests/defer_regress/tests.py | 2 +- tests/delete/tests.py | 2 +- tests/delete_regress/tests.py | 2 +- tests/dispatch/tests/__init__.py | 2 -- tests/distinct_on_fields/tests.py | 2 +- tests/empty/tests.py | 2 -- tests/expressions/tests.py | 2 +- tests/expressions_regress/tests.py | 2 +- tests/extra_regress/tests.py | 2 +- tests/field_defaults/tests.py | 2 -- tests/field_subclassing/models.py | 2 -- tests/field_subclassing/tests.py | 2 +- tests/file_storage/tests.py | 2 +- tests/file_uploads/tests.py | 2 +- tests/file_uploads/urls.py | 2 -- tests/file_uploads/views.py | 2 +- tests/files/tests.py | 2 +- tests/fixtures/tests.py | 2 +- tests/fixtures_regress/models.py | 2 +- tests/fixtures_regress/tests.py | 2 +- tests/force_insert_update/tests.py | 2 +- tests/forms_tests/tests/__init__.py | 2 -- tests/forms_tests/tests/test_error_messages.py | 2 +- tests/forms_tests/tests/test_extra.py | 2 +- tests/forms_tests/tests/tests.py | 2 +- tests/generic_inline_admin/admin.py | 2 -- tests/generic_inline_admin/tests.py | 2 +- tests/generic_inline_admin/urls.py | 2 -- tests/generic_relations/tests.py | 2 +- tests/generic_views/test_base.py | 2 +- tests/generic_views/test_dates.py | 2 +- tests/generic_views/test_detail.py | 2 +- tests/generic_views/test_edit.py | 2 +- tests/generic_views/test_forms.py | 2 +- tests/generic_views/test_list.py | 2 +- tests/generic_views/urls.py | 2 -- tests/generic_views/views.py | 2 +- tests/get_earliest_or_latest/tests.py | 2 +- tests/get_object_or_404/tests.py | 4 ++-- tests/get_or_create/tests.py | 4 ++-- tests/get_or_create_regress/tests.py | 2 +- tests/i18n/forms.py | 2 -- tests/i18n/tests.py | 2 +- tests/inline_formsets/tests.py | 2 +- tests/introspection/tests.py | 2 +- tests/known_related_objects/tests.py | 2 +- tests/lookup/tests.py | 2 +- tests/m2m_and_m2o/tests.py | 2 -- tests/m2m_intermediary/tests.py | 2 +- tests/m2m_multiple/tests.py | 2 +- tests/m2m_recursive/tests.py | 2 +- tests/m2m_regress/tests.py | 2 +- tests/m2m_signals/tests.py | 2 -- tests/m2m_through/tests.py | 2 +- tests/m2m_through_regress/tests.py | 2 +- tests/m2o_recursive/tests.py | 2 +- tests/managers_regress/tests.py | 2 +- tests/many_to_many/tests.py | 2 +- tests/many_to_one/tests.py | 2 -- tests/many_to_one_null/tests.py | 2 +- tests/many_to_one_regress/tests.py | 2 +- tests/max_lengths/tests.py | 2 +- tests/middleware/tests.py | 2 +- tests/middleware_exceptions/urls.py | 3 --- tests/model_fields/test_imagefield.py | 2 +- tests/model_fields/tests.py | 2 +- tests/model_forms/tests.py | 2 +- tests/model_forms_regress/tests.py | 2 +- tests/model_formsets/tests.py | 2 +- tests/model_formsets_regress/tests.py | 2 +- tests/model_inheritance/tests.py | 2 +- tests/model_inheritance_regress/tests.py | 2 +- tests/model_inheritance_same_model_name/models.py | 2 -- tests/model_inheritance_same_model_name/tests.py | 2 +- tests/model_inheritance_select_related/tests.py | 2 +- tests/model_package/models/__init__.py | 2 -- tests/model_package/tests.py | 2 +- tests/model_permalink/tests.py | 2 -- tests/model_regress/tests.py | 2 +- tests/modeladmin/tests.py | 2 +- tests/multiple_database/models.py | 2 -- tests/multiple_database/tests.py | 2 +- tests/mutually_referential/tests.py | 2 -- tests/nested_foreign_keys/tests.py | 3 ++- tests/null_fk/tests.py | 2 +- tests/null_fk_ordering/tests.py | 2 +- tests/null_queries/tests.py | 2 +- tests/one_to_one/tests.py | 2 +- tests/one_to_one_regress/tests.py | 2 +- tests/or_lookups/tests.py | 2 +- tests/order_with_respect_to/tests.py | 2 +- tests/ordering/tests.py | 2 +- tests/pagination/tests.py | 2 +- tests/prefetch_related/tests.py | 2 +- tests/properties/tests.py | 2 +- tests/proxy_model_inheritance/app1/models.py | 2 -- tests/proxy_model_inheritance/tests.py | 2 +- tests/proxy_models/tests.py | 2 +- tests/queries/tests.py | 2 +- tests/queryset_pickle/models.py | 2 -- tests/queryset_pickle/tests.py | 4 ++-- tests/raw_query/tests.py | 2 +- tests/reserved_names/tests.py | 2 +- tests/reverse_lookup/tests.py | 2 +- tests/reverse_single_related/tests.py | 2 -- tests/save_delete_hooks/tests.py | 2 +- tests/select_for_update/tests.py | 2 +- tests/select_related/tests.py | 2 +- tests/select_related_onetoone/tests.py | 2 +- tests/select_related_regress/tests.py | 2 +- tests/serializers/tests.py | 4 ++-- tests/serializers_regress/tests.py | 2 +- tests/servers/urls.py | 2 -- tests/signals/tests.py | 2 +- tests/signals_regress/tests.py | 2 +- tests/sites_framework/tests.py | 2 -- tests/str/tests.py | 2 +- tests/string_lookup/tests.py | 4 ++-- tests/swappable_models/tests.py | 2 +- tests/syndication/feeds.py | 2 +- tests/syndication/tests.py | 2 +- tests/syndication/urls.py | 2 -- tests/tablespaces/tests.py | 2 +- tests/template_tests/alternate_urls.py | 4 ---- tests/template_tests/test_custom.py | 2 +- tests/template_tests/tests.py | 2 +- tests/template_tests/urls.py | 2 +- tests/test_client/tests.py | 2 +- tests/test_client/urls.py | 2 -- tests/test_client_regress/urls.py | 2 -- tests/test_runner/tests.py | 2 +- tests/test_utils/tests.py | 2 +- tests/test_utils/urls.py | 2 -- tests/test_utils/views.py | 4 +--- tests/timezones/admin.py | 2 -- tests/timezones/urls.py | 2 -- tests/transactions/tests.py | 2 +- tests/transactions_regress/tests.py | 2 +- tests/unmanaged_models/tests.py | 2 +- tests/update/tests.py | 2 +- tests/update_only_fields/tests.py | 2 +- tests/urlpatterns_reverse/extra_urls.py | 2 -- tests/urlpatterns_reverse/included_named_urls.py | 2 -- tests/urlpatterns_reverse/included_named_urls2.py | 2 -- tests/urlpatterns_reverse/included_namespace_urls.py | 2 -- tests/urlpatterns_reverse/included_urls.py | 2 -- tests/urlpatterns_reverse/included_urls2.py | 2 -- tests/urlpatterns_reverse/middleware.py | 2 -- tests/urlpatterns_reverse/named_urls.py | 2 -- tests/urlpatterns_reverse/namespace_urls.py | 2 -- tests/urlpatterns_reverse/reverse_lazy_urls.py | 2 -- tests/urlpatterns_reverse/tests.py | 2 +- tests/urlpatterns_reverse/urlconf_outer.py | 4 +--- tests/urlpatterns_reverse/urls.py | 2 -- tests/urlpatterns_reverse/urls_error_handlers_callables.py | 2 -- tests/urlpatterns_reverse/urls_without_full_import.py | 2 -- tests/utils_tests/test_safestring.py | 3 +-- tests/validation/test_custom_messages.py | 2 -- tests/validation/test_unique.py | 2 +- tests/validation/test_validators.py | 2 +- tests/validation/tests.py | 2 +- tests/view_tests/generic_urls.py | 2 +- tests/view_tests/templatetags/debugtags.py | 2 -- tests/view_tests/tests/__init__.py | 2 -- tests/view_tests/tests/test_debug.py | 2 +- tests/view_tests/tests/test_defaults.py | 2 +- tests/view_tests/tests/test_i18n.py | 2 -- tests/view_tests/tests/test_static.py | 2 +- tests/view_tests/urls.py | 2 -- tests/view_tests/views.py | 2 +- 264 files changed, 194 insertions(+), 366 deletions(-) (limited to 'tests/admin_scripts') diff --git a/django/contrib/admindocs/tests/test_fields.py b/django/contrib/admindocs/tests/test_fields.py index b505d2deeb..e8fe0b0caa 100644 --- a/django/contrib/admindocs/tests/test_fields.py +++ b/django/contrib/admindocs/tests/test_fields.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import unittest diff --git a/django/contrib/comments/views/comments.py b/django/contrib/comments/views/comments.py index befd326092..a2cbe33c0e 100644 --- a/django/contrib/comments/views/comments.py +++ b/django/contrib/comments/views/comments.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django import http from django.conf import settings from django.contrib import comments diff --git a/django/contrib/comments/views/moderation.py b/django/contrib/comments/views/moderation.py index 31bb98fa63..484ceac02c 100644 --- a/django/contrib/comments/views/moderation.py +++ b/django/contrib/comments/views/moderation.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django import template from django.conf import settings from django.contrib import comments diff --git a/django/contrib/formtools/tests/urls.py b/django/contrib/formtools/tests/urls.py index f96f89ecdf..c86a7408e0 100644 --- a/django/contrib/formtools/tests/urls.py +++ b/django/contrib/formtools/tests/urls.py @@ -2,8 +2,6 @@ This is a URLconf to be loaded by tests.py. Add any URLs needed for tests only. """ -from __future__ import absolute_import - from django.conf.urls import patterns, url from django.contrib.formtools.tests.tests import TestFormPreview diff --git a/django/contrib/gis/geoip/__init__.py b/django/contrib/gis/geoip/__init__.py index 8b519a242d..c42dd2c72b 100644 --- a/django/contrib/gis/geoip/__init__.py +++ b/django/contrib/gis/geoip/__init__.py @@ -11,8 +11,6 @@ Grab GeoIP.dat.gz and GeoLiteCity.dat.gz, and unzip them in the directory corresponding to settings.GEOIP_PATH. """ -from __future__ import absolute_import - try: from .base import GeoIP, GeoIPException HAS_GEOIP = True diff --git a/django/contrib/gis/tests/distapp/tests.py b/django/contrib/gis/tests/distapp/tests.py index 8915f01e50..5e74225f91 100644 --- a/django/contrib/gis/tests/distapp/tests.py +++ b/django/contrib/gis/tests/distapp/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from unittest import skipUnless diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py index 6c17003982..6fdf67042b 100644 --- a/django/contrib/gis/tests/geo3d/tests.py +++ b/django/contrib/gis/tests/geo3d/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import os import re diff --git a/django/contrib/gis/tests/geoadmin/tests.py b/django/contrib/gis/tests/geoadmin/tests.py index df4158bb31..295c1de46f 100644 --- a/django/contrib/gis/tests/geoadmin/tests.py +++ b/django/contrib/gis/tests/geoadmin/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from unittest import skipUnless diff --git a/django/contrib/gis/tests/geoapp/feeds.py b/django/contrib/gis/tests/geoapp/feeds.py index f53431c24d..9ec959ecce 100644 --- a/django/contrib/gis/tests/geoapp/feeds.py +++ b/django/contrib/gis/tests/geoapp/feeds.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib.gis import feeds diff --git a/django/contrib/gis/tests/geoapp/sitemaps.py b/django/contrib/gis/tests/geoapp/sitemaps.py index 0e85fda662..55bf7c764c 100644 --- a/django/contrib/gis/tests/geoapp/sitemaps.py +++ b/django/contrib/gis/tests/geoapp/sitemaps.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib.gis.sitemaps import GeoRSSSitemap, KMLSitemap, KMZSitemap from .feeds import feed_dict diff --git a/django/contrib/gis/tests/geoapp/test_feeds.py b/django/contrib/gis/tests/geoapp/test_feeds.py index b2953b4a70..9c7b572e99 100644 --- a/django/contrib/gis/tests/geoapp/test_feeds.py +++ b/django/contrib/gis/tests/geoapp/test_feeds.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from unittest import skipUnless from xml.dom import minidom diff --git a/django/contrib/gis/tests/geoapp/test_regress.py b/django/contrib/gis/tests/geoapp/test_regress.py index 2ffbaec9a9..844f03aef5 100644 --- a/django/contrib/gis/tests/geoapp/test_regress.py +++ b/django/contrib/gis/tests/geoapp/test_regress.py @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from datetime import datetime from unittest import skipUnless diff --git a/django/contrib/gis/tests/geoapp/test_sitemaps.py b/django/contrib/gis/tests/geoapp/test_sitemaps.py index 98cd8cc5ac..bb68039bc3 100644 --- a/django/contrib/gis/tests/geoapp/test_sitemaps.py +++ b/django/contrib/gis/tests/geoapp/test_sitemaps.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from io import BytesIO from unittest import skipUnless diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py index eabc5958c0..9221f99285 100644 --- a/django/contrib/gis/tests/geoapp/tests.py +++ b/django/contrib/gis/tests/geoapp/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import re import unittest diff --git a/django/contrib/gis/tests/geoapp/urls.py b/django/contrib/gis/tests/geoapp/urls.py index 55a5fa3670..70db62d71b 100644 --- a/django/contrib/gis/tests/geoapp/urls.py +++ b/django/contrib/gis/tests/geoapp/urls.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.conf.urls import patterns diff --git a/django/contrib/gis/tests/geogapp/tests.py b/django/contrib/gis/tests/geogapp/tests.py index 2a60f623fa..bc809bdfc0 100644 --- a/django/contrib/gis/tests/geogapp/tests.py +++ b/django/contrib/gis/tests/geogapp/tests.py @@ -1,7 +1,7 @@ """ Tests for geography support in PostGIS 1.5+ """ -from __future__ import absolute_import +from __future__ import unicode_literals import os from unittest import skipUnless diff --git a/django/contrib/gis/tests/inspectapp/tests.py b/django/contrib/gis/tests/inspectapp/tests.py index 34dab1ab7d..4b7c5ff21d 100644 --- a/django/contrib/gis/tests/inspectapp/tests.py +++ b/django/contrib/gis/tests/inspectapp/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import os from unittest import skipUnless diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py index c4c27b353e..86b15b24d4 100644 --- a/django/contrib/gis/tests/layermap/tests.py +++ b/django/contrib/gis/tests/layermap/tests.py @@ -1,5 +1,5 @@ # coding: utf-8 -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from copy import copy from decimal import Decimal diff --git a/django/contrib/gis/tests/relatedapp/tests.py b/django/contrib/gis/tests/relatedapp/tests.py index 653bda8aaf..83da000f82 100644 --- a/django/contrib/gis/tests/relatedapp/tests.py +++ b/django/contrib/gis/tests/relatedapp/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from unittest import skipUnless diff --git a/django/contrib/messages/__init__.py b/django/contrib/messages/__init__.py index 68a53d996f..a835f29dc9 100644 --- a/django/contrib/messages/__init__.py +++ b/django/contrib/messages/__init__.py @@ -1,4 +1,2 @@ -from __future__ import absolute_import - from django.contrib.messages.api import * from django.contrib.messages.constants import * diff --git a/django/core/cache/utils.py b/django/core/cache/utils.py index 4310825ad4..b9806cc5e0 100644 --- a/django/core/cache/utils.py +++ b/django/core/cache/utils.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import hashlib from django.utils.encoding import force_bytes diff --git a/django/core/management/utils.py b/django/core/management/utils.py index 7159d1123f..d1052d5182 100644 --- a/django/core/management/utils.py +++ b/django/core/management/utils.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import os from subprocess import PIPE, Popen diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py index 64357bf9d5..b07aa3392c 100644 --- a/django/core/serializers/json.py +++ b/django/core/serializers/json.py @@ -4,6 +4,7 @@ Serialize data to/from JSON # Avoid shadowing the standard library json module from __future__ import absolute_import +from __future__ import unicode_literals import datetime import decimal diff --git a/django/db/models/sql/__init__.py b/django/db/models/sql/__init__.py index df5b74e326..8bc60c1d10 100644 --- a/django/db/models/sql/__init__.py +++ b/django/db/models/sql/__init__.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.db.models.sql.datastructures import EmptyResultSet from django.db.models.sql.subqueries import * from django.db.models.sql.query import * diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py index 2e83ecdce4..7b71580370 100644 --- a/django/db/models/sql/where.py +++ b/django/db/models/sql/where.py @@ -2,8 +2,6 @@ Code to manage the creation and SQL rendering of 'where' constraints. """ -from __future__ import absolute_import - import collections import datetime from itertools import repeat diff --git a/django/forms/__init__.py b/django/forms/__init__.py index 2588098330..34896d948d 100644 --- a/django/forms/__init__.py +++ b/django/forms/__init__.py @@ -2,8 +2,6 @@ Django validation and HTML form handling. """ -from __future__ import absolute_import - from django.core.exceptions import ValidationError from django.forms.fields import * from django.forms.forms import * diff --git a/django/forms/extras/__init__.py b/django/forms/extras/__init__.py index d801e4fa80..28316f472c 100644 --- a/django/forms/extras/__init__.py +++ b/django/forms/extras/__init__.py @@ -1,3 +1 @@ -from __future__ import absolute_import - from django.forms.extras.widgets import * diff --git a/django/forms/fields.py b/django/forms/fields.py index a794c02e9f..de0c620ed0 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -2,7 +2,7 @@ Field classes. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import copy import datetime diff --git a/django/forms/forms.py b/django/forms/forms.py index ad5daf4416..31e51e7c34 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -2,7 +2,7 @@ Form classes """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import copy import warnings diff --git a/django/forms/formsets.py b/django/forms/formsets.py index cb3126e6d7..8a379ff3cf 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.core.exceptions import ValidationError from django.forms import Form diff --git a/django/forms/models.py b/django/forms/models.py index 2d1ec96306..83954b0b22 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -3,7 +3,7 @@ Helper functions for creating Form classes from Django models and database field objects. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import warnings diff --git a/django/forms/widgets.py b/django/forms/widgets.py index a92e5a56ce..8a351bb637 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -2,7 +2,7 @@ HTML Widget classes """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import copy from itertools import chain diff --git a/django/http/cookie.py b/django/http/cookie.py index 50ff549caf..62d5c61a4d 100644 --- a/django/http/cookie.py +++ b/django/http/cookie.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.utils.encoding import force_str from django.utils import six diff --git a/django/http/request.py b/django/http/request.py index b7f9d241a7..e222081450 100644 --- a/django/http/request.py +++ b/django/http/request.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import copy import os diff --git a/django/http/response.py b/django/http/response.py index 1f0849c0bf..07bbd32eeb 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime import time diff --git a/django/template/base.py b/django/template/base.py index aa82d8911a..ed4196012a 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import re from functools import partial diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py index 175b1972c9..db836cdf7d 100644 --- a/tests/admin_changelist/admin.py +++ b/tests/admin_changelist/admin.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib import admin from django.core.paginator import Paginator diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index fb72f60b7c..a65de46490 100644 --- a/tests/admin_changelist/tests.py +++ b/tests/admin_changelist/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime diff --git a/tests/admin_custom_urls/tests.py b/tests/admin_custom_urls/tests.py index 31c93410f4..257638afb1 100644 --- a/tests/admin_custom_urls/tests.py +++ b/tests/admin_custom_urls/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import warnings from django.contrib.admin.util import quote diff --git a/tests/admin_docs/urls.py b/tests/admin_docs/urls.py index 3c3a8fe5d8..914b4836e0 100644 --- a/tests/admin_docs/urls.py +++ b/tests/admin_docs/urls.py @@ -1,6 +1,3 @@ -# coding: utf-8 -from __future__ import absolute_import - from django.conf.urls import patterns from . import views diff --git a/tests/admin_filters/tests.py b/tests/admin_filters/tests.py index f05e8e2011..5e6b122fec 100644 --- a/tests/admin_filters/tests.py +++ b/tests/admin_filters/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime diff --git a/tests/admin_inlines/admin.py b/tests/admin_inlines/admin.py index 62f9e04e5b..c69800851a 100644 --- a/tests/admin_inlines/admin.py +++ b/tests/admin_inlines/admin.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib import admin from django import forms diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py index 465b224d4f..f62a0c1e01 100644 --- a/tests/admin_inlines/tests.py +++ b/tests/admin_inlines/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.contrib.admin.tests import AdminSeleniumWebDriverTestCase from django.contrib.admin.helpers import InlineAdminForm diff --git a/tests/admin_inlines/urls.py b/tests/admin_inlines/urls.py index cf18ef97cf..a5d927e20b 100644 --- a/tests/admin_inlines/urls.py +++ b/tests/admin_inlines/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, include from . import admin diff --git a/tests/admin_ordering/tests.py b/tests/admin_ordering/tests.py index 6655ad37ad..763e97bd72 100644 --- a/tests/admin_ordering/tests.py +++ b/tests/admin_ordering/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.test import TestCase, RequestFactory from django.contrib import admin diff --git a/tests/admin_registration/tests.py b/tests/admin_registration/tests.py index 1b2d291691..0e444fd2af 100644 --- a/tests/admin_registration/tests.py +++ b/tests/admin_registration/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import admin from django.core.exceptions import ImproperlyConfigured diff --git a/tests/admin_scripts/complex_app/admin/foo.py b/tests/admin_scripts/complex_app/admin/foo.py index 1ed704a66b..09ceba05aa 100644 --- a/tests/admin_scripts/complex_app/admin/foo.py +++ b/tests/admin_scripts/complex_app/admin/foo.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib import admin from ..models.foo import Foo diff --git a/tests/admin_scripts/complex_app/models/bar.py b/tests/admin_scripts/complex_app/models/bar.py index 15956f7a50..92f1b98694 100644 --- a/tests/admin_scripts/complex_app/models/bar.py +++ b/tests/admin_scripts/complex_app/models/bar.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.db import models from ..admin import foo diff --git a/tests/admin_scripts/simple_app/models.py b/tests/admin_scripts/simple_app/models.py index b89f4b898b..e5b9e297c5 100644 --- a/tests/admin_scripts/simple_app/models.py +++ b/tests/admin_scripts/simple_app/models.py @@ -1,3 +1 @@ -from __future__ import absolute_import - from ..complex_app.models.bar import Bar diff --git a/tests/admin_util/tests.py b/tests/admin_util/tests.py index 4a9a203f50..8c63e90ce1 100644 --- a/tests/admin_util/tests.py +++ b/tests/admin_util/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from datetime import datetime diff --git a/tests/admin_validation/tests.py b/tests/admin_validation/tests.py index 5eee3e7105..39e74a945c 100644 --- a/tests/admin_validation/tests.py +++ b/tests/admin_validation/tests.py @@ -1,9 +1,10 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django import forms from django.contrib import admin from django.core.exceptions import ImproperlyConfigured from django.test import TestCase +from django.test.utils import str_prefix from .models import Song, Book, Album, TwoAlbumFKAndAnE, State, City @@ -185,7 +186,8 @@ class ValidationTestCase(TestCase): readonly_fields = ("title", "nonexistant") self.assertRaisesMessage(ImproperlyConfigured, - "SongAdmin.readonly_fields[1], 'nonexistant' is not a callable or an attribute of 'SongAdmin' or found in the model 'Song'.", + str_prefix("SongAdmin.readonly_fields[1], %(_)s'nonexistant' is not a callable " + "or an attribute of 'SongAdmin' or found in the model 'Song'."), SongAdmin.validate, Song) @@ -195,7 +197,8 @@ class ValidationTestCase(TestCase): readonly_fields=['i_dont_exist'] # Missing attribute self.assertRaisesMessage(ImproperlyConfigured, - "CityInline.readonly_fields[0], 'i_dont_exist' is not a callable or an attribute of 'CityInline' or found in the model 'City'.", + str_prefix("CityInline.readonly_fields[0], %(_)s'i_dont_exist' is not a callable " + "or an attribute of 'CityInline' or found in the model 'City'."), CityInline.validate, City) diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index 039abb819b..df8ced949e 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import tempfile import os diff --git a/tests/admin_views/customadmin.py b/tests/admin_views/customadmin.py index c204b81edd..ed3a3dea7a 100644 --- a/tests/admin_views/customadmin.py +++ b/tests/admin_views/customadmin.py @@ -1,7 +1,7 @@ """ A second, custom AdminSite -- see tests.CustomAdminSiteTests. """ -from __future__ import absolute_import +from __future__ import unicode_literals from django.conf.urls import patterns from django.contrib import admin diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 80fdb90402..19c5207cf9 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1,5 +1,5 @@ # coding: utf-8 -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import os import re diff --git a/tests/admin_views/urls.py b/tests/admin_views/urls.py index 763c83a450..d934173234 100644 --- a/tests/admin_views/urls.py +++ b/tests/admin_views/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, include from . import views, customadmin, admin diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py index e8d4e5276b..c083c7cb9c 100644 --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -1,5 +1,5 @@ # encoding: utf-8 -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from datetime import datetime, timedelta from unittest import TestCase diff --git a/tests/admin_widgets/urls.py b/tests/admin_widgets/urls.py index aecee90b7f..3da5d25bc8 100644 --- a/tests/admin_widgets/urls.py +++ b/tests/admin_widgets/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, include from . import widgetadmin diff --git a/tests/admin_widgets/widgetadmin.py b/tests/admin_widgets/widgetadmin.py index 1cdeeb9f67..b7023fc81c 100644 --- a/tests/admin_widgets/widgetadmin.py +++ b/tests/admin_widgets/widgetadmin.py @@ -1,8 +1,3 @@ -""" - -""" -from __future__ import absolute_import - from django.contrib import admin from . import models @@ -47,4 +42,4 @@ site.register(models.Bee) site.register(models.Advisor) -site.register(models.School, SchoolAdmin) \ No newline at end of file +site.register(models.School, SchoolAdmin) diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index dd7e994a63..e1a880585f 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import datetime from decimal import Decimal diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index 35ac57d9be..0838cb8fe8 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime import pickle diff --git a/tests/app_loading/tests.py b/tests/app_loading/tests.py index e0c7cbd78c..bba2b234a2 100644 --- a/tests/app_loading/tests.py +++ b/tests/app_loading/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import copy import os diff --git a/tests/backends/tests.py b/tests/backends/tests.py index ec592f0188..2ad2e1d6d5 100644 --- a/tests/backends/tests.py +++ b/tests/backends/tests.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Unit and doctests for specific database backends. -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime from decimal import Decimal diff --git a/tests/basic/tests.py b/tests/basic/tests.py index 9d4490afc6..879c7869fa 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from datetime import datetime import threading diff --git a/tests/bug639/tests.py b/tests/bug639/tests.py index 71c50e14aa..769d27d2f0 100644 --- a/tests/bug639/tests.py +++ b/tests/bug639/tests.py @@ -4,8 +4,6 @@ gets called *again* for each FileField. This test will fail if calling a ModelForm's save() method causes Model.save() to be called more than once. """ -from __future__ import absolute_import - import os import shutil import unittest diff --git a/tests/bug8245/admin.py b/tests/bug8245/admin.py index d821190763..e7d1a080c2 100644 --- a/tests/bug8245/admin.py +++ b/tests/bug8245/admin.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib import admin from .models import Story diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py index d4772934a1..94258ca711 100644 --- a/tests/bulk_create/tests.py +++ b/tests/bulk_create/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from operator import attrgetter diff --git a/tests/cache/tests.py b/tests/cache/tests.py index bccac6b5a8..a225666521 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -2,7 +2,7 @@ # Unit tests for cache framework # Uses whatever cache backend is set in the test settings file. -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import hashlib import os diff --git a/tests/choices/tests.py b/tests/choices/tests.py index 03a7d3340d..2d612626c2 100644 --- a/tests/choices/tests.py +++ b/tests/choices/tests.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.test import TestCase from .models import Person diff --git a/tests/comment_tests/tests/__init__.py b/tests/comment_tests/tests/__init__.py index ae4585e187..6cbddbe82b 100644 --- a/tests/comment_tests/tests/__init__.py +++ b/tests/comment_tests/tests/__init__.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib.auth.models import User from django.contrib.comments.forms import CommentForm from django.contrib.comments.models import Comment diff --git a/tests/comment_tests/tests/test_app_api.py b/tests/comment_tests/tests/test_app_api.py index ed23ba39cc..83ee868a02 100644 --- a/tests/comment_tests/tests/test_app_api.py +++ b/tests/comment_tests/tests/test_app_api.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf import settings from django.contrib import comments from django.contrib.comments.models import Comment diff --git a/tests/comment_tests/tests/test_comment_form.py b/tests/comment_tests/tests/test_comment_form.py index a30f13a073..bca339fd3d 100644 --- a/tests/comment_tests/tests/test_comment_form.py +++ b/tests/comment_tests/tests/test_comment_form.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import time from django.conf import settings diff --git a/tests/comment_tests/tests/test_comment_utils_moderators.py b/tests/comment_tests/tests/test_comment_utils_moderators.py index 6c7a882e25..e61be48d8b 100644 --- a/tests/comment_tests/tests/test_comment_utils_moderators.py +++ b/tests/comment_tests/tests/test_comment_utils_moderators.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib.comments.models import Comment from django.contrib.comments.moderation import (moderator, CommentModerator, AlreadyModerated) diff --git a/tests/comment_tests/tests/test_comment_view.py b/tests/comment_tests/tests/test_comment_view.py index 0d994d3af8..19d7c1d16b 100644 --- a/tests/comment_tests/tests/test_comment_view.py +++ b/tests/comment_tests/tests/test_comment_view.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import re diff --git a/tests/comment_tests/tests/test_feeds.py b/tests/comment_tests/tests/test_feeds.py index 941ffb6bf2..e6652afa28 100644 --- a/tests/comment_tests/tests/test_feeds.py +++ b/tests/comment_tests/tests/test_feeds.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from xml.etree import ElementTree as ET from django.conf import settings diff --git a/tests/comment_tests/tests/test_models.py b/tests/comment_tests/tests/test_models.py index 69c1a8118f..4303fda852 100644 --- a/tests/comment_tests/tests/test_models.py +++ b/tests/comment_tests/tests/test_models.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib.comments.models import Comment from . import CommentTestCase diff --git a/tests/comment_tests/tests/test_moderation_views.py b/tests/comment_tests/tests/test_moderation_views.py index 02af35cfe4..9f826f5866 100644 --- a/tests/comment_tests/tests/test_moderation_views.py +++ b/tests/comment_tests/tests/test_moderation_views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.contrib.auth.models import User, Permission from django.contrib.comments import signals diff --git a/tests/comment_tests/tests/test_templatetags.py b/tests/comment_tests/tests/test_templatetags.py index 1971c21a58..d24859eb55 100644 --- a/tests/comment_tests/tests/test_templatetags.py +++ b/tests/comment_tests/tests/test_templatetags.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib.comments.forms import CommentForm from django.contrib.comments.models import Comment from django.contrib.contenttypes.models import ContentType diff --git a/tests/comment_tests/urls.py b/tests/comment_tests/urls.py index 0a7e8b5fdf..32106106b5 100644 --- a/tests/comment_tests/urls.py +++ b/tests/comment_tests/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url from django.contrib.comments.feeds import LatestCommentFeed diff --git a/tests/conditional_processing/views.py b/tests/conditional_processing/views.py index 14a5a83a45..d4dc4b8cf6 100644 --- a/tests/conditional_processing/views.py +++ b/tests/conditional_processing/views.py @@ -1,6 +1,3 @@ -# -*- coding:utf-8 -*- -from __future__ import absolute_import - from django.views.decorators.http import condition, etag, last_modified from django.http import HttpResponse diff --git a/tests/contenttypes_tests/models.py b/tests/contenttypes_tests/models.py index 3c6685687a..5d21ad5b96 100644 --- a/tests/contenttypes_tests/models.py +++ b/tests/contenttypes_tests/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.db import models from django.utils.encoding import python_2_unicode_compatible diff --git a/tests/contenttypes_tests/tests.py b/tests/contenttypes_tests/tests.py index b39e118ec6..63f02697df 100644 --- a/tests/contenttypes_tests/tests.py +++ b/tests/contenttypes_tests/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.contrib.contenttypes.models import ContentType from django.test import TestCase diff --git a/tests/contenttypes_tests/urls.py b/tests/contenttypes_tests/urls.py index 2cfc90b024..626b3ae8f7 100644 --- a/tests/contenttypes_tests/urls.py +++ b/tests/contenttypes_tests/urls.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.conf.urls import patterns diff --git a/tests/context_processors/urls.py b/tests/context_processors/urls.py index 757017c9ca..9340cdfc38 100644 --- a/tests/context_processors/urls.py +++ b/tests/context_processors/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url from . import views diff --git a/tests/custom_columns/tests.py b/tests/custom_columns/tests.py index 51028b0c46..155279297f 100644 --- a/tests/custom_columns/tests.py +++ b/tests/custom_columns/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.core.exceptions import FieldError from django.test import TestCase diff --git a/tests/custom_columns_regress/tests.py b/tests/custom_columns_regress/tests.py index 7cc66ca2a6..034de08d45 100644 --- a/tests/custom_columns_regress/tests.py +++ b/tests/custom_columns_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.core.exceptions import FieldError from django.test import TestCase diff --git a/tests/custom_managers/tests.py b/tests/custom_managers/tests.py index 5ab58b534a..87e5a721bc 100644 --- a/tests/custom_managers/tests.py +++ b/tests/custom_managers/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase from django.utils import six diff --git a/tests/custom_managers_regress/tests.py b/tests/custom_managers_regress/tests.py index 5a9cd91d59..8462e526c9 100644 --- a/tests/custom_managers_regress/tests.py +++ b/tests/custom_managers_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase diff --git a/tests/custom_methods/tests.py b/tests/custom_methods/tests.py index 9d7444ba62..addb61d4c1 100644 --- a/tests/custom_methods/tests.py +++ b/tests/custom_methods/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from datetime import date diff --git a/tests/custom_pk/models.py b/tests/custom_pk/models.py index 5ef9b69f0c..8d5065aed8 100644 --- a/tests/custom_pk/models.py +++ b/tests/custom_pk/models.py @@ -6,7 +6,7 @@ By default, Django adds an ``"id"`` field to each model. But you can override this behavior by explicitly adding ``primary_key=True`` to a field. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.db import models diff --git a/tests/custom_pk/tests.py b/tests/custom_pk/tests.py index 3f562f0bed..59bc64754f 100644 --- a/tests/custom_pk/tests.py +++ b/tests/custom_pk/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.db import transaction, IntegrityError from django.test import TestCase, skipIfDBFeature diff --git a/tests/datatypes/tests.py b/tests/datatypes/tests.py index b6b52dedf2..a2bb0c110a 100644 --- a/tests/datatypes/tests.py +++ b/tests/datatypes/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime diff --git a/tests/dates/tests.py b/tests/dates/tests.py index 6c02d597de..c2a8d82e37 100644 --- a/tests/dates/tests.py +++ b/tests/dates/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import datetime diff --git a/tests/datetimes/tests.py b/tests/datetimes/tests.py index 58cb060f6b..f54b30d967 100644 --- a/tests/datetimes/tests.py +++ b/tests/datetimes/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import datetime diff --git a/tests/defer/tests.py b/tests/defer/tests.py index 50db5a76b4..1df312e1bf 100644 --- a/tests/defer/tests.py +++ b/tests/defer/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db.models.query_utils import DeferredAttribute, InvalidQuery from django.test import TestCase diff --git a/tests/defer_regress/tests.py b/tests/defer_regress/tests.py index ad2546794c..619f65163c 100644 --- a/tests/defer_regress/tests.py +++ b/tests/defer_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from operator import attrgetter diff --git a/tests/delete/tests.py b/tests/delete/tests.py index 66173078a0..8fb16f5a2d 100644 --- a/tests/delete/tests.py +++ b/tests/delete/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db import models, IntegrityError, connection from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature diff --git a/tests/delete_regress/tests.py b/tests/delete_regress/tests.py index a4908b2121..22e15baf8e 100644 --- a/tests/delete_regress/tests.py +++ b/tests/delete_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import datetime diff --git a/tests/dispatch/tests/__init__.py b/tests/dispatch/tests/__init__.py index b6d26217e1..4c4d4fea8a 100644 --- a/tests/dispatch/tests/__init__.py +++ b/tests/dispatch/tests/__init__.py @@ -2,7 +2,5 @@ Unit-tests for the dispatch project """ -from __future__ import absolute_import - from .test_dispatcher import DispatcherTests, ReceiverTestCase from .test_saferef import SaferefTests diff --git a/tests/distinct_on_fields/tests.py b/tests/distinct_on_fields/tests.py index f62a32e58d..7bc06f0da2 100644 --- a/tests/distinct_on_fields/tests.py +++ b/tests/distinct_on_fields/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db.models import Max from django.test import TestCase, skipUnlessDBFeature diff --git a/tests/empty/tests.py b/tests/empty/tests.py index 6dd9f7c75d..007d04c363 100644 --- a/tests/empty/tests.py +++ b/tests/empty/tests.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.core.exceptions import ImproperlyConfigured from django.db.models.loading import get_app from django.test import TestCase diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index a351496442..9801d0acbb 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.core.exceptions import FieldError from django.db.models import F diff --git a/tests/expressions_regress/tests.py b/tests/expressions_regress/tests.py index ddb2c83b4f..c4f8085804 100644 --- a/tests/expressions_regress/tests.py +++ b/tests/expressions_regress/tests.py @@ -1,7 +1,7 @@ """ Spanning tests for all the operations that F() expressions can perform. """ -from __future__ import absolute_import +from __future__ import unicode_literals import datetime diff --git a/tests/extra_regress/tests.py b/tests/extra_regress/tests.py index 194b250c99..921f33aab9 100644 --- a/tests/extra_regress/tests.py +++ b/tests/extra_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime diff --git a/tests/field_defaults/tests.py b/tests/field_defaults/tests.py index 69dabb5168..d9f28d8c5c 100644 --- a/tests/field_defaults/tests.py +++ b/tests/field_defaults/tests.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from datetime import datetime from django.test import TestCase diff --git a/tests/field_subclassing/models.py b/tests/field_subclassing/models.py index 642573cc83..67a95b02f2 100644 --- a/tests/field_subclassing/models.py +++ b/tests/field_subclassing/models.py @@ -2,8 +2,6 @@ Tests for field subclassing. """ -from __future__ import absolute_import - from django.db import models from django.utils.encoding import force_text diff --git a/tests/field_subclassing/tests.py b/tests/field_subclassing/tests.py index 4945cff1bf..d3b4d9e527 100644 --- a/tests/field_subclassing/tests.py +++ b/tests/field_subclassing/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.core import serializers from django.test import TestCase diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py index 8cf4c33091..cdd9720374 100644 --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import errno import os diff --git a/tests/file_uploads/tests.py b/tests/file_uploads/tests.py index f5a9c10be4..b0f00236d2 100644 --- a/tests/file_uploads/tests.py +++ b/tests/file_uploads/tests.py @@ -1,5 +1,5 @@ #! -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import base64 import errno diff --git a/tests/file_uploads/urls.py b/tests/file_uploads/urls.py index 96efaaa5d8..4782a0dab9 100644 --- a/tests/file_uploads/urls.py +++ b/tests/file_uploads/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns from . import views diff --git a/tests/file_uploads/views.py b/tests/file_uploads/views.py index d1bd2cf44e..8d20a9cb6e 100644 --- a/tests/file_uploads/views.py +++ b/tests/file_uploads/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import hashlib import json diff --git a/tests/files/tests.py b/tests/files/tests.py index 54eeee13e4..b353c1a213 100644 --- a/tests/files/tests.py +++ b/tests/files/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import os import gzip diff --git a/tests/fixtures/tests.py b/tests/fixtures/tests.py index 6f2218b19e..78653ffe5e 100644 --- a/tests/fixtures/tests.py +++ b/tests/fixtures/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import warnings diff --git a/tests/fixtures_regress/models.py b/tests/fixtures_regress/models.py index 1cc30d2e51..99096728a7 100644 --- a/tests/fixtures_regress/models.py +++ b/tests/fixtures_regress/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.contrib.auth.models import User from django.db import models diff --git a/tests/fixtures_regress/tests.py b/tests/fixtures_regress/tests.py index 9899bf939c..f917b21642 100644 --- a/tests/fixtures_regress/tests.py +++ b/tests/fixtures_regress/tests.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Unittests for fixtures. -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import os import re diff --git a/tests/force_insert_update/tests.py b/tests/force_insert_update/tests.py index a5b2dcebb5..706a099872 100644 --- a/tests/force_insert_update/tests.py +++ b/tests/force_insert_update/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db import transaction, IntegrityError, DatabaseError from django.test import TestCase diff --git a/tests/forms_tests/tests/__init__.py b/tests/forms_tests/tests/__init__.py index aea9418c05..39219f82be 100644 --- a/tests/forms_tests/tests/__init__.py +++ b/tests/forms_tests/tests/__init__.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from .test_error_messages import (FormsErrorMessagesTestCase, ModelChoiceFieldErrorMessagesTestCase) from .test_extra import FormsExtraTestCase, FormsExtraL10NTestCase diff --git a/tests/forms_tests/tests/test_error_messages.py b/tests/forms_tests/tests/test_error_messages.py index 9d45a46a3d..f0638298e9 100644 --- a/tests/forms_tests/tests/test_error_messages.py +++ b/tests/forms_tests/tests/test_error_messages.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.core.files.uploadedfile import SimpleUploadedFile from django.forms import * diff --git a/tests/forms_tests/tests/test_extra.py b/tests/forms_tests/tests/test_extra.py index d439e2223c..afdfaf5281 100644 --- a/tests/forms_tests/tests/test_extra.py +++ b/tests/forms_tests/tests/test_extra.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py index 99a67c320c..4c391646e7 100644 --- a/tests/forms_tests/tests/tests.py +++ b/tests/forms_tests/tests/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime diff --git a/tests/generic_inline_admin/admin.py b/tests/generic_inline_admin/admin.py index 73cac7f7c5..1917024fa5 100644 --- a/tests/generic_inline_admin/admin.py +++ b/tests/generic_inline_admin/admin.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib import admin from django.contrib.contenttypes import generic diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py index ac2c191183..ccf12ab4f3 100644 --- a/tests/generic_inline_admin/tests.py +++ b/tests/generic_inline_admin/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.conf import settings from django.contrib import admin diff --git a/tests/generic_inline_admin/urls.py b/tests/generic_inline_admin/urls.py index 88d7b574d4..8d68d6c922 100644 --- a/tests/generic_inline_admin/urls.py +++ b/tests/generic_inline_admin/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, include from . import admin diff --git a/tests/generic_relations/tests.py b/tests/generic_relations/tests.py index 734b2e5143..2b52ebac56 100644 --- a/tests/generic_relations/tests.py +++ b/tests/generic_relations/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django import forms from django.contrib.contenttypes.generic import generic_inlineformset_factory diff --git a/tests/generic_views/test_base.py b/tests/generic_views/test_base.py index 013a8f282c..b1dd7a3040 100644 --- a/tests/generic_views/test_base.py +++ b/tests/generic_views/test_base.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import time import unittest diff --git a/tests/generic_views/test_dates.py b/tests/generic_views/test_dates.py index bff909f7d0..03c6d02e5e 100644 --- a/tests/generic_views/test_dates.py +++ b/tests/generic_views/test_dates.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import time import datetime diff --git a/tests/generic_views/test_detail.py b/tests/generic_views/test_detail.py index 3a97d27995..8a487a7c3d 100644 --- a/tests/generic_views/test_detail.py +++ b/tests/generic_views/test_detail.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.core.exceptions import ImproperlyConfigured from django.test import TestCase diff --git a/tests/generic_views/test_edit.py b/tests/generic_views/test_edit.py index 9ed18833e4..9b1ba0f865 100644 --- a/tests/generic_views/test_edit.py +++ b/tests/generic_views/test_edit.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import warnings from unittest import expectedFailure diff --git a/tests/generic_views/test_forms.py b/tests/generic_views/test_forms.py index 8c118e32a6..1ee26afc8f 100644 --- a/tests/generic_views/test_forms.py +++ b/tests/generic_views/test_forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django import forms diff --git a/tests/generic_views/test_list.py b/tests/generic_views/test_list.py index a77a6418a3..e572af8e32 100644 --- a/tests/generic_views/test_list.py +++ b/tests/generic_views/test_list.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.core.exceptions import ImproperlyConfigured from django.test import TestCase diff --git a/tests/generic_views/urls.py b/tests/generic_views/urls.py index 695b50279a..4ef8f7a97f 100644 --- a/tests/generic_views/urls.py +++ b/tests/generic_views/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url from django.views.decorators.cache import cache_page from django.views.generic import TemplateView diff --git a/tests/generic_views/views.py b/tests/generic_views/views.py index fd331f14b7..f839b53753 100644 --- a/tests/generic_views/views.py +++ b/tests/generic_views/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib.auth.decorators import login_required from django.core.paginator import Paginator diff --git a/tests/get_earliest_or_latest/tests.py b/tests/get_earliest_or_latest/tests.py index 8d16af9587..eeb95c0818 100644 --- a/tests/get_earliest_or_latest/tests.py +++ b/tests/get_earliest_or_latest/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from datetime import datetime diff --git a/tests/get_object_or_404/tests.py b/tests/get_object_or_404/tests.py index 38ebeb4f8c..1a0b41bc4d 100644 --- a/tests/get_object_or_404/tests.py +++ b/tests/get_object_or_404/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.http import Http404 from django.shortcuts import get_object_or_404, get_list_or_404 @@ -87,7 +87,7 @@ class GetObjectOr404Tests(TestCase): self.assertRaisesMessage(ValueError, "Object is of type 'str', but must be a Django Model, Manager, " "or QuerySet", - get_object_or_404, "Article", title__icontains="Run" + get_object_or_404, str("Article"), title__icontains="Run" ) class CustomClass(object): diff --git a/tests/get_or_create/tests.py b/tests/get_or_create/tests.py index 0f766ab128..a612ea60a0 100644 --- a/tests/get_or_create/tests.py +++ b/tests/get_or_create/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from datetime import date import traceback @@ -65,7 +65,7 @@ class GetOrCreateTests(TestCase): ManualPrimaryKeyTest.objects.get_or_create(id=1, data="Different") except IntegrityError as e: formatted_traceback = traceback.format_exc() - self.assertIn('obj.save', formatted_traceback) + self.assertIn(str('obj.save'), formatted_traceback) def test_savepoint_rollback(self): # Regression test for #20463: the database connection should still be diff --git a/tests/get_or_create_regress/tests.py b/tests/get_or_create_regress/tests.py index 92c371b6f8..54dafc85fb 100644 --- a/tests/get_or_create_regress/tests.py +++ b/tests/get_or_create_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase diff --git a/tests/i18n/forms.py b/tests/i18n/forms.py index 6e4def9c5e..07b015d590 100644 --- a/tests/i18n/forms.py +++ b/tests/i18n/forms.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django import forms from django.forms.extras import SelectDateWidget diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index 8e6ec45ce1..3d5cbc590e 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime import decimal diff --git a/tests/inline_formsets/tests.py b/tests/inline_formsets/tests.py index ad8a666cb5..a16488dc79 100644 --- a/tests/inline_formsets/tests.py +++ b/tests/inline_formsets/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.forms.models import inlineformset_factory from django.test import TestCase diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py index f1c87bbf14..6f38439945 100644 --- a/tests/introspection/tests.py +++ b/tests/introspection/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import unittest diff --git a/tests/known_related_objects/tests.py b/tests/known_related_objects/tests.py index d28d266557..6fd507cbdc 100644 --- a/tests/known_related_objects/tests.py +++ b/tests/known_related_objects/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py index ee9c5afe1d..c9891c846f 100644 --- a/tests/lookup/tests.py +++ b/tests/lookup/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from datetime import datetime from operator import attrgetter diff --git a/tests/m2m_and_m2o/tests.py b/tests/m2m_and_m2o/tests.py index 77f2eb3b09..0380ad4b08 100644 --- a/tests/m2m_and_m2o/tests.py +++ b/tests/m2m_and_m2o/tests.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.db.models import Q from django.test import TestCase diff --git a/tests/m2m_intermediary/tests.py b/tests/m2m_intermediary/tests.py index f261f23546..d9c77ecb7c 100644 --- a/tests/m2m_intermediary/tests.py +++ b/tests/m2m_intermediary/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from datetime import datetime diff --git a/tests/m2m_multiple/tests.py b/tests/m2m_multiple/tests.py index 7bf88f99bb..2122517ce4 100644 --- a/tests/m2m_multiple/tests.py +++ b/tests/m2m_multiple/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from datetime import datetime diff --git a/tests/m2m_recursive/tests.py b/tests/m2m_recursive/tests.py index a3f2c670d6..3beafc9692 100644 --- a/tests/m2m_recursive/tests.py +++ b/tests/m2m_recursive/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from operator import attrgetter diff --git a/tests/m2m_regress/tests.py b/tests/m2m_regress/tests.py index 884fc097a1..610f01694a 100644 --- a/tests/m2m_regress/tests.py +++ b/tests/m2m_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.core.exceptions import FieldError from django.test import TestCase diff --git a/tests/m2m_signals/tests.py b/tests/m2m_signals/tests.py index d3d2a74c70..569a2dc12d 100644 --- a/tests/m2m_signals/tests.py +++ b/tests/m2m_signals/tests.py @@ -2,8 +2,6 @@ Testing signals emitted on changing m2m relations. """ -from .models import Person - from django.db import models from django.test import TestCase diff --git a/tests/m2m_through/tests.py b/tests/m2m_through/tests.py index 259dc68a0b..69a7ec99bf 100644 --- a/tests/m2m_through/tests.py +++ b/tests/m2m_through/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from datetime import datetime from operator import attrgetter diff --git a/tests/m2m_through_regress/tests.py b/tests/m2m_through_regress/tests.py index de4d52a2db..c1b229b30b 100644 --- a/tests/m2m_through_regress/tests.py +++ b/tests/m2m_through_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.core import management from django.contrib.auth.models import User diff --git a/tests/m2o_recursive/tests.py b/tests/m2o_recursive/tests.py index fa04c74cca..f5e8938706 100644 --- a/tests/m2o_recursive/tests.py +++ b/tests/m2o_recursive/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase diff --git a/tests/managers_regress/tests.py b/tests/managers_regress/tests.py index 45059be4e5..e5dce53122 100644 --- a/tests/managers_regress/tests.py +++ b/tests/managers_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import copy from django.conf import settings diff --git a/tests/many_to_many/tests.py b/tests/many_to_many/tests.py index 7d30379b94..e6fed191fc 100644 --- a/tests/many_to_many/tests.py +++ b/tests/many_to_many/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase from django.utils import six diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py index a4f87a3283..ae629288b1 100644 --- a/tests/many_to_one/tests.py +++ b/tests/many_to_one/tests.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from copy import deepcopy import datetime diff --git a/tests/many_to_one_null/tests.py b/tests/many_to_one_null/tests.py index 4de44b5e64..cd1800d77c 100644 --- a/tests/many_to_one_null/tests.py +++ b/tests/many_to_one_null/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase diff --git a/tests/many_to_one_regress/tests.py b/tests/many_to_one_regress/tests.py index 035ba53bff..19cfaad097 100644 --- a/tests/many_to_one_regress/tests.py +++ b/tests/many_to_one_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db import models from django.test import TestCase diff --git a/tests/max_lengths/tests.py b/tests/max_lengths/tests.py index 0f525864d5..43f9e217c8 100644 --- a/tests/max_lengths/tests.py +++ b/tests/max_lengths/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import unittest diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py index 5ceab2e594..0897ec06be 100644 --- a/tests/middleware/tests.py +++ b/tests/middleware/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import gzip from io import BytesIO diff --git a/tests/middleware_exceptions/urls.py b/tests/middleware_exceptions/urls.py index 042607fdc8..fcef638553 100644 --- a/tests/middleware_exceptions/urls.py +++ b/tests/middleware_exceptions/urls.py @@ -1,6 +1,3 @@ -# coding: utf-8 -from __future__ import absolute_import - from django.conf.urls import patterns from . import views diff --git a/tests/model_fields/test_imagefield.py b/tests/model_fields/test_imagefield.py index f6019bd77f..ce7d33eb32 100644 --- a/tests/model_fields/test_imagefield.py +++ b/tests/model_fields/test_imagefield.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import os import shutil diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py index 1ce5eba3e9..a43f764407 100644 --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime from decimal import Decimal diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 09c62c5205..21e3143be6 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime import os diff --git a/tests/model_forms_regress/tests.py b/tests/model_forms_regress/tests.py index 35e706ac4c..ffe1123b99 100644 --- a/tests/model_forms_regress/tests.py +++ b/tests/model_forms_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from datetime import date import unittest diff --git a/tests/model_formsets/tests.py b/tests/model_formsets/tests.py index 3bb4f95ea5..053448181a 100644 --- a/tests/model_formsets/tests.py +++ b/tests/model_formsets/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime import re diff --git a/tests/model_formsets_regress/tests.py b/tests/model_formsets_regress/tests.py index 179f79fbcb..782c7d6fbc 100644 --- a/tests/model_formsets_regress/tests.py +++ b/tests/model_formsets_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django import forms from django.forms.formsets import BaseFormSet, DELETION_FIELD_NAME diff --git a/tests/model_inheritance/tests.py b/tests/model_inheritance/tests.py index dc40d2d2e0..eb50d30cf8 100644 --- a/tests/model_inheritance/tests.py +++ b/tests/model_inheritance/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from operator import attrgetter diff --git a/tests/model_inheritance_regress/tests.py b/tests/model_inheritance_regress/tests.py index 7ca16647fa..10a1230685 100644 --- a/tests/model_inheritance_regress/tests.py +++ b/tests/model_inheritance_regress/tests.py @@ -1,7 +1,7 @@ """ Regression tests for Model inheritance behavior. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime from operator import attrgetter diff --git a/tests/model_inheritance_same_model_name/models.py b/tests/model_inheritance_same_model_name/models.py index b4a6b930df..8b02b08668 100644 --- a/tests/model_inheritance_same_model_name/models.py +++ b/tests/model_inheritance_same_model_name/models.py @@ -6,8 +6,6 @@ in the need for an %(app_label)s format string. This app specifically tests this feature by redefining the Copy model from model_inheritance/models.py """ -from __future__ import absolute_import - from django.db import models from model_inheritance.models import NamedURL diff --git a/tests/model_inheritance_same_model_name/tests.py b/tests/model_inheritance_same_model_name/tests.py index 8f22578013..fe1fb0cdd2 100644 --- a/tests/model_inheritance_same_model_name/tests.py +++ b/tests/model_inheritance_same_model_name/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase diff --git a/tests/model_inheritance_select_related/tests.py b/tests/model_inheritance_select_related/tests.py index 078b466d0e..68f9897e25 100644 --- a/tests/model_inheritance_select_related/tests.py +++ b/tests/model_inheritance_select_related/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from operator import attrgetter diff --git a/tests/model_package/models/__init__.py b/tests/model_package/models/__init__.py index 3c261aa444..ec29d667f9 100644 --- a/tests/model_package/models/__init__.py +++ b/tests/model_package/models/__init__.py @@ -1,5 +1,3 @@ # Import all the models from subpackages -from __future__ import absolute_import - from .article import Article from .publication import Publication diff --git a/tests/model_package/tests.py b/tests/model_package/tests.py index 5d856a9608..a352b57478 100644 --- a/tests/model_package/tests.py +++ b/tests/model_package/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib.sites.models import Site from django.db import models diff --git a/tests/model_permalink/tests.py b/tests/model_permalink/tests.py index 257648ca5f..ef682ed0e8 100644 --- a/tests/model_permalink/tests.py +++ b/tests/model_permalink/tests.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.test import TestCase from .models import Guitarist diff --git a/tests/model_regress/tests.py b/tests/model_regress/tests.py index 2924b220e6..f84a40b05b 100644 --- a/tests/model_regress/tests.py +++ b/tests/model_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime from operator import attrgetter diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py index 0d0fed394a..616b0889b9 100644 --- a/tests/modeladmin/tests.py +++ b/tests/modeladmin/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from datetime import date import unittest diff --git a/tests/multiple_database/models.py b/tests/multiple_database/models.py index e46438649b..00534c870c 100644 --- a/tests/multiple_database/models.py +++ b/tests/multiple_database/models.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py index 12a6379ca0..949679418c 100644 --- a/tests/multiple_database/tests.py +++ b/tests/multiple_database/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime import pickle diff --git a/tests/mutually_referential/tests.py b/tests/mutually_referential/tests.py index b3deb0e75c..6006465843 100644 --- a/tests/mutually_referential/tests.py +++ b/tests/mutually_referential/tests.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.test import TestCase from .models import Parent diff --git a/tests/nested_foreign_keys/tests.py b/tests/nested_foreign_keys/tests.py index 5cb23cfb9c..e8e20762fe 100644 --- a/tests/nested_foreign_keys/tests.py +++ b/tests/nested_foreign_keys/tests.py @@ -1,4 +1,5 @@ -from __future__ import absolute_import +from __future__ import unicode_literals + from django.test import TestCase from .models import Person, Movie, Event, Screening, ScreeningNullFK, Package, PackageNullFK diff --git a/tests/null_fk/tests.py b/tests/null_fk/tests.py index 96a06b6769..29e1fcb4bb 100644 --- a/tests/null_fk/tests.py +++ b/tests/null_fk/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.db.models import Q from django.test import TestCase diff --git a/tests/null_fk_ordering/tests.py b/tests/null_fk_ordering/tests.py index aea969de4f..70873244ac 100644 --- a/tests/null_fk_ordering/tests.py +++ b/tests/null_fk_ordering/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase diff --git a/tests/null_queries/tests.py b/tests/null_queries/tests.py index 93e72d55d8..d08c9979d7 100644 --- a/tests/null_queries/tests.py +++ b/tests/null_queries/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase from django.core.exceptions import FieldError diff --git a/tests/one_to_one/tests.py b/tests/one_to_one/tests.py index a36764b788..6e16d81cea 100644 --- a/tests/one_to_one/tests.py +++ b/tests/one_to_one/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db import transaction, IntegrityError from django.test import TestCase diff --git a/tests/one_to_one_regress/tests.py b/tests/one_to_one_regress/tests.py index 615536ba38..7d82194abb 100644 --- a/tests/one_to_one_regress/tests.py +++ b/tests/one_to_one_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase diff --git a/tests/or_lookups/tests.py b/tests/or_lookups/tests.py index e1c6fcb32a..264d999575 100644 --- a/tests/or_lookups/tests.py +++ b/tests/or_lookups/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from datetime import datetime from operator import attrgetter diff --git a/tests/order_with_respect_to/tests.py b/tests/order_with_respect_to/tests.py index 559cb1d996..155c238617 100644 --- a/tests/order_with_respect_to/tests.py +++ b/tests/order_with_respect_to/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from operator import attrgetter diff --git a/tests/ordering/tests.py b/tests/ordering/tests.py index b1b5253682..63161a3273 100644 --- a/tests/ordering/tests.py +++ b/tests/ordering/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from datetime import datetime from operator import attrgetter diff --git a/tests/pagination/tests.py b/tests/pagination/tests.py index 76799bec46..46ea428d17 100644 --- a/tests/pagination/tests.py +++ b/tests/pagination/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from datetime import datetime import unittest diff --git a/tests/prefetch_related/tests.py b/tests/prefetch_related/tests.py index 2e3fee6be6..9d5a5290da 100644 --- a/tests/prefetch_related/tests.py +++ b/tests/prefetch_related/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.contrib.contenttypes.models import ContentType from django.db import connection diff --git a/tests/properties/tests.py b/tests/properties/tests.py index 8a40d06e98..c471c414a1 100644 --- a/tests/properties/tests.py +++ b/tests/properties/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase diff --git a/tests/proxy_model_inheritance/app1/models.py b/tests/proxy_model_inheritance/app1/models.py index affcf140ac..a7a99fe46b 100644 --- a/tests/proxy_model_inheritance/app1/models.py +++ b/tests/proxy_model_inheritance/app1/models.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - # TODO: why can't I make this ..app2 from app2.models import NiceModel diff --git a/tests/proxy_model_inheritance/tests.py b/tests/proxy_model_inheritance/tests.py index 85bf74a4e9..dda09a080f 100644 --- a/tests/proxy_model_inheritance/tests.py +++ b/tests/proxy_model_inheritance/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import os import sys diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py index 5cc5ef5478..240198cc39 100644 --- a/tests/proxy_models/tests.py +++ b/tests/proxy_models/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import copy from django.conf import settings diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 94c12c5ba9..025fcd8608 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import,unicode_literals +from __future__ import unicode_literals import datetime from operator import attrgetter diff --git a/tests/queryset_pickle/models.py b/tests/queryset_pickle/models.py index 3a8973505c..dacd5018da 100644 --- a/tests/queryset_pickle/models.py +++ b/tests/queryset_pickle/models.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import datetime from django.db import models diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py index d2f333a9b3..384073ad56 100644 --- a/tests/queryset_pickle/tests.py +++ b/tests/queryset_pickle/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import pickle import datetime @@ -83,7 +83,7 @@ class PickleabilityTestCase(TestCase): def test_model_pickle_dynamic(self): class Meta: proxy = True - dynclass = type("DynamicEventSubclass", (Event, ), + dynclass = type(str("DynamicEventSubclass"), (Event, ), {'Meta': Meta, '__module__': Event.__module__}) original = dynclass(pk=1) dumped = pickle.dumps(original) diff --git a/tests/raw_query/tests.py b/tests/raw_query/tests.py index 7242b8309b..06c9b11230 100644 --- a/tests/raw_query/tests.py +++ b/tests/raw_query/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from datetime import date diff --git a/tests/reserved_names/tests.py b/tests/reserved_names/tests.py index ddffe08d34..cdf81b8477 100644 --- a/tests/reserved_names/tests.py +++ b/tests/reserved_names/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import datetime diff --git a/tests/reverse_lookup/tests.py b/tests/reverse_lookup/tests.py index 549ee66392..ca16db0d31 100644 --- a/tests/reverse_lookup/tests.py +++ b/tests/reverse_lookup/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.core.exceptions import FieldError from django.test import TestCase diff --git a/tests/reverse_single_related/tests.py b/tests/reverse_single_related/tests.py index 0c755c4db6..472a3026b6 100644 --- a/tests/reverse_single_related/tests.py +++ b/tests/reverse_single_related/tests.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.test import TestCase from .models import Source, Item diff --git a/tests/save_delete_hooks/tests.py b/tests/save_delete_hooks/tests.py index 42e0d4a80e..0fd1ed4e03 100644 --- a/tests/save_delete_hooks/tests.py +++ b/tests/save_delete_hooks/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.test import TestCase from django.utils import six diff --git a/tests/select_for_update/tests.py b/tests/select_for_update/tests.py index 3204d74224..3bd35448b1 100644 --- a/tests/select_for_update/tests.py +++ b/tests/select_for_update/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import sys import time diff --git a/tests/select_related/tests.py b/tests/select_related/tests.py index e6723eac9b..f07e28df99 100644 --- a/tests/select_related/tests.py +++ b/tests/select_related/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.test import TestCase diff --git a/tests/select_related_onetoone/tests.py b/tests/select_related_onetoone/tests.py index d8ba4d0484..3942b2d221 100644 --- a/tests/select_related_onetoone/tests.py +++ b/tests/select_related_onetoone/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import unittest diff --git a/tests/select_related_regress/tests.py b/tests/select_related_regress/tests.py index f6d21b2dd9..da47cb771f 100644 --- a/tests/select_related_regress/tests.py +++ b/tests/select_related_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.test import TestCase from django.utils import six diff --git a/tests/serializers/tests.py b/tests/serializers/tests.py index bff7c53249..07c220c52e 100644 --- a/tests/serializers/tests.py +++ b/tests/serializers/tests.py @@ -1,6 +1,6 @@ -from __future__ import absolute_import, unicode_literals - # -*- coding: utf-8 -*- +from __future__ import unicode_literals + import json from datetime import datetime import unittest diff --git a/tests/serializers_regress/tests.py b/tests/serializers_regress/tests.py index 1751816cee..3173f73985 100644 --- a/tests/serializers_regress/tests.py +++ b/tests/serializers_regress/tests.py @@ -6,7 +6,7 @@ test case that is capable of testing the capabilities of the serializers. This includes all valid data values, plus forward, backwards and self references. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime import decimal diff --git a/tests/servers/urls.py b/tests/servers/urls.py index a857c45f95..03393c30ec 100644 --- a/tests/servers/urls.py +++ b/tests/servers/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url from . import views diff --git a/tests/signals/tests.py b/tests/signals/tests.py index 58f25c2868..1dfe72bf5f 100644 --- a/tests/signals/tests.py +++ b/tests/signals/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db.models import signals from django.dispatch import receiver diff --git a/tests/signals_regress/tests.py b/tests/signals_regress/tests.py index 8fb3ad5a48..2c9858efda 100644 --- a/tests/signals_regress/tests.py +++ b/tests/signals_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db import models from django.test import TestCase diff --git a/tests/sites_framework/tests.py b/tests/sites_framework/tests.py index 8e664fd501..7860394aa2 100644 --- a/tests/sites_framework/tests.py +++ b/tests/sites_framework/tests.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf import settings from django.contrib.sites.models import Site from django.test import TestCase diff --git a/tests/str/tests.py b/tests/str/tests.py index d82908a0ee..3c0bc079c8 100644 --- a/tests/str/tests.py +++ b/tests/str/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime from unittest import skipIf diff --git a/tests/string_lookup/tests.py b/tests/string_lookup/tests.py index b011720ddf..5a17e55560 100644 --- a/tests/string_lookup/tests.py +++ b/tests/string_lookup/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.test import TestCase from .models import Foo, Whiz, Bar, Article, Base, Child @@ -80,4 +80,4 @@ class StringLookupTests(TestCase): self.assertEqual(repr(Article.objects.filter(submitted_from__contains='192.0.2')), repr([a])) # Test that the searches do not match the subnet mask (/32 in this case) - self.assertEqual(Article.objects.filter(submitted_from__contains='32').count(), 0) \ No newline at end of file + self.assertEqual(Article.objects.filter(submitted_from__contains='32').count(), 0) diff --git a/tests/swappable_models/tests.py b/tests/swappable_models/tests.py index 858061db23..2e2d544cea 100644 --- a/tests/swappable_models/tests.py +++ b/tests/swappable_models/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.utils.six import StringIO diff --git a/tests/syndication/feeds.py b/tests/syndication/feeds.py index 1cd5c3d988..f8ffb4b2e6 100644 --- a/tests/syndication/feeds.py +++ b/tests/syndication/feeds.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.contrib.syndication import views from django.core.exceptions import ObjectDoesNotExist diff --git a/tests/syndication/tests.py b/tests/syndication/tests.py index d3b0058d53..8bc6b04939 100644 --- a/tests/syndication/tests.py +++ b/tests/syndication/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from xml.dom import minidom diff --git a/tests/syndication/urls.py b/tests/syndication/urls.py index 06a75a4e68..1b5d77f2e1 100644 --- a/tests/syndication/urls.py +++ b/tests/syndication/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns from . import feeds diff --git a/tests/tablespaces/tests.py b/tests/tablespaces/tests.py index 1eaddef079..088938ca1d 100644 --- a/tests/tablespaces/tests.py +++ b/tests/tablespaces/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import copy diff --git a/tests/template_tests/alternate_urls.py b/tests/template_tests/alternate_urls.py index fa4985a9dc..3c6a4e62f9 100644 --- a/tests/template_tests/alternate_urls.py +++ b/tests/template_tests/alternate_urls.py @@ -1,7 +1,3 @@ -# coding: utf-8 - -from __future__ import absolute_import - from django.conf.urls import patterns, url from . import views diff --git a/tests/template_tests/test_custom.py b/tests/template_tests/test_custom.py index e941bc223e..c2dff03b10 100644 --- a/tests/template_tests/test_custom.py +++ b/tests/template_tests/test_custom.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from unittest import TestCase diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py index 81f4682f16..aa0283be79 100644 --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.conf import settings diff --git a/tests/template_tests/urls.py b/tests/template_tests/urls.py index b5498fade1..f3720bbda7 100644 --- a/tests/template_tests/urls.py +++ b/tests/template_tests/urls.py @@ -1,5 +1,5 @@ # coding: utf-8 -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.conf.urls import patterns, url from . import views diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index 0f3cba7e88..85637b982e 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -20,7 +20,7 @@ testing against the contexts and templates produced by a view, rather than the HTML rendered to the end-user. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.conf import settings from django.core import mail diff --git a/tests/test_client/urls.py b/tests/test_client/urls.py index bd395ca552..4d2f4fb86e 100644 --- a/tests/test_client/urls.py +++ b/tests/test_client/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns from django.views.generic import RedirectView diff --git a/tests/test_client_regress/urls.py b/tests/test_client_regress/urls.py index 1332537d57..6a0b330e02 100644 --- a/tests/test_client_regress/urls.py +++ b/tests/test_client_regress/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url from django.views.generic import RedirectView diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py index 48651b37ff..7aefa4e077 100644 --- a/tests/test_runner/tests.py +++ b/tests/test_runner/tests.py @@ -1,7 +1,7 @@ """ Tests for django test runner """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from importlib import import_module from optparse import make_option diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index 24aa433dd3..eb850cc3be 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import unittest diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py index 31fc5cc7fc..65e8631735 100644 --- a/tests/test_utils/urls.py +++ b/tests/test_utils/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns from . import views diff --git a/tests/test_utils/views.py b/tests/test_utils/views.py index 5495488e2c..77e598b72c 100644 --- a/tests/test_utils/views.py +++ b/tests/test_utils/views.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.http import HttpResponse from django.shortcuts import get_object_or_404 @@ -8,4 +6,4 @@ from .models import Person def get_person(request, pk): person = get_object_or_404(Person, pk=pk) - return HttpResponse(person.name) \ No newline at end of file + return HttpResponse(person.name) diff --git a/tests/timezones/admin.py b/tests/timezones/admin.py index 4c199813e2..81b49a4ab6 100644 --- a/tests/timezones/admin.py +++ b/tests/timezones/admin.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib import admin from .models import Event, Timestamp diff --git a/tests/timezones/urls.py b/tests/timezones/urls.py index e4f42972db..e9a7a90df9 100644 --- a/tests/timezones/urls.py +++ b/tests/timezones/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, include from django.contrib import admin diff --git a/tests/transactions/tests.py b/tests/transactions/tests.py index afb573f366..9cf8b4d742 100644 --- a/tests/transactions/tests.py +++ b/tests/transactions/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import sys from unittest import skipIf, skipUnless diff --git a/tests/transactions_regress/tests.py b/tests/transactions_regress/tests.py index 01f8fc4186..2376bcd277 100644 --- a/tests/transactions_regress/tests.py +++ b/tests/transactions_regress/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from unittest import skipIf, skipUnless diff --git a/tests/unmanaged_models/tests.py b/tests/unmanaged_models/tests.py index d7cf961a37..7b23a46096 100644 --- a/tests/unmanaged_models/tests.py +++ b/tests/unmanaged_models/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db import connection from django.test import TestCase diff --git a/tests/update/tests.py b/tests/update/tests.py index 7a1177c1fd..9db9625183 100644 --- a/tests/update/tests.py +++ b/tests/update/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.test import TestCase diff --git a/tests/update_only_fields/tests.py b/tests/update_only_fields/tests.py index 97c05ddc79..1f85c3bbb2 100644 --- a/tests/update_only_fields/tests.py +++ b/tests/update_only_fields/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db.models.signals import pre_save, post_save from django.test import TestCase diff --git a/tests/urlpatterns_reverse/extra_urls.py b/tests/urlpatterns_reverse/extra_urls.py index d3a04e6b31..94e225fb46 100644 --- a/tests/urlpatterns_reverse/extra_urls.py +++ b/tests/urlpatterns_reverse/extra_urls.py @@ -2,8 +2,6 @@ Some extra URL patterns that are included at the top level. """ -from __future__ import absolute_import - from django.conf.urls import patterns, url, include from .views import empty_view diff --git a/tests/urlpatterns_reverse/included_named_urls.py b/tests/urlpatterns_reverse/included_named_urls.py index 353aed255e..366fe9b57a 100644 --- a/tests/urlpatterns_reverse/included_named_urls.py +++ b/tests/urlpatterns_reverse/included_named_urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url, include from .views import empty_view diff --git a/tests/urlpatterns_reverse/included_named_urls2.py b/tests/urlpatterns_reverse/included_named_urls2.py index b31bdb1f7e..b8e4c531fa 100644 --- a/tests/urlpatterns_reverse/included_named_urls2.py +++ b/tests/urlpatterns_reverse/included_named_urls2.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url from .views import empty_view diff --git a/tests/urlpatterns_reverse/included_namespace_urls.py b/tests/urlpatterns_reverse/included_namespace_urls.py index 7a2096ecd9..ae098a64dc 100644 --- a/tests/urlpatterns_reverse/included_namespace_urls.py +++ b/tests/urlpatterns_reverse/included_namespace_urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url, include from .namespace_urls import URLObject diff --git a/tests/urlpatterns_reverse/included_urls.py b/tests/urlpatterns_reverse/included_urls.py index c8c9001843..af6b6882e0 100644 --- a/tests/urlpatterns_reverse/included_urls.py +++ b/tests/urlpatterns_reverse/included_urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url from .views import empty_view diff --git a/tests/urlpatterns_reverse/included_urls2.py b/tests/urlpatterns_reverse/included_urls2.py index 98605047f4..9dcafc8535 100644 --- a/tests/urlpatterns_reverse/included_urls2.py +++ b/tests/urlpatterns_reverse/included_urls2.py @@ -5,8 +5,6 @@ each name to resolve and Django must distinguish the possibilities based on the argument list. """ -from __future__ import absolute_import - from django.conf.urls import patterns, url from .views import empty_view diff --git a/tests/urlpatterns_reverse/middleware.py b/tests/urlpatterns_reverse/middleware.py index fbf577786e..0de692835f 100644 --- a/tests/urlpatterns_reverse/middleware.py +++ b/tests/urlpatterns_reverse/middleware.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.core.urlresolvers import reverse from django.http import HttpResponse, StreamingHttpResponse diff --git a/tests/urlpatterns_reverse/named_urls.py b/tests/urlpatterns_reverse/named_urls.py index 3290cab29c..d4d35bac33 100644 --- a/tests/urlpatterns_reverse/named_urls.py +++ b/tests/urlpatterns_reverse/named_urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url, include from .views import empty_view diff --git a/tests/urlpatterns_reverse/namespace_urls.py b/tests/urlpatterns_reverse/namespace_urls.py index cf960070ec..014bc65990 100644 --- a/tests/urlpatterns_reverse/namespace_urls.py +++ b/tests/urlpatterns_reverse/namespace_urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url, include from .views import view_class_instance diff --git a/tests/urlpatterns_reverse/reverse_lazy_urls.py b/tests/urlpatterns_reverse/reverse_lazy_urls.py index 693c6e1b38..0ef0a1f313 100644 --- a/tests/urlpatterns_reverse/reverse_lazy_urls.py +++ b/tests/urlpatterns_reverse/reverse_lazy_urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url from .views import empty_view, LazyRedirectView, login_required_view diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py index 222ebe053b..aef0fa0514 100644 --- a/tests/urlpatterns_reverse/tests.py +++ b/tests/urlpatterns_reverse/tests.py @@ -1,7 +1,7 @@ """ Unit tests for reverse URL lookups. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import unittest diff --git a/tests/urlpatterns_reverse/urlconf_outer.py b/tests/urlpatterns_reverse/urlconf_outer.py index 0cdebf83ff..20b9b09f98 100644 --- a/tests/urlpatterns_reverse/urlconf_outer.py +++ b/tests/urlpatterns_reverse/urlconf_outer.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url, include from . import urlconf_inner @@ -8,4 +6,4 @@ from . import urlconf_inner urlpatterns = patterns('', url(r'^test/me/$', urlconf_inner.inner_view, name='outer'), url(r'^inner_urlconf/', include(urlconf_inner.__name__)) -) \ No newline at end of file +) diff --git a/tests/urlpatterns_reverse/urls.py b/tests/urlpatterns_reverse/urls.py index 1dbc8d889f..cb08e2e664 100644 --- a/tests/urlpatterns_reverse/urls.py +++ b/tests/urlpatterns_reverse/urls.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.conf.urls import patterns, url, include from .views import empty_view, absolute_kwargs_view diff --git a/tests/urlpatterns_reverse/urls_error_handlers_callables.py b/tests/urlpatterns_reverse/urls_error_handlers_callables.py index befeccaf45..0900ec94ba 100644 --- a/tests/urlpatterns_reverse/urls_error_handlers_callables.py +++ b/tests/urlpatterns_reverse/urls_error_handlers_callables.py @@ -1,7 +1,5 @@ # Used by the ErrorHandlerResolutionTests test case. -from __future__ import absolute_import - from django.conf.urls import patterns from .views import empty_view diff --git a/tests/urlpatterns_reverse/urls_without_full_import.py b/tests/urlpatterns_reverse/urls_without_full_import.py index ca3e424f23..c1dce5549c 100644 --- a/tests/urlpatterns_reverse/urls_without_full_import.py +++ b/tests/urlpatterns_reverse/urls_without_full_import.py @@ -1,8 +1,6 @@ # A URLs file that doesn't use the default # from django.conf.urls import * # import pattern. -from __future__ import absolute_import - from django.conf.urls import patterns, url from .views import empty_view, bad_view diff --git a/tests/utils_tests/test_safestring.py b/tests/utils_tests/test_safestring.py index a6f0c0a01c..5d4528a9a8 100644 --- a/tests/utils_tests/test_safestring.py +++ b/tests/utils_tests/test_safestring.py @@ -1,5 +1,4 @@ -from __future__ import absolute_import, unicode_literals - +from __future__ import unicode_literals from django.template import Template, Context from django.test import TestCase diff --git a/tests/validation/test_custom_messages.py b/tests/validation/test_custom_messages.py index c5a1ee744f..2e259b7aef 100644 --- a/tests/validation/test_custom_messages.py +++ b/tests/validation/test_custom_messages.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from . import ValidationTestCase from .models import CustomMessagesModel diff --git a/tests/validation/test_unique.py b/tests/validation/test_unique.py index a481fcb1c4..bca1b36c93 100644 --- a/tests/validation/test_unique.py +++ b/tests/validation/test_unique.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import datetime import unittest diff --git a/tests/validation/test_validators.py b/tests/validation/test_validators.py index e58d9fd4a6..c3875d4601 100644 --- a/tests/validation/test_validators.py +++ b/tests/validation/test_validators.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from . import ValidationTestCase from .models import ModelToValidate diff --git a/tests/validation/tests.py b/tests/validation/tests.py index c8b679541a..34cde3fc8a 100644 --- a/tests/validation/tests.py +++ b/tests/validation/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django import forms from django.core.exceptions import NON_FIELD_ERRORS diff --git a/tests/view_tests/generic_urls.py b/tests/view_tests/generic_urls.py index c3ac1fcafa..10e7601eb6 100644 --- a/tests/view_tests/generic_urls.py +++ b/tests/view_tests/generic_urls.py @@ -1,5 +1,5 @@ # -*- coding:utf-8 -*- -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.conf.urls import patterns, url from django.views.generic import RedirectView diff --git a/tests/view_tests/templatetags/debugtags.py b/tests/view_tests/templatetags/debugtags.py index cd2d2d9ad2..9e1945cb23 100644 --- a/tests/view_tests/templatetags/debugtags.py +++ b/tests/view_tests/templatetags/debugtags.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django import template from ..views import BrokenException diff --git a/tests/view_tests/tests/__init__.py b/tests/view_tests/tests/__init__.py index bfb2ed7376..dae149a8ef 100644 --- a/tests/view_tests/tests/__init__.py +++ b/tests/view_tests/tests/__init__.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from .test_debug import (DebugViewTests, ExceptionReporterTests, ExceptionReporterTests, PlainTextReportTests, ExceptionReporterFilterTests, AjaxResponseExceptionReporterFilter) diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index bc77fc351a..0159886918 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This coding header is significant for tests, as the debug view is parsing # files to search for such a header to decode the source file content -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import inspect import os diff --git a/tests/view_tests/tests/test_defaults.py b/tests/view_tests/tests/test_defaults.py index 5efd338d34..af812b4446 100644 --- a/tests/view_tests/tests/test_defaults.py +++ b/tests/view_tests/tests/test_defaults.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.contrib.contenttypes.models import ContentType from django.test import TestCase diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py index c1852ee71f..7a7e615e92 100644 --- a/tests/view_tests/tests/test_i18n.py +++ b/tests/view_tests/tests/test_i18n.py @@ -1,6 +1,4 @@ # -*- coding:utf-8 -*- -from __future__ import absolute_import - import gettext import os from os import path diff --git a/tests/view_tests/tests/test_static.py b/tests/view_tests/tests/test_static.py index 6104ad063e..d2f3f47fa7 100644 --- a/tests/view_tests/tests/test_static.py +++ b/tests/view_tests/tests/test_static.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import mimetypes from os import path diff --git a/tests/view_tests/urls.py b/tests/view_tests/urls.py index d792e47ddf..3dcee2fe53 100644 --- a/tests/view_tests/urls.py +++ b/tests/view_tests/urls.py @@ -1,6 +1,4 @@ # coding: utf-8 -from __future__ import absolute_import - from os import path from django.conf.urls import patterns, url, include diff --git a/tests/view_tests/views.py b/tests/view_tests/views.py index 1cfafa4333..a40b1e0c57 100644 --- a/tests/view_tests/views.py +++ b/tests/view_tests/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import sys -- cgit v1.3 From 7b57e575c94691e40533e84d84235a0c6c90ab7b Mon Sep 17 00:00:00 2001 From: "Jose L. Patino" Date: Sat, 23 Feb 2013 16:28:45 +0100 Subject: Fixed #19877 -- Added `--no-color` option to `BaseCommand` to avoid using output styles. --- django/core/management/base.py | 10 +++++-- django/core/management/color.py | 2 +- docs/ref/django-admin.txt | 13 +++++++++ docs/releases/1.7.txt | 3 ++ tests/admin_scripts/tests.py | 62 ++++++++++++++++++++++++++++------------- 5 files changed, 67 insertions(+), 23 deletions(-) (limited to 'tests/admin_scripts') diff --git a/django/core/management/base.py b/django/core/management/base.py index af040288d0..9c8940e99f 100644 --- a/django/core/management/base.py +++ b/django/core/management/base.py @@ -10,7 +10,7 @@ from optparse import make_option, OptionParser import django from django.core.exceptions import ImproperlyConfigured -from django.core.management.color import color_style +from django.core.management.color import color_style, no_style from django.utils.encoding import force_str from django.utils.six import StringIO @@ -171,6 +171,8 @@ class BaseCommand(object): help='A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".'), make_option('--traceback', action='store_true', help='Raise on exception'), + make_option('--no-color', action='store_true', dest='no_color', default=False, + help="Don't colorize the command output."), ) help = '' args = '' @@ -254,7 +256,11 @@ class BaseCommand(object): ``self.requires_model_validation``, except if force-skipped). """ self.stdout = OutputWrapper(options.get('stdout', sys.stdout)) - self.stderr = OutputWrapper(options.get('stderr', sys.stderr), self.style.ERROR) + if options.get('no_color'): + self.style = no_style() + self.stderr = OutputWrapper(options.get('stderr', sys.stderr)) + else: + self.stderr = OutputWrapper(options.get('stderr', sys.stderr), self.style.ERROR) if self.can_import_settings: from django.conf import settings diff --git a/django/core/management/color.py b/django/core/management/color.py index 8c7a87fe71..708823705b 100644 --- a/django/core/management/color.py +++ b/django/core/management/color.py @@ -30,7 +30,7 @@ def color_style(): class dummy: pass style = dummy() # The nocolor palette has all available roles. - # Use that pallete as the basis for populating + # Use that palette as the basis for populating # the palette as defined in the environment. for role in termcolors.PALETTES[termcolors.NOCOLOR_PALETTE]: format = color_settings.get(role,{}) diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt index 565c779525..6be9d0f441 100644 --- a/docs/ref/django-admin.txt +++ b/docs/ref/django-admin.txt @@ -1429,6 +1429,19 @@ that ``django-admin.py`` should print to the console. * ``2`` means verbose output. * ``3`` means *very* verbose output. +.. django-admin-option:: --no-color + +.. versionadded:: 1.7 + +Example usage:: + + django-admin.py sqlall --no-color + +By default, ``django-admin.py`` will format the output to be colorized. For +example, errors will be printed to the console in red and SQL statements will +be syntax highlighted. To prevent this and have a plain text output, pass the +``--no-color`` option when running your command. + Common options ============== diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index 8d863c849a..217fdff287 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -92,6 +92,9 @@ Minor features * :func:`~django.core.mail.send_mail` now accepts an ``html_message`` parameter for sending a multipart ``text/plain`` and ``text/html`` email. +* The :djadminopt:`--no-color` option for ``django-admin.py`` allows you to + disable the colorization of management command output. + Backwards incompatible changes in 1.7 ===================================== diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 6e1f916996..68615b787e 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -18,7 +18,7 @@ import unittest import django from django import conf, get_version from django.conf import settings -from django.core.management import BaseCommand, CommandError +from django.core.management import BaseCommand, CommandError, call_command from django.db import connection from django.test.runner import DiscoverRunner from django.utils.encoding import force_text @@ -922,14 +922,21 @@ class ManageAlternateSettings(AdminScriptTestCase): "alternate: manage.py can execute user commands if settings are provided as argument" args = ['noargs_command', '--settings=alternate_settings'] out, err = self.run_manage(args) - self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('no_color', False), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") self.assertNoOutput(err) def test_custom_command_with_environment(self): "alternate: manage.py can execute user commands if settings are provided in environment" args = ['noargs_command'] out, err = self.run_manage(args, 'alternate_settings') - self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertNoOutput(err) + + def test_custom_command_output_color(self): + "alternate: manage.py output syntax color can be deactivated with the `--no-color` option" + args = ['noargs_command', '--no-color', '--settings=alternate_settings'] + out, err = self.run_manage(args) + self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('no_color', True), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") self.assertNoOutput(err) @@ -1272,40 +1279,55 @@ class CommandTypes(AdminScriptTestCase): self.assertNoOutput(err) self.assertOutput(out, "Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).") + def test_no_color(self): + "--no-color prevent colorization of the output" + out = StringIO() + call_command("sqlall", "admin_scripts", no_color=True, stdout=out) + self.assertEqual(out.getvalue(), """BEGIN; +CREATE TABLE "admin_scripts_article" ( + "id" integer NOT NULL PRIMARY KEY, + "headline" varchar(100) NOT NULL, + "pub_date" datetime NOT NULL +) +; + +COMMIT; +""") + def test_base_command(self): "User BaseCommands can execute when a label is provided" args = ['base_command', 'testlabel'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', '1'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('no_color', False), ('option_a', '1'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") def test_base_command_no_label(self): "User BaseCommands can execute when no labels are provided" args = ['base_command'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:BaseCommand labels=(), options=[('option_a', '1'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:BaseCommand labels=(), options=[('no_color', False), ('option_a', '1'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") def test_base_command_multiple_label(self): "User BaseCommands can execute when no labels are provided" args = ['base_command', 'testlabel', 'anotherlabel'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel', 'anotherlabel'), options=[('option_a', '1'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel', 'anotherlabel'), options=[('no_color', False), ('option_a', '1'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") def test_base_command_with_option(self): "User BaseCommands can execute with options when a label is provided" args = ['base_command', 'testlabel', '--option_a=x'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('no_color', False), ('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") def test_base_command_with_options(self): "User BaseCommands can execute with multiple options when a label is provided" args = ['base_command', 'testlabel', '-a', 'x', '--option_b=y'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', 'y'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('no_color', False), ('option_a', 'x'), ('option_b', 'y'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") def test_base_run_from_argv(self): """ @@ -1351,7 +1373,7 @@ class CommandTypes(AdminScriptTestCase): args = ['noargs_command'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") def test_noargs_with_args(self): "NoArg Commands raise an error if an argument is provided" @@ -1366,7 +1388,7 @@ class CommandTypes(AdminScriptTestCase): self.assertNoOutput(err) self.assertOutput(out, "EXECUTE:AppCommand app=, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "'>, options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") def test_app_command_no_apps(self): "User AppCommands raise an error when no app name is provided" @@ -1381,10 +1403,10 @@ class CommandTypes(AdminScriptTestCase): self.assertNoOutput(err) self.assertOutput(out, "EXECUTE:AppCommand app=, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "'>, options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") self.assertOutput(out, "EXECUTE:AppCommand app=, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "'>, options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") def test_app_command_invalid_appname(self): "User AppCommands can execute when a single app name is provided" @@ -1403,7 +1425,7 @@ class CommandTypes(AdminScriptTestCase): args = ['label_command', 'testlabel'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:LabelCommand label=testlabel, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:LabelCommand label=testlabel, options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") def test_label_command_no_label(self): "User LabelCommands raise an error if no label is provided" @@ -1416,8 +1438,8 @@ class CommandTypes(AdminScriptTestCase): args = ['label_command', 'testlabel', 'anotherlabel'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:LabelCommand label=testlabel, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") - self.assertOutput(out, "EXECUTE:LabelCommand label=anotherlabel, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:LabelCommand label=testlabel, options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:LabelCommand label=anotherlabel, options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") class ArgumentOrder(AdminScriptTestCase): """Tests for 2-stage argument parsing scheme. @@ -1441,35 +1463,35 @@ class ArgumentOrder(AdminScriptTestCase): args = ['base_command', 'testlabel', '--settings=alternate_settings', '--option_a=x'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('no_color', False), ('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") def test_setting_then_short_option(self): "Short options passed after settings are correctly handled" args = ['base_command', 'testlabel', '--settings=alternate_settings', '--option_a=x'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('no_color', False), ('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") def test_option_then_setting(self): "Options passed before settings are correctly handled" args = ['base_command', 'testlabel', '--option_a=x', '--settings=alternate_settings'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('no_color', False), ('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") def test_short_option_then_setting(self): "Short options passed before settings are correctly handled" args = ['base_command', 'testlabel', '-a', 'x', '--settings=alternate_settings'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('no_color', False), ('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") def test_option_then_setting_then_option(self): "Options are correctly handled when they are passed before and after a setting" args = ['base_command', 'testlabel', '--option_a=x', '--settings=alternate_settings', '--option_b=y'] out, err = self.run_manage(args) self.assertNoOutput(err) - self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', 'y'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('no_color', False), ('option_a', 'x'), ('option_b', 'y'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") class StartProject(LiveServerTestCase, AdminScriptTestCase): -- cgit v1.3 From dffda2ba4e55d4567b3a829d410dae794636ebdd Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Tue, 30 Jul 2013 11:30:20 -0400 Subject: Fixed a test that depended on the DB backend; refs #19877. Thanks Loic. --- .../admin_scripts/management/commands/color_command.py | 9 +++++++++ tests/admin_scripts/tests.py | 18 +++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 tests/admin_scripts/management/commands/color_command.py (limited to 'tests/admin_scripts') diff --git a/tests/admin_scripts/management/commands/color_command.py b/tests/admin_scripts/management/commands/color_command.py new file mode 100644 index 0000000000..02da0a14ab --- /dev/null +++ b/tests/admin_scripts/management/commands/color_command.py @@ -0,0 +1,9 @@ +from django.core.management.base import NoArgsCommand + + +class Command(NoArgsCommand): + help = "Test color output" + requires_model_validation = False + + def handle_noargs(self, **options): + return self.style.SQL_KEYWORD('BEGIN') diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 68615b787e..e9863ebd94 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -1282,17 +1282,13 @@ class CommandTypes(AdminScriptTestCase): def test_no_color(self): "--no-color prevent colorization of the output" out = StringIO() - call_command("sqlall", "admin_scripts", no_color=True, stdout=out) - self.assertEqual(out.getvalue(), """BEGIN; -CREATE TABLE "admin_scripts_article" ( - "id" integer NOT NULL PRIMARY KEY, - "headline" varchar(100) NOT NULL, - "pub_date" datetime NOT NULL -) -; - -COMMIT; -""") + + call_command('color_command', no_color=True, stdout=out) + self.assertEqual(out.getvalue(), 'BEGIN\n') + + out = StringIO() + call_command('color_command', stdout=out) + self.assertEqual(out.getvalue(), '\x1b[33mBEGIN\x1b[0m\n') def test_base_command(self): "User BaseCommands can execute when a label is provided" -- cgit v1.3 From 8550df869bef11d176aa926aa056df9f3566a304 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Tue, 30 Jul 2013 11:59:04 -0400 Subject: Removed part of a test that doesn't work on Jenkins; refs #19877. --- tests/admin_scripts/tests.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests/admin_scripts') diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index e9863ebd94..810c90c53e 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -1286,10 +1286,6 @@ class CommandTypes(AdminScriptTestCase): call_command('color_command', no_color=True, stdout=out) self.assertEqual(out.getvalue(), 'BEGIN\n') - out = StringIO() - call_command('color_command', stdout=out) - self.assertEqual(out.getvalue(), '\x1b[33mBEGIN\x1b[0m\n') - def test_base_command(self): "User BaseCommands can execute when a label is provided" args = ['base_command', 'testlabel'] -- cgit v1.3