[py3] Fixed remaining Python 3 syntax errors.

django.utils.unittest.* weren't touched -- they're only imported on Python 2.6.
This commit is contained in:
Aymeric Augustin 2012-07-20 13:52:16 +02:00
parent 56dbe924a6
commit cacd845996
4 changed files with 7 additions and 5 deletions

View File

@ -324,7 +324,7 @@ class ManagementUtility(object):
subcommand_cls.option_list] subcommand_cls.option_list]
# filter out previously specified options from available options # filter out previously specified options from available options
prev_opts = [x.split('=')[0] for x in cwords[1:cword-1]] 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 # filter options by current input
options = sorted([(k, v) for k, v in options if k.startswith(curr)]) options = sorted([(k, v) for k, v in options if k.startswith(curr)])

View File

@ -105,6 +105,8 @@ import unittest, difflib, pdb, tempfile
import warnings import warnings
from StringIO import StringIO from StringIO import StringIO
from django.utils import six
if sys.platform.startswith('java'): if sys.platform.startswith('java'):
# On Jython, isclass() reports some modules as classes. Patch it. # On Jython, isclass() reports some modules as classes. Patch it.
def patch_isclass(isclass): def patch_isclass(isclass):
@ -1232,8 +1234,8 @@ class DocTestRunner:
# keyboard interrupts.) # keyboard interrupts.)
try: try:
# Don't blink! This is where the user's code gets run. # Don't blink! This is where the user's code gets run.
exec compile(example.source, filename, "single", six.exec_(compile(example.source, filename, "single",
compileflags, 1) in test.globs compileflags, 1), test.globs)
self.debugger.set_continue() # ==== Example Finished ==== self.debugger.set_continue() # ==== Example Finished ====
exception = None exception = None
except KeyboardInterrupt: except KeyboardInterrupt:

View File

@ -206,7 +206,7 @@ class SelectForUpdateTests(TransactionTestCase):
sanity_count += 1 sanity_count += 1
time.sleep(1) time.sleep(1)
if sanity_count >= 10: 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 # Check the person hasn't been updated. Since this isn't
# using FOR UPDATE, it won't block. # using FOR UPDATE, it won't block.

View File

@ -554,7 +554,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
def test_smart_unicode(self): def test_smart_unicode(self):
class Test: class Test:
def __str__(self): def __str__(self):
return b'ŠĐĆŽćžšđ' return 'ŠĐĆŽćžšđ'.encode('utf-8')
class TestU: class TestU:
def __str__(self): def __str__(self):