diff options
author | Russell Keith-Magee <russell@keith-magee.com> | 2010-05-04 14:00:30 +0000 |
---|---|---|
committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-05-04 14:00:30 +0000 |
commit | 5211f48ae3cc0d87a260dbf5c3ab8bdae664c4b6 (patch) | |
tree | 2b50ac06dd30395e53e7649d2a813927ccaeed94 /tests | |
parent | 7202eb8e3194c6d9c52780526871018205bd0858 (diff) | |
download | django-5211f48ae3cc0d87a260dbf5c3ab8bdae664c4b6.tar.gz |
Fixed #12164 -- Removed the Python 2.3 compatibility imports and workarounds. Thanks to timo and claudep for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13094 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
23 files changed, 11 insertions, 141 deletions
diff --git a/tests/modeltests/aggregation/models.py b/tests/modeltests/aggregation/models.py index 74e43b8cc6..f50abe651b 100644 --- a/tests/modeltests/aggregation/models.py +++ b/tests/modeltests/aggregation/models.py @@ -1,11 +1,6 @@ # coding: utf-8 from django.db import models -try: - sorted -except NameError: - from django.utils.itercompat import sorted # For Python 2.3 - class Author(models.Model): name = models.CharField(max_length=100) age = models.IntegerField() @@ -48,10 +43,7 @@ class Store(models.Model): # Different backends and numbers. __test__ = {'API_TESTS': """ >>> from django.core import management ->>> try: -... from decimal import Decimal -... except: -... from django.utils._decimal import Decimal +>>> from decimal import Decimal >>> from datetime import date # Reset the database representation of this app. diff --git a/tests/modeltests/basic/models.py b/tests/modeltests/basic/models.py index c86cb3ab25..ad2e965810 100644 --- a/tests/modeltests/basic/models.py +++ b/tests/modeltests/basic/models.py @@ -4,18 +4,6 @@ This is a basic model with only two non-primary-key fields. """ -# Python 2.3 doesn't have set as a builtin -try: - set -except NameError: - from sets import Set as set - -# Python 2.3 doesn't have sorted() -try: - sorted -except NameError: - from django.utils.itercompat import sorted - from django.db import models, DEFAULT_DB_ALIAS class Article(models.Model): diff --git a/tests/modeltests/model_formsets/models.py b/tests/modeltests/model_formsets/models.py index b67df97d76..6d5b81dd8a 100644 --- a/tests/modeltests/model_formsets/models.py +++ b/tests/modeltests/model_formsets/models.py @@ -2,11 +2,6 @@ import datetime from django import forms from django.db import models -try: - sorted -except NameError: - from django.utils.itercompat import sorted - class Author(models.Model): name = models.CharField(max_length=100) diff --git a/tests/modeltests/or_lookups/models.py b/tests/modeltests/or_lookups/models.py index 60b40d021d..1179c6d2dc 100644 --- a/tests/modeltests/or_lookups/models.py +++ b/tests/modeltests/or_lookups/models.py @@ -8,11 +8,6 @@ Alternatively, use positional arguments, and pass one or more expressions of clauses using the variable ``django.db.models.Q`` (or any object with an ``add_to_query`` method). """ -# Python 2.3 doesn't have sorted() -try: - sorted -except NameError: - from django.utils.itercompat import sorted from django.db import models diff --git a/tests/modeltests/serializers/models.py b/tests/modeltests/serializers/models.py index a3ff87353e..aac945077b 100644 --- a/tests/modeltests/serializers/models.py +++ b/tests/modeltests/serializers/models.py @@ -6,11 +6,7 @@ ``QuerySet`` objects to and from "flat" data (i.e. strings). """ -try: - from decimal import Decimal -except ImportError: - from django.utils._decimal import Decimal # Python 2.3 fallback - +from decimal import Decimal from django.db import models class Category(models.Model): diff --git a/tests/regressiontests/admin_scripts/management/commands/app_command.py b/tests/regressiontests/admin_scripts/management/commands/app_command.py index 3d8c43755c..f72e912ac0 100644 --- a/tests/regressiontests/admin_scripts/management/commands/app_command.py +++ b/tests/regressiontests/admin_scripts/management/commands/app_command.py @@ -1,9 +1,4 @@ from django.core.management.base import AppCommand -# Python 2.3 doesn't have sorted() -try: - sorted -except NameError: - from django.utils.itercompat import sorted class Command(AppCommand): help = 'Test Application-based commands' diff --git a/tests/regressiontests/admin_scripts/management/commands/base_command.py b/tests/regressiontests/admin_scripts/management/commands/base_command.py index 536f40409a..438f7038ca 100644 --- a/tests/regressiontests/admin_scripts/management/commands/base_command.py +++ b/tests/regressiontests/admin_scripts/management/commands/base_command.py @@ -1,10 +1,5 @@ from django.core.management.base import BaseCommand from optparse import make_option -# Python 2.3 doesn't have sorted() -try: - sorted -except NameError: - from django.utils.itercompat import sorted class Command(BaseCommand): option_list = BaseCommand.option_list + ( diff --git a/tests/regressiontests/admin_scripts/management/commands/label_command.py b/tests/regressiontests/admin_scripts/management/commands/label_command.py index e749209d9c..2b735c8e60 100644 --- a/tests/regressiontests/admin_scripts/management/commands/label_command.py +++ b/tests/regressiontests/admin_scripts/management/commands/label_command.py @@ -1,9 +1,4 @@ from django.core.management.base import LabelCommand -# Python 2.3 doesn't have sorted() -try: - sorted -except NameError: - from django.utils.itercompat import sorted class Command(LabelCommand): help = "Test Label-based commands" diff --git a/tests/regressiontests/admin_scripts/management/commands/noargs_command.py b/tests/regressiontests/admin_scripts/management/commands/noargs_command.py index f0f418752a..683eb7a62c 100644 --- a/tests/regressiontests/admin_scripts/management/commands/noargs_command.py +++ b/tests/regressiontests/admin_scripts/management/commands/noargs_command.py @@ -1,9 +1,4 @@ from django.core.management.base import NoArgsCommand -# Python 2.3 doesn't have sorted() -try: - sorted -except NameError: - from django.utils.itercompat import sorted class Command(NoArgsCommand): help = "Test No-args commands" diff --git a/tests/regressiontests/aggregation_regress/models.py b/tests/regressiontests/aggregation_regress/models.py index 66a5ff7435..ba74357534 100644 --- a/tests/regressiontests/aggregation_regress/models.py +++ b/tests/regressiontests/aggregation_regress/models.py @@ -4,11 +4,6 @@ import pickle from django.db import connection, models, DEFAULT_DB_ALIAS from django.conf import settings -try: - sorted -except NameError: - from django.utils.itercompat import sorted # For Python 2.3 - class Author(models.Model): name = models.CharField(max_length=100) age = models.IntegerField() diff --git a/tests/regressiontests/decorators/tests.py b/tests/regressiontests/decorators/tests.py index 2330b0e073..7855fef638 100644 --- a/tests/regressiontests/decorators/tests.py +++ b/tests/regressiontests/decorators/tests.py @@ -3,7 +3,7 @@ from sys import version_info try: from functools import wraps except ImportError: - from django.utils.functional import wraps # Python 2.3, 2.4 fallback. + from django.utils.functional import wraps # Python 2.4 fallback. from django.http import HttpResponse, HttpRequest from django.utils.functional import allow_lazy, lazy, memoize diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py index abc080db48..25555081e4 100644 --- a/tests/regressiontests/defaultfilters/tests.py +++ b/tests/regressiontests/defaultfilters/tests.py @@ -580,12 +580,6 @@ u'123' from django.template.defaultfilters import * import datetime -# Python 2.3 doesn't have sorted() -try: - sorted -except NameError: - from django.utils.itercompat import sorted - if __name__ == '__main__': import doctest doctest.testmod() diff --git a/tests/regressiontests/forms/extra.py b/tests/regressiontests/forms/extra.py index 2d25530a48..7547901d0f 100644 --- a/tests/regressiontests/forms/extra.py +++ b/tests/regressiontests/forms/extra.py @@ -5,10 +5,7 @@ tests = r""" >>> import datetime >>> import time >>> import re ->>> try: -... from decimal import Decimal -... except ImportError: -... from django.utils._decimal import Decimal +>>> from decimal import Decimal ############### # Extra stuff # diff --git a/tests/regressiontests/forms/fields.py b/tests/regressiontests/forms/fields.py index eb85a05d21..990a9f74cf 100644 --- a/tests/regressiontests/forms/fields.py +++ b/tests/regressiontests/forms/fields.py @@ -28,6 +28,7 @@ import datetime import time import re import os +from decimal import Decimal from unittest import TestCase @@ -35,11 +36,6 @@ from django.core.files.uploadedfile import SimpleUploadedFile from django.forms import * from django.forms.widgets import RadioFieldRenderer -try: - from decimal import Decimal -except ImportError: - from django.utils._decimal import Decimal - def fix_os_paths(x): if isinstance(x, basestring): diff --git a/tests/regressiontests/forms/forms.py b/tests/regressiontests/forms/forms.py index bb58eaa982..58051fd133 100644 --- a/tests/regressiontests/forms/forms.py +++ b/tests/regressiontests/forms/forms.py @@ -5,10 +5,7 @@ tests = r""" >>> import datetime >>> import time >>> import re ->>> try: -... from decimal import Decimal -... except ImportError: -... from django.utils._decimal import Decimal +>>> from decimal import Decimal ######### # Forms # diff --git a/tests/regressiontests/forms/widgets.py b/tests/regressiontests/forms/widgets.py index cc83a888cf..0b2ccebbb1 100644 --- a/tests/regressiontests/forms/widgets.py +++ b/tests/regressiontests/forms/widgets.py @@ -7,10 +7,7 @@ tests = r""" >>> import datetime >>> import time >>> import re ->>> try: -... from decimal import Decimal -... except ImportError: -... from django.utils._decimal import Decimal +>>> from decimal import Decimal >>> from django.utils.translation import activate, deactivate >>> from django.conf import settings diff --git a/tests/regressiontests/model_fields/models.py b/tests/regressiontests/model_fields/models.py index 72c7beb014..45cd223142 100644 --- a/tests/regressiontests/model_fields/models.py +++ b/tests/regressiontests/model_fields/models.py @@ -1,11 +1,6 @@ import os import tempfile -try: - import decimal -except ImportError: - from django.utils import _decimal as decimal # Python 2.3 fallback - # Try to import PIL in either of the two ways it can end up installed. # Checking for the existence of Image is enough for CPython, but for PyPy, # you need to check for the underlying modules. diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py index f0704ff941..72a7d4d657 100644 --- a/tests/regressiontests/model_fields/tests.py +++ b/tests/regressiontests/model_fields/tests.py @@ -1,5 +1,6 @@ import datetime import unittest +from decimal import Decimal import django.test from django import forms @@ -8,12 +9,6 @@ from django.core.exceptions import ValidationError from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel, BooleanModel -try: - from decimal import Decimal -except ImportError: - from django.utils._decimal import Decimal - - # If PIL available, do these tests. if Image: from imagefield import \ diff --git a/tests/regressiontests/model_inheritance_regress/models.py b/tests/regressiontests/model_inheritance_regress/models.py index 41895182f9..15330bd5ee 100644 --- a/tests/regressiontests/model_inheritance_regress/models.py +++ b/tests/regressiontests/model_inheritance_regress/models.py @@ -6,12 +6,6 @@ import datetime from django.db import models -# Python 2.3 doesn't have sorted() -try: - sorted -except NameError: - from django.utils.itercompat import sorted - class Place(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80) diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index 2eb4682c60..f3f0ad8857 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -12,12 +12,6 @@ from django.db import models, DEFAULT_DB_ALIAS from django.db.models import Count from django.db.models.query import Q, ITER_CHUNK_SIZE, EmptyQuerySet -# Python 2.3 doesn't have sorted() -try: - sorted -except NameError: - from django.utils.itercompat import sorted - class DumbCategory(models.Model): pass @@ -1279,12 +1273,12 @@ True """} -# In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__ +# In Python 2.6 beta releases, exceptions raised in __len__ # are swallowed (Python issue 1242657), so these cases return an empty list, # rather than raising an exception. Not a lot we can do about that, # unfortunately, due to the way Python handles list() calls internally. Thus, -# we skip the tests for Python 2.3 and 2.6. -if (2, 4) <= sys.version_info < (2, 6): +# we skip the tests for Python 2.6. +if sys.version_info < (2, 6): __test__["API_TESTS"] += """ # If you're not careful, it's possible to introduce infinite loops via default # ordering on foreign keys in a cycle. We detect that. diff --git a/tests/regressiontests/utils/itercompat.py b/tests/regressiontests/utils/itercompat.py deleted file mode 100644 index ad79cffcd1..0000000000 --- a/tests/regressiontests/utils/itercompat.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -# Tests of the utils itercompat library. - ->>> from django.utils.itercompat import sorted as compat_sorted - -# Check the replacement version of sorted ->>> x = [5,1,4,2,3] ->>> y = compat_sorted(x) ->>> print y -[1, 2, 3, 4, 5] - ->>> print x -[5, 1, 4, 2, 3] - -"""
\ No newline at end of file diff --git a/tests/regressiontests/utils/tests.py b/tests/regressiontests/utils/tests.py index 8897df6789..cfefc6139a 100644 --- a/tests/regressiontests/utils/tests.py +++ b/tests/regressiontests/utils/tests.py @@ -10,25 +10,16 @@ from django.utils.functional import SimpleLazyObject import timesince import datastructures import datetime_safe -import itercompat import tzinfo from decorators import DecoratorFromMiddlewareTests from functional import FunctionalTestCase -# We need this because "datastructures" uses sorted() and the tests are run in -# the scope of this module. -try: - sorted -except NameError: - from django.utils.itercompat import sorted # For Python 2.3 - # Extra tests __test__ = { 'timesince': timesince, 'datastructures': datastructures, 'datetime_safe': datetime_safe, - 'itercompat': itercompat, 'tzinfo': tzinfo, } diff --git a/tests/runtests.py b/tests/runtests.py index b4e0f581be..5585f75d5a 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -5,12 +5,6 @@ import unittest import django.contrib as contrib -try: - set -except NameError: - from sets import Set as set # For Python 2.3 - - CONTRIB_DIR_NAME = 'django.contrib' MODEL_TESTS_DIR_NAME = 'modeltests' REGRESSION_TESTS_DIR_NAME = 'regressiontests' |