mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
[py3] Replaced unicode/str by six.text_type/bytes.
This commit is contained in:
@@ -211,7 +211,7 @@ def _normalize_module(module, depth=2):
|
||||
"""
|
||||
if inspect.ismodule(module):
|
||||
return module
|
||||
elif isinstance(module, (str, unicode)):
|
||||
elif isinstance(module, six.string_types):
|
||||
return __import__(module, globals(), locals(), ["*"])
|
||||
elif module is None:
|
||||
return sys.modules[sys._getframe(depth).f_globals['__name__']]
|
||||
|
||||
@@ -125,14 +125,14 @@ class Element(object):
|
||||
output += ' %s' % key
|
||||
if self.children:
|
||||
output += '>\n'
|
||||
output += ''.join(unicode(c) for c in self.children)
|
||||
output += ''.join(six.text_type(c) for c in self.children)
|
||||
output += '\n</%s>' % self.name
|
||||
else:
|
||||
output += ' />'
|
||||
return output
|
||||
|
||||
def __repr__(self):
|
||||
return unicode(self)
|
||||
return six.text_type(self)
|
||||
|
||||
|
||||
class RootElement(Element):
|
||||
@@ -140,7 +140,7 @@ class RootElement(Element):
|
||||
super(RootElement, self).__init__(None, ())
|
||||
|
||||
def __unicode__(self):
|
||||
return ''.join(unicode(c) for c in self.children)
|
||||
return ''.join(six.text_type(c) for c in self.children)
|
||||
|
||||
|
||||
class Parser(HTMLParser):
|
||||
|
||||
@@ -38,6 +38,7 @@ from django.test.utils import (get_warnings_state, restore_warnings_state,
|
||||
from django.test.utils import ContextList
|
||||
from django.utils import unittest as ut2
|
||||
from django.utils.encoding import smart_str, force_unicode
|
||||
from django.utils import six
|
||||
from django.utils.unittest.util import safe_repr
|
||||
from django.views.static import serve
|
||||
|
||||
@@ -421,8 +422,8 @@ class SimpleTestCase(ut2.TestCase):
|
||||
standardMsg = '%s != %s' % (
|
||||
safe_repr(dom1, True), safe_repr(dom2, True))
|
||||
diff = ('\n' + '\n'.join(difflib.ndiff(
|
||||
unicode(dom1).splitlines(),
|
||||
unicode(dom2).splitlines())))
|
||||
six.text_type(dom1).splitlines(),
|
||||
six.text_type(dom2).splitlines())))
|
||||
standardMsg = self._truncateMessage(standardMsg, diff)
|
||||
self.fail(self._formatMessage(msg, standardMsg))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user