From 0fdabe885baabae291da23570966a9e4a4e4df6d Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 28 Mar 2011 02:27:43 +0000 Subject: [PATCH] Made a bunch of simplifications now that we don't support Python 2.4 git-svn-id: http://code.djangoproject.com/svn/django/trunk@15933 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/decorators/tests.py | 6 +-- .../i18n/commands/extraction.py | 9 ++--- tests/regressiontests/i18n/tests.py | 40 ++++++------------- 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/tests/regressiontests/decorators/tests.py b/tests/regressiontests/decorators/tests.py index c7dc2819cf..dac4029904 100644 --- a/tests/regressiontests/decorators/tests.py +++ b/tests/regressiontests/decorators/tests.py @@ -1,8 +1,4 @@ -from sys import version_info -try: - from functools import wraps -except ImportError: - from django.utils.functional import wraps # Python 2.4 fallback. +from functools import wraps from django.contrib.auth.decorators import login_required, permission_required, user_passes_test from django.contrib.admin.views.decorators import staff_member_required diff --git a/tests/regressiontests/i18n/commands/extraction.py b/tests/regressiontests/i18n/commands/extraction.py index 0d70d2641d..46242d0359 100644 --- a/tests/regressiontests/i18n/commands/extraction.py +++ b/tests/regressiontests/i18n/commands/extraction.py @@ -75,11 +75,10 @@ class BasicExtractorTests(ExtractorTests): os.chdir(self.test_dir) shutil.copyfile('./templates/template_with_error.txt', './templates/template_with_error.html') self.assertRaises(SyntaxError, management.call_command, 'makemessages', locale=LOCALE, verbosity=0) - try: # TODO: Simplify this try/try block when we drop support for Python 2.4 - try: - management.call_command('makemessages', locale=LOCALE, verbosity=0) - except SyntaxError, e: - self.assertEqual(str(e), 'Translation blocks must not include other block tags: blocktrans (file templates/template_with_error.html, line 3)') + try: + management.call_command('makemessages', locale=LOCALE, verbosity=0) + except SyntaxError, e: + self.assertEqual(str(e), 'Translation blocks must not include other block tags: blocktrans (file templates/template_with_error.html, line 3)') finally: os.remove('./templates/template_with_error.html') os.remove('./templates/template_with_error.html.py') # Waiting for #8536 to be fixed diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py index 88c1c138bd..c92823b9c7 100644 --- a/tests/regressiontests/i18n/tests.py +++ b/tests/regressiontests/i18n/tests.py @@ -590,19 +590,12 @@ class MiscTests(TestCase): r.META = {'HTTP_ACCEPT_LANGUAGE': 'es-ar,de'} self.assertEqual('es-ar', g(r)) - # Python 2.3 and 2.4 return slightly different results for completely - # bogus locales, so we omit this test for that anything below 2.4. - # It's relatively harmless in any cases (GIGO). This also means this - # won't be executed on Jython currently, but life's like that - # sometimes. (On those platforms, passing in a truly bogus locale - # will get you the default locale back.) - if sys.version_info >= (2, 5): - # This test assumes there won't be a Django translation to a US - # variation of the Spanish language, a safe assumption. When the - # user sets it as the preferred language, the main 'es' - # translation should be selected instead. - r.META = {'HTTP_ACCEPT_LANGUAGE': 'es-us'} - self.assertEqual(g(r), 'es') + # This test assumes there won't be a Django translation to a US + # variation of the Spanish language, a safe assumption. When the + # user sets it as the preferred language, the main 'es' + # translation should be selected instead. + r.META = {'HTTP_ACCEPT_LANGUAGE': 'es-us'} + self.assertEqual(g(r), 'es') # This tests the following scenario: there isn't a main language (zh) # translation of Django but there is a translation to variation (zh_CN) @@ -631,20 +624,13 @@ class MiscTests(TestCase): r.META = {'HTTP_ACCEPT_LANGUAGE': 'de'} self.assertEqual('es', g(r)) - # Python 2.3 and 2.4 return slightly different results for completely - # bogus locales, so we omit this test for that anything below 2.4. - # It's relatively harmless in any cases (GIGO). This also means this - # won't be executed on Jython currently, but life's like that - # sometimes. (On those platforms, passing in a truly bogus locale - # will get you the default locale back.) - if sys.version_info >= (2, 5): - # This test assumes there won't be a Django translation to a US - # variation of the Spanish language, a safe assumption. When the - # user sets it as the preferred language, the main 'es' - # translation should be selected instead. - r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: 'es-us'} - r.META = {} - self.assertEqual(g(r), 'es') + # This test assumes there won't be a Django translation to a US + # variation of the Spanish language, a safe assumption. When the + # user sets it as the preferred language, the main 'es' + # translation should be selected instead. + r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: 'es-us'} + r.META = {} + self.assertEqual(g(r), 'es') # This tests the following scenario: there isn't a main language (zh) # translation of Django but there is a translation to variation (zh_CN)