From cacd845996d1245f6aed257bff5f748f46206d3f Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Fri, 20 Jul 2012 13:52:16 +0200 Subject: [PATCH] [py3] Fixed remaining Python 3 syntax errors. django.utils.unittest.* weren't touched -- they're only imported on Python 2.6. --- django/core/management/__init__.py | 2 +- django/test/_doctest.py | 6 ++++-- tests/modeltests/select_for_update/tests.py | 2 +- tests/regressiontests/forms/tests/extra.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index 0464eb27bb..68048e5672 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -324,7 +324,7 @@ class ManagementUtility(object): subcommand_cls.option_list] # filter out previously specified options from available options prev_opts = [x.split('=')[0] for x in cwords[1:cword-1]] - options = filter(lambda (x, v): x not in prev_opts, options) + options = [opt for opt in options if opt[0] not in prev_opts] # filter options by current input options = sorted([(k, v) for k, v in options if k.startswith(curr)]) diff --git a/django/test/_doctest.py b/django/test/_doctest.py index b5d5da970b..4456511532 100644 --- a/django/test/_doctest.py +++ b/django/test/_doctest.py @@ -105,6 +105,8 @@ import unittest, difflib, pdb, tempfile import warnings from StringIO import StringIO +from django.utils import six + if sys.platform.startswith('java'): # On Jython, isclass() reports some modules as classes. Patch it. def patch_isclass(isclass): @@ -1232,8 +1234,8 @@ class DocTestRunner: # keyboard interrupts.) try: # Don't blink! This is where the user's code gets run. - exec compile(example.source, filename, "single", - compileflags, 1) in test.globs + six.exec_(compile(example.source, filename, "single", + compileflags, 1), test.globs) self.debugger.set_continue() # ==== Example Finished ==== exception = None except KeyboardInterrupt: diff --git a/tests/modeltests/select_for_update/tests.py b/tests/modeltests/select_for_update/tests.py index cb8f19f1e8..e3e4d9e7e2 100644 --- a/tests/modeltests/select_for_update/tests.py +++ b/tests/modeltests/select_for_update/tests.py @@ -206,7 +206,7 @@ class SelectForUpdateTests(TransactionTestCase): sanity_count += 1 time.sleep(1) if sanity_count >= 10: - raise ValueError, 'Thread did not run and block' + raise ValueError('Thread did not run and block') # Check the person hasn't been updated. Since this isn't # using FOR UPDATE, it won't block. diff --git a/tests/regressiontests/forms/tests/extra.py b/tests/regressiontests/forms/tests/extra.py index 25b21123c4..28b6c12453 100644 --- a/tests/regressiontests/forms/tests/extra.py +++ b/tests/regressiontests/forms/tests/extra.py @@ -554,7 +554,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin): def test_smart_unicode(self): class Test: def __str__(self): - return b'ŠĐĆŽćžšđ' + return 'ŠĐĆŽćžšđ'.encode('utf-8') class TestU: def __str__(self):