diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2011-03-28 02:11:19 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2011-03-28 02:11:19 +0000 |
| commit | 13864703bc1d5dd4dac63c96c6a4b42a392bc57f (patch) | |
| tree | 64d070fb754332d47afc310daef2671c54e17988 /tests | |
| parent | a87be3554fc73a567b926ea51c13ea844b5113f8 (diff) | |
Removed a bunch more Python 2.4 workarounds now that we don't support that version. Refs #15702 -- thanks to jonash for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15927 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/cache/tests.py | 6 | ||||
| -rw-r--r-- | tests/regressiontests/comment_tests/tests/comment_form_tests.py | 4 | ||||
| -rw-r--r-- | tests/regressiontests/dispatch/tests/test_dispatcher.py | 1 | ||||
| -rw-r--r-- | tests/regressiontests/extra_regress/models.py | 3 | ||||
| -rw-r--r-- | tests/regressiontests/file_uploads/tests.py | 7 | ||||
| -rw-r--r-- | tests/regressiontests/file_uploads/views.py | 6 | ||||
| -rw-r--r-- | tests/regressiontests/forms/tests/widgets.py | 5 | ||||
| -rw-r--r-- | tests/regressiontests/introspection/tests.py | 4 | ||||
| -rw-r--r-- | tests/regressiontests/utils/datastructures.py | 3 | ||||
| -rw-r--r-- | tests/regressiontests/utils/simplelazyobject.py | 2 |
10 files changed, 21 insertions, 20 deletions
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py index 2832bcbdd9..2f46c0b1aa 100644 --- a/tests/regressiontests/cache/tests.py +++ b/tests/regressiontests/cache/tests.py @@ -3,6 +3,7 @@ # Unit tests for cache framework # Uses whatever cache backend is set in the test settings file. +import hashlib import os import tempfile import time @@ -19,7 +20,6 @@ from django.test.utils import get_warnings_state, restore_warnings_state from django.utils import translation from django.utils import unittest from django.utils.cache import patch_vary_headers, get_cache_key, learn_cache_key -from django.utils.hashcompat import md5_constructor from django.views.decorators.cache import cache_page from regressiontests.cache.models import Poll, expensive_calculation @@ -850,7 +850,7 @@ class FileBasedCacheTests(unittest.TestCase, BaseCacheTests): """Test that keys are hashed into subdirectories correctly""" self.cache.set("foo", "bar") key = self.cache.make_key("foo") - keyhash = md5_constructor(key).hexdigest() + keyhash = hashlib.md5(key).hexdigest() keypath = os.path.join(self.dirname, keyhash[:2], keyhash[2:4], keyhash[4:]) self.assertTrue(os.path.exists(keypath)) @@ -860,7 +860,7 @@ class FileBasedCacheTests(unittest.TestCase, BaseCacheTests): """ self.cache.set("foo", "bar") key = self.cache.make_key("foo") - keyhash = md5_constructor(key).hexdigest() + keyhash = hashlib.md5(key).hexdigest() keypath = os.path.join(self.dirname, keyhash[:2], keyhash[2:4], keyhash[4:]) self.assertTrue(os.path.exists(keypath)) diff --git a/tests/regressiontests/comment_tests/tests/comment_form_tests.py b/tests/regressiontests/comment_tests/tests/comment_form_tests.py index 57dad3625c..956ca53bfd 100644 --- a/tests/regressiontests/comment_tests/tests/comment_form_tests.py +++ b/tests/regressiontests/comment_tests/tests/comment_form_tests.py @@ -1,9 +1,9 @@ +import hashlib import time from django.conf import settings from django.contrib.comments.forms import CommentForm from django.contrib.comments.models import Comment -from django.utils.hashcompat import sha_constructor from regressiontests.comment_tests.models import Article from regressiontests.comment_tests.tests import CommentTestCase @@ -57,7 +57,7 @@ class CommentFormTests(CommentTestCase): # The Django 1.2 method hard-coded here: info = (content_type, object_pk, timestamp, settings.SECRET_KEY) - security_hash = sha_constructor("".join(info)).hexdigest() + security_hash = hashlib.sha1("".join(info)).hexdigest() d['security_hash'] = security_hash f = CommentForm(a, data=d) diff --git a/tests/regressiontests/dispatch/tests/test_dispatcher.py b/tests/regressiontests/dispatch/tests/test_dispatcher.py index 2ad5b0c67a..a16d8e24f5 100644 --- a/tests/regressiontests/dispatch/tests/test_dispatcher.py +++ b/tests/regressiontests/dispatch/tests/test_dispatcher.py @@ -3,7 +3,6 @@ import sys from django.dispatch import Signal from django.utils import unittest -import django.utils.copycompat as copy if sys.platform.startswith('java'): def garbage_collect(): diff --git a/tests/regressiontests/extra_regress/models.py b/tests/regressiontests/extra_regress/models.py index 073157a38a..11218202f0 100644 --- a/tests/regressiontests/extra_regress/models.py +++ b/tests/regressiontests/extra_regress/models.py @@ -1,7 +1,6 @@ +import copy import datetime -import django.utils.copycompat as copy - from django.contrib.auth.models import User from django.db import models diff --git a/tests/regressiontests/file_uploads/tests.py b/tests/regressiontests/file_uploads/tests.py index 6dba4731fd..5da0a5fafc 100644 --- a/tests/regressiontests/file_uploads/tests.py +++ b/tests/regressiontests/file_uploads/tests.py @@ -1,5 +1,7 @@ #! -*- coding: utf-8 -*- + import errno +import hashlib import os import shutil from StringIO import StringIO @@ -10,7 +12,6 @@ from django.http.multipartparser import MultiPartParser from django.test import TestCase, client from django.utils import simplejson from django.utils import unittest -from django.utils.hashcompat import sha_constructor from models import FileModel, temp_storage, UPLOAD_TO import uploadhandler @@ -46,10 +47,10 @@ class FileUploadTests(TestCase): for key in post_data.keys(): try: - post_data[key + '_hash'] = sha_constructor(post_data[key].read()).hexdigest() + post_data[key + '_hash'] = hashlib.sha1(post_data[key].read()).hexdigest() post_data[key].seek(0) except AttributeError: - post_data[key + '_hash'] = sha_constructor(post_data[key]).hexdigest() + post_data[key + '_hash'] = hashlib.sha1(post_data[key]).hexdigest() response = self.client.post('/file_uploads/verify/', post_data) diff --git a/tests/regressiontests/file_uploads/views.py b/tests/regressiontests/file_uploads/views.py index 9f4ce69b5f..0fd0b6502d 100644 --- a/tests/regressiontests/file_uploads/views.py +++ b/tests/regressiontests/file_uploads/views.py @@ -1,10 +1,10 @@ +import hashlib import os from django.core.files.uploadedfile import UploadedFile from django.http import HttpResponse, HttpResponseServerError from django.utils import simplejson from models import FileModel, UPLOAD_TO from uploadhandler import QuotaUploadHandler, ErroringUploadHandler -from django.utils.hashcompat import sha_constructor from tests import UNICODE_FILENAME def file_upload_view(request): @@ -37,9 +37,9 @@ def file_upload_view_verify(request): continue submitted_hash = form_data[key + '_hash'] if isinstance(value, UploadedFile): - new_hash = sha_constructor(value.read()).hexdigest() + new_hash = hashlib.sha1(value.read()).hexdigest() else: - new_hash = sha_constructor(value).hexdigest() + new_hash = hashlib.sha1(value).hexdigest() if new_hash != submitted_hash: return HttpResponseServerError() diff --git a/tests/regressiontests/forms/tests/widgets.py b/tests/regressiontests/forms/tests/widgets.py index 4c5aeb0147..0a8a87949c 100644 --- a/tests/regressiontests/forms/tests/widgets.py +++ b/tests/regressiontests/forms/tests/widgets.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- + +import copy import datetime -from decimal import Decimal import re import time +from decimal import Decimal from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile from django.forms import * from django.forms.widgets import RadioFieldRenderer -from django.utils import copycompat as copy from django.utils import formats from django.utils.safestring import mark_safe from django.utils.translation import activate, deactivate diff --git a/tests/regressiontests/introspection/tests.py b/tests/regressiontests/introspection/tests.py index 90dea9203c..7481641fb5 100644 --- a/tests/regressiontests/introspection/tests.py +++ b/tests/regressiontests/introspection/tests.py @@ -1,7 +1,7 @@ +from functools import update_wrapper from django.conf import settings from django.db import connection, DEFAULT_DB_ALIAS from django.test import TestCase, skipUnlessDBFeature -from django.utils import functional from models import Reporter, Article @@ -23,7 +23,7 @@ def ignore_not_implemented(func): return func(*args, **kwargs) except NotImplementedError: return None - functional.update_wrapper(_inner, func) + update_wrapper(_inner, func) return _inner class IgnoreNotimplementedError(type): diff --git a/tests/regressiontests/utils/datastructures.py b/tests/regressiontests/utils/datastructures.py index 3d01ab8b6f..6ae652cdba 100644 --- a/tests/regressiontests/utils/datastructures.py +++ b/tests/regressiontests/utils/datastructures.py @@ -1,10 +1,11 @@ """ Tests for stuff in django.utils.datastructures. """ + +import copy import pickle import unittest -from django.utils.copycompat import copy from django.utils.datastructures import * diff --git a/tests/regressiontests/utils/simplelazyobject.py b/tests/regressiontests/utils/simplelazyobject.py index 9eea8b5901..e29729df60 100644 --- a/tests/regressiontests/utils/simplelazyobject.py +++ b/tests/regressiontests/utils/simplelazyobject.py @@ -1,6 +1,6 @@ +import copy import unittest -import django.utils.copycompat as copy from django.utils.functional import SimpleLazyObject class _ComplexObject(object): |
