Commits

Gustavo Picon committed 53568b0

Added Python 3 and Django 1.5 support.

Comments (0)

Files changed (13)

 Release 2.0 (XXX XX, 2012)
 ---------------------------
 
+* Added support for Django 1.5 and Python 3.X
 * Revamped admin interface for MP and NS trees, supporting drag&drop to reorder
   nodes. Work on this patch was sponsored by the Oregon Center for
   Applied Science (http://www.orcasinc.com/), developed by Aureal
 * Moved treebeard.tests to it's own directory (instead of tests.py)
 * Added the runtests.py test runner
 * Added tox support
-* Fixed the test suite to run in Python 2.4
 * Fixed drag&drop bug in the admin
 * Fixed a bug when moving MP_Nodes
 * Using .pk instead of .id when accessing nodes.
         'Environment :: Web Environment',
         'Framework :: Django',
         'Programming Language :: Python',
-        'Programming Language :: Python :: 2.4',
         'Programming Language :: Python :: 2.5',
         'Programming Language :: Python :: 2.6',
         'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3.1',
+        'Programming Language :: Python :: 3.2',
+        'Programming Language :: Python :: 3.3',
         'Operating System :: OS Independent',
         'Topic :: Software Development :: Libraries',
         'Topic :: Utilities'])
     py27-dj14-mysql,
     py27-dj14-postgres,
     py27-dj15-sqlite,
-    py33-dj15-sqlite
+    py31-dj15-sqlite,
+    py31-dj15-postgres,
+    py32-dj15-sqlite,
+    py32-dj15-postgres,
+    py33-dj15-sqlite,
+    py33-dj15-postgres
 
 [testenv]
 commands =
 setenv =
     DATABASE_ENGINE=sqlite3
 
+[testenv:py31-dj15-sqlite]
+basepython=python3.1
+deps =
+    https://www.djangoproject.com/download/1.5a1/tarball/#egg=django
+    coverage
+    pytest
+setenv =
+    DATABASE_ENGINE=sqlite3
+
+[testenv:py31-dj15-postgres]
+basepython=python3.1
+deps =
+    https://www.djangoproject.com/download/1.5a1/tarball/#egg=django
+    psycopg2
+    coverage
+    pytest
+setenv =
+    DATABASE_ENGINE=postgresql_psycopg2
+
+[testenv:py32-dj15-sqlite]
+basepython=python3.2
+deps =
+    https://www.djangoproject.com/download/1.5a1/tarball/#egg=django
+    coverage
+    pytest
+setenv =
+    DATABASE_ENGINE=sqlite3
+
+[testenv:py32-dj15-postgres]
+basepython=python3.2
+deps =
+    https://www.djangoproject.com/download/1.5a1/tarball/#egg=django
+    psycopg2
+    coverage
+    pytest
+setenv =
+    DATABASE_ENGINE=postgresql_psycopg2
+
 [testenv:py33-dj15-sqlite]
 basepython=python3.3
 deps =
     pytest
 setenv =
     DATABASE_ENGINE=sqlite3
+
+[testenv:py33-dj15-postgres]
+basepython=python3.3
+deps =
+    https://www.djangoproject.com/download/1.5a1/tarball/#egg=django
+    psycopg2
+    coverage
+    pytest
+setenv =
+    DATABASE_ENGINE=postgresql_psycopg2
+
+

treebeard/admin.py

 "Django admin support for treebeard"
 
+import sys
+
 from django.conf.urls.defaults import patterns, url
 from django.contrib import admin, messages
 from django.contrib.admin.views.main import ChangeList
 from django.http import HttpResponse, HttpResponseBadRequest
-from django.utils.encoding import force_unicode
 from django.utils.translation import ugettext_lazy as _
 from treebeard.templatetags.admin_tree import check_empty_dict
 from treebeard.exceptions import (InvalidPosition, MissingNodeOrderBy,
                                   InvalidMoveToDescendant, PathOverflow)
 from treebeard.forms import MoveNodeForm
 
+if sys.version_info >= (3, 0):
+    from django.utils.encoding import force_str
+else:
+    from django.utils.encoding import force_unicode as force_str
+
 
 class TreeChangeList(ChangeList):
     def get_ordering(self, *args):
             sibling_id = request.POST['sibling_id']
             as_child = request.POST.get('as_child', False)
             as_child = bool(int(as_child))
-        except (KeyError, ValueError), e:
+        except (KeyError, ValueError):
             # Some parameters were missing return a BadRequest
-            return HttpResponseBadRequest(u'Malformed POST params')
+            return HttpResponseBadRequest('Malformed POST params')
 
         node = self.model.objects.get(pk=node_id)
         # Parent is not used at this time, need to handle special case
                     node.move(sibling, pos='target')
                 else:
                     node.move(sibling, pos='left')
-            except InvalidPosition, e:
+            except InvalidPosition:
                 # This could be due two reasons (from the docs):
                 # :raise InvalidPosition:
                 #       when passing an invalid ``pos`` parm
             if as_child:
                 messages.info(
                     request,
-                    _(u'Moved node "%(node)s" as child of "%(other)s"') % {
+                    _('Moved node "%(node)s" as child of "%(other)s"') % {
                         'node': node,
                         'other': sibling
                     }
             else:
                 messages.info(
                     request,
-                    _(u'Moved node "%(node)s" as sibling of "%(other)s"') % {
+                    _('Moved node "%(node)s" as sibling of "%(other)s"') % {
                         'node': node,
                         'other': sibling
                     }
                 )
 
         except (MissingNodeOrderBy, PathOverflow, InvalidMoveToDescendant,
-                InvalidPosition), e:
+                InvalidPosition):
+            e = sys.exc_info()[1]
             # An error was raised while trying to move the node, then set an
             # error message and return 400, this will cause a reload on the
             # client to show the message
             # error message and return 400, this will cause a reload on
             # the client to show the message
             messages.error(request,
-                           _(u'Exception raised while moving node: %s') % _(
-                               force_unicode(e)))
-            return HttpResponseBadRequest(u'Exception raised during move')
+                           _('Exception raised while moving node: %s') % _(
+                               force_str(e)))
+            return HttpResponseBadRequest('Exception raised during move')
 
         return HttpResponse('OK')

treebeard/forms.py

     """
 
     __position_choices_sorted = (
-        ('sorted-child', _(u'Child of')),
-        ('sorted-sibling', _(u'Sibling of')),
+        ('sorted-child', _('Child of')),
+        ('sorted-sibling', _('Sibling of')),
     )
 
     __position_choices_unsorted = (
-        ('first-child', _(u'First child of')),
-        ('left', _(u'Before')),
-        ('right', _(u'After')),
+        ('first-child', _('First child of')),
+        ('left', _('Before')),
+        ('right', _('After')),
     )
 
-    _position = forms.ChoiceField(required=True, label=_(u"Position"))
+    _position = forms.ChoiceField(required=True, label=_("Position"))
 
     _ref_node_id = forms.TypedChoiceField(required=False,
                                           coerce=int,
-                                          label=_(u"Relative to"))
+                                          label=_("Relative to"))
 
     class Meta:
         exclude = ('path',
                     for subnode in node.get_children():
                         add_subtree(subnode, options)
 
-            options = [(0, _(u'-- root --'))]
+            options = [(0, _('-- root --'))]
             for node in opts.model.get_root_nodes():
                 add_subtree(node, options)
             return options

treebeard/models.py

 "Models and base API"
 
+import sys
 import operator
 
+if sys.version_info >= (3, 0):
+    from functools import reduce
+
 from django.db.models import Q
 from django.db import models, transaction
 from django.conf import settings
             if start_depth is None:
                 start_depth = depth
 
-            open = (depth > prev_depth)
+            open = (depth  and (prev_depth is None or depth > prev_depth))
 
-            if depth < prev_depth:
-                info['close'] = range(0, prev_depth - depth)
+            if prev_depth is not None and depth < prev_depth:
+                info['close'] = list(range(0, prev_depth - depth))
 
             info = {'open': open, 'close': [], 'level': depth - start_depth}
 
 
             prev_depth = depth
 
-        if start_depth > 0:
-            info['close'] = range(0, prev_depth - start_depth + 1)
+        if start_depth and start_depth > 0:
+            info['close'] = list(range(0, prev_depth - start_depth + 1))
 
         return result
 

treebeard/mp_tree.py

 "Materialized Path Trees"
 
+import sys
 import operator
 
+if sys.version_info >= (3, 0):
+    from functools import reduce
+
 from django.core import serializers
 from django.db import models, transaction, connection
 from django.db.models import Q
 from django.utils.translation import ugettext_noop as _
 
-from numconv import NumConv
+from treebeard.numconv import NumConv
 from treebeard.models import Node
 from treebeard.exceptions import InvalidMoveToDescendant, PathOverflow
 
         removed = {}
         for node in self.order_by('depth', 'path'):
             found = False
-            for depth in range(1, len(node.path) / node.steplen):
+            for depth in range(1, int(len(node.path) / node.steplen)):
                 path = node._get_basepath(node.path, depth)
                 if path in removed:
                     # we are already removing a parent of this node
             # django's serializer stores the attributes in 'fields'
             fields = pyobj['fields']
             path = fields['path']
-            depth = len(path) / cls.steplen
+            depth = int(len(path) / cls.steplen)
             # this will be useless in load_bulk
             del fields['depth']
             del fields['path']
                 orphans.append(node.pk)
                 continue
 
-            if node.depth != len(node.path) / cls.steplen:
+            if node.depth != int(len(node.path) / cls.steplen):
                 wrong_depth.append(node.pk)
                 continue
 
         :returns: the parent node of the current node object.
             Caches the result in the object itself to help in loops.
         """
-        depth = len(self.path) / self.steplen
+        depth = int(len(self.path) / self.steplen)
         if depth <= 1:
             return
         try:
             if movebranch and len(oldpath) == len(newpath):
                 parentoldpath = cls._get_basepath(
                     oldpath,
-                    (len(oldpath) / cls.steplen) - 1
+                    int(len(oldpath) / cls.steplen) - 1
                 )
                 parentnewpath = cls._get_basepath(newpath, newdepth - 1)
                 if (

treebeard/ns_tree.py

 "Nested Sets"
 
+import sys
 import operator
 
+if sys.version_info >= (3, 0):
+    from functools import reduce
+
 from django.core import serializers
 from django.db import connection, models, transaction
 from django.db.models import Q

treebeard/templatetags/admin_tree.py

 
 """
 
-from urlparse import urljoin
+import sys
 
 from django.db import models
 from django.conf import settings
 from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
 from django.core.exceptions import ObjectDoesNotExist
 from django.template import Library
-from django.utils.encoding import force_unicode, smart_unicode
 from django.utils.html import conditional_escape, escape
 from django.utils.safestring import mark_safe
 from django.utils.translation import ugettext_lazy as _
 
 register = Library()
 
+if sys.version_info >= (3, 0):
+    from django.utils.encoding import force_str, smart_str
+    from urllib.parse import urljoin
+else:
+    from django.utils.encoding import force_unicode as force_str
+    from django.utils.encoding import smart_unicode as smart_str
+    from urlparse import urljoin
+
 
 def items_for_result(cl, result, form):
     """
                     allow_tags = True
                     result_repr = _boolean_icon(value)
                 else:
-                    result_repr = smart_unicode(value)
+                    result_repr = smart_str(value)
                     # Strip HTML tags in the resulting text, except if the
                 # function has an "allow_tags" attribute set to True.
                 if not allow_tags:
                         isinstance(f, models.TimeField)
                 ):
                     row_class = ' class="nowrap"'
-        if force_unicode(result_repr) == '':
+        if force_str(result_repr) == '':
             result_repr = mark_safe('&nbsp;')
             # If list_display_links not defined, add the link tag to the
         # first field
             else:
                 attr = pk
             value = result.serializable_value(attr)
-            result_id = repr(force_unicode(value))[1:]
+            result_id = repr(force_str(value))[1:]
             onclickstr = (
                 ' onclick="opener.dismissRelatedLookupPopup(window, %s);'
                 ' return false;"')
             yield mark_safe(
-                u'%s<%s%s>%s %s <a href="%s"%s>%s</a></%s>' % (
+                '%s<%s%s>%s %s <a href="%s"%s>%s</a></%s>' % (
                     drag_handler, table_tag, row_class, spacer, collapse, url,
                     (cl.is_popup and onclickstr % result_id or ''),
                     conditional_escape(result_repr), table_tag))
             if form and field_name in form.fields:
                 bf = form[field_name]
                 result_repr = mark_safe(
-                    force_unicode(bf.errors) + force_unicode(bf))
+                    force_str(bf.errors) + force_str(bf))
             else:
                 result_repr = conditional_escape(result_repr)
-            yield mark_safe(u'<td%s>%s</td>' % (row_class, result_repr))
+            yield mark_safe('<td%s>%s</td>' % (row_class, result_repr))
     if form and not form[cl.model._meta.pk.name].is_hidden:
         yield mark_safe(
-            u'<td>%s</td>' % force_unicode(form[cl.model._meta.pk.name]))
+            '<td>%s</td>' % force_str(form[cl.model._meta.pk.name]))
 
 
 def results(cl):

treebeard/tests/conftest.py

+import os
+import sys
 import time
 
-import os
-
 
 os.environ['DJANGO_SETTINGS_MODULE'] = 'treebeard.tests.settings'
 
         connection.autocommit = True
         connection._set_isolation_level(0)
         time.sleep(1)
-        print "Destroying test database for alias '%s' (%s)..." % (
-            connection.alias, dbtestname)
+        sys.stdout.write(
+            "Destroying test database for alias '%s' (%s)...\n" % (
+                connection.alias, dbtestname)
+        )
+        sys.stdout.flush()
         cursor.execute(
             'DROP DATABASE %s' % connection.ops.quote_name(dbtestname))
     else:

treebeard/tests/models.py

 
     desc = models.CharField(max_length=255)
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
 class MP_TestNodeSomeDep(models.Model):
     node = models.ForeignKey(MP_TestNode)
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
 class NS_TestNode(NS_Node):
     desc = models.CharField(max_length=255)
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
 class NS_TestNodeSomeDep(models.Model):
     node = models.ForeignKey(NS_TestNode)
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
     sib_order = models.PositiveIntegerField()
     desc = models.CharField(max_length=255)
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
 class AL_TestNodeSomeDep(models.Model):
     node = models.ForeignKey(AL_TestNode)
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
     val2 = models.IntegerField()
     desc = models.CharField(max_length=255)
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
     val2 = models.IntegerField()
     desc = models.CharField(max_length=255)
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
     val2 = models.IntegerField()
     desc = models.CharField(max_length=255)
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
 
     numval = models.IntegerField()
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
     steplen = 1
     alphabet = '0123456789'
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
 
     node_order_by = ['created']
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
     alphabet = '01234'
     desc = models.CharField(max_length=255)
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 
 
     node_order_by = ['desc']
 
-    def __unicode__(self):  # pragma: no cover
+    def __str__(self):  # pragma: no cover
         return 'Node %d' % self.pk
 
 

treebeard/tests/settings.py

         # tests at the same time
         conf['TEST_NAME'] = "test_%s_%s" % (
             conf['NAME'],
-            ''.join(random.choice(string.letters) for _ in range(15))
+            ''.join(random.choice(string.ascii_letters) for _ in range(15))
         )
 
         if conf['USER'] == '':

treebeard/tests/test_treebeard.py

 "Unit/Functional tests"
 
 import os
+import sys
+
 from django import VERSION as DJANGO_VERSION
 from django.contrib.admin.options import ModelAdmin
 from django.contrib.admin.sites import AdminSite
 from treebeard.exceptions import InvalidPosition, InvalidMoveToDescendant,\
     PathOverflow, MissingNodeOrderBy
 from treebeard.forms import MoveNodeForm
-import models
+from treebeard.tests import models
 
 
 # ghetto app detection, there is probably some introspection method,
 class TestTreeBase(TestCase):
     def setUp(self):
         self.set_MP()
-        self.unchanged = [(u'1', 1, 0),
-                          (u'2', 1, 4),
-                          (u'21', 2, 0),
-                          (u'22', 2, 0),
-                          (u'23', 2, 1),
-                          (u'231', 3, 0),
-                          (u'24', 2, 0),
-                          (u'3', 1, 0),
-                          (u'4', 1, 1),
-                          (u'41', 2, 0)]
+        self.unchanged = [('1', 1, 0),
+                          ('2', 1, 4),
+                          ('21', 2, 0),
+                          ('22', 2, 0),
+                          ('23', 2, 1),
+                          ('231', 3, 0),
+                          ('24', 2, 0),
+                          ('3', 1, 0),
+                          ('4', 1, 1),
+                          ('41', 2, 0)]
 
     def set_MP(self, proxy=False):
         if proxy:
                 d.setdefault(tree_id, []).extend([lft, rgt])
             for tree_id, got_edges in d.items():
                 self.assertEqual(len(got_edges), max(got_edges))
-                good_edges = range(1, len(got_edges) + 1)
+                good_edges = list(range(1, len(got_edges) + 1))
                 self.assertEqual(sorted(got_edges), good_edges)
 
         return [(o.desc, o.get_depth(), o.get_children_count())
 
     def _multi_add_root_empty(self):
         self.model.add_root(desc='1')
-        expected = [(u'1', 1, 0)]
+        expected = [('1', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_get_root_nodes_empty(self):
     def _multi_load_bulk_existing(self):
         # inserting on an existing node
 
-        node = self.model.objects.get(desc=u'231')
+        node = self.model.objects.get(desc='231')
         ids = self.model.load_bulk(BASE_DATA, node)
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 4),
-                    (u'1', 4, 0),
-                    (u'2', 4, 4),
-                    (u'21', 5, 0),
-                    (u'22', 5, 0),
-                    (u'23', 5, 1),
-                    (u'231', 6, 0),
-                    (u'24', 5, 0),
-                    (u'3', 4, 0),
-                    (u'4', 4, 1),
-                    (u'41', 5, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
-        expected_descs = [u'1', u'2', u'21', u'22', u'23', u'231', u'24',
-                          u'3', u'4', u'41']
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 4),
+                    ('1', 4, 0),
+                    ('2', 4, 4),
+                    ('21', 5, 0),
+                    ('22', 5, 0),
+                    ('23', 5, 1),
+                    ('231', 6, 0),
+                    ('24', 5, 0),
+                    ('3', 4, 0),
+                    ('4', 4, 1),
+                    ('41', 5, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
+        expected_descs = ['1', '2', '21', '22', '23', '231', '24',
+                          '3', '4', '41']
         got_descs = [obj.desc
                      for obj in self.model.objects.filter(id__in=ids)]
         self.assertEqual(sorted(got_descs), sorted(expected_descs))
         self.assertEqual(self.model.dump_bulk(keep_ids=False), BASE_DATA)
 
     def _multi_get_tree_node(self):
-        node = self.model.objects.get(desc=u'231')
+        node = self.model.objects.get(desc='231')
         self.model.load_bulk(BASE_DATA, node)
 
         # the tree was modified by load_bulk, so we reload our node object
 
         got = [(o.desc, o.get_depth(), o.get_children_count())
                for o in self.model.get_tree(node)]
-        expected = [(u'231', 3, 4),
-                    (u'1', 4, 0),
-                    (u'2', 4, 4),
-                    (u'21', 5, 0),
-                    (u'22', 5, 0),
-                    (u'23', 5, 1),
-                    (u'231', 6, 0),
-                    (u'24', 5, 0),
-                    (u'3', 4, 0),
-                    (u'4', 4, 1),
-                    (u'41', 5, 0)]
+        expected = [('231', 3, 4),
+                    ('1', 4, 0),
+                    ('2', 4, 4),
+                    ('21', 5, 0),
+                    ('22', 5, 0),
+                    ('23', 5, 1),
+                    ('231', 6, 0),
+                    ('24', 5, 0),
+                    ('3', 4, 0),
+                    ('4', 4, 1),
+                    ('41', 5, 0)]
         self.assertEqual(got, expected)
 
     def _multi_get_tree_leaf(self):
-        node = self.model.objects.get(desc=u'1')
+        node = self.model.objects.get(desc='1')
 
         self.assertEqual(0, node.get_children_count())
         got = [(o.desc, o.get_depth(), o.get_children_count())
                for o in self.model.get_tree(node)]
-        expected = [(u'1', 1, 0)]
+        expected = [('1', 1, 0)]
         self.assertEqual(got, expected)
 
     def _multi_get_annotated_list_all(self):
-        expected = [(u'1', True, [], 0), (u'2', False, [], 0),
-                    (u'21', True, [], 1), (u'22', False, [], 1),
-                    (u'23', False, [], 1), (u'231', True, [0], 2),
-                    (u'24', False, [0], 1), (u'3', False, [], 0),
-                    (u'4', False, [], 0), (u'41', True, [0, 1], 1)]
+        expected = [('1', True, [], 0), ('2', False, [], 0),
+                    ('21', True, [], 1), ('22', False, [], 1),
+                    ('23', False, [], 1), ('231', True, [0], 2),
+                    ('24', False, [0], 1), ('3', False, [], 0),
+                    ('4', False, [], 0), ('41', True, [0, 1], 1)]
         self._assert_get_annotated_list(expected)
 
     def _multi_get_annotated_list_node(self):
-        node = self.model.objects.get(desc=u'2')
-        expected = [(u'2', True, [], 0), (u'21', True, [], 1),
-                    (u'22', False, [], 1), (u'23', False, [], 1),
-                    (u'231', True, [0], 2), (u'24', False, [0, 1], 1)]
+        node = self.model.objects.get(desc='2')
+        expected = [('2', True, [], 0), ('21', True, [], 1),
+                    ('22', False, [], 1), ('23', False, [], 1),
+                    ('231', True, [0], 2), ('24', False, [0, 1], 1)]
         self._assert_get_annotated_list(expected, node)
 
     def _multi_get_annotated_list_leaf(self):
-        node = self.model.objects.get(desc=u'1')
-        expected = [(u'1', True, [0], 0)]
+        node = self.model.objects.get(desc='1')
+        expected = [('1', True, [0], 0)]
         self._assert_get_annotated_list(expected, node)
 
     def _multi_dump_bulk_node(self):
-        node = self.model.objects.get(desc=u'231')
+        node = self.model.objects.get(desc='231')
         self.model.load_bulk(BASE_DATA, node)
 
         # the tree was modified by load_bulk, so we reload our node object
         node = self.model.objects.get(pk=node.pk)
 
         got = self.model.dump_bulk(node, False)
-        expected = [{'data': {'desc': u'231'}, 'children': BASE_DATA}]
+        expected = [{'data': {'desc': '231'}, 'children': BASE_DATA}]
         self.assertEqual(got, expected)
 
     def _multi_load_and_dump_bulk_keeping_ids(self):
 
 class TestAddChild(TestNonEmptyTree):
     def _multi_add_child_to_leaf(self):
-        self.model.objects.get(desc=u'231').add_child(desc='2311')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 1),
-                    (u'2311', 4, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').add_child(desc='2311')
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 1),
+                    ('2311', 4, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_add_child_to_node(self):
-        self.model.objects.get(desc=u'2').add_child(desc='25')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'25', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='2').add_child(desc='25')
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('25', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
 
 class TestAddSibling(TestNonEmptyTree):
     def _multi_add_sibling_invalid_pos(self):
-        method = self.model.objects.get(desc=u'231').add_sibling
+        method = self.model.objects.get(desc='231').add_sibling
         self.assertRaises(InvalidPosition, method, 'invalid_pos')
 
     def _multi_add_sibling_missing_nodeorderby(self):
-        node_wchildren = self.model.objects.get(desc=u'2')
+        node_wchildren = self.model.objects.get(desc='2')
         method = node_wchildren.add_sibling
         self.assertRaises(MissingNodeOrderBy, method, 'sorted-sibling',
                           desc='aaa')
 
     def _multi_add_sibling_last_root(self):
-        node_wchildren = self.model.objects.get(desc=u'2')
+        node_wchildren = self.model.objects.get(desc='2')
         obj = node_wchildren.add_sibling('last-sibling', desc='5')
         self.assertEqual(obj.get_depth(), 1)
-        self.assertEqual(node_wchildren.get_last_sibling().desc, u'5')
+        self.assertEqual(node_wchildren.get_last_sibling().desc, '5')
 
     def _multi_add_sibling_last(self):
-        node = self.model.objects.get(desc=u'231')
+        node = self.model.objects.get(desc='231')
         obj = node.add_sibling('last-sibling', desc='232')
         self.assertEqual(obj.get_depth(), 3)
-        self.assertEqual(node.get_last_sibling().desc, u'232')
+        self.assertEqual(node.get_last_sibling().desc, '232')
 
     def _multi_add_sibling_first_root(self):
-        node_wchildren = self.model.objects.get(desc=u'2')
+        node_wchildren = self.model.objects.get(desc='2')
         obj = node_wchildren.add_sibling('first-sibling', desc='new')
         self.assertEqual(obj.get_depth(), 1)
-        expected = [(u'new', 1, 0),
-                    (u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('new', 1, 0),
+                    ('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_add_sibling_first(self):
-        node_wchildren = self.model.objects.get(desc=u'23')
+        node_wchildren = self.model.objects.get(desc='23')
         obj = node_wchildren.add_sibling('first-sibling', desc='new')
         self.assertEqual(obj.get_depth(), 2)
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'new', 2, 0),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('new', 2, 0),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_add_sibling_left_root(self):
-        node_wchildren = self.model.objects.get(desc=u'2')
+        node_wchildren = self.model.objects.get(desc='2')
         obj = node_wchildren.add_sibling('left', desc='new')
         self.assertEqual(obj.get_depth(), 1)
-        expected = [(u'1', 1, 0),
-                    (u'new', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('new', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_add_sibling_left(self):
-        node_wchildren = self.model.objects.get(desc=u'23')
+        node_wchildren = self.model.objects.get(desc='23')
         obj = node_wchildren.add_sibling('left', desc='new')
         self.assertEqual(obj.get_depth(), 2)
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'new', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('new', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_add_sibling_left_noleft_root(self):
-        node = self.model.objects.get(desc=u'1')
+        node = self.model.objects.get(desc='1')
         obj = node.add_sibling('left', desc='new')
         self.assertEqual(obj.get_depth(), 1)
-        expected = [(u'new', 1, 0),
-                    (u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('new', 1, 0),
+                    ('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_add_sibling_left_noleft(self):
-        node = self.model.objects.get(desc=u'231')
+        node = self.model.objects.get(desc='231')
         obj = node.add_sibling('left', desc='new')
         self.assertEqual(obj.get_depth(), 3)
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 2),
-                    (u'new', 3, 0),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 2),
+                    ('new', 3, 0),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_add_sibling_right_root(self):
-        node_wchildren = self.model.objects.get(desc=u'2')
+        node_wchildren = self.model.objects.get(desc='2')
         obj = node_wchildren.add_sibling('right', desc='new')
         self.assertEqual(obj.get_depth(), 1)
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'new', 1, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('new', 1, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_add_sibling_right(self):
-        node_wchildren = self.model.objects.get(desc=u'23')
+        node_wchildren = self.model.objects.get(desc='23')
         obj = node_wchildren.add_sibling('right', desc='new')
         self.assertEqual(obj.get_depth(), 2)
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'new', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('new', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_add_sibling_right_noright_root(self):
-        node = self.model.objects.get(desc=u'4')
+        node = self.model.objects.get(desc='4')
         obj = node.add_sibling('right', desc='new')
         self.assertEqual(obj.get_depth(), 1)
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0),
-                    (u'new', 1, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0),
+                    ('new', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_add_sibling_right_noright(self):
-        node = self.model.objects.get(desc=u'231')
+        node = self.model.objects.get(desc='231')
         obj = node.add_sibling('right', desc='new')
         self.assertEqual(obj.get_depth(), 3)
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 2),
-                    (u'231', 3, 0),
-                    (u'new', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 2),
+                    ('231', 3, 0),
+                    ('new', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
 
             self.dep_model(node=node).save()
 
     def _multi_delete_leaf(self):
-        self.model.objects.get(desc=u'231').delete()
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').delete()
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_delete_node(self):
-        self.model.objects.get(desc=u'23').delete()
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 3),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='23').delete()
+        expected = [('1', 1, 0),
+                    ('2', 1, 3),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_delete_root(self):
-        self.model.objects.get(desc=u'2').delete()
-        expected = [(u'1', 1, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='2').delete()
+        expected = [('1', 1, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_delete_filter_root_nodes(self):
         self.model.objects.filter(desc__in=('2', '3')).delete()
-        expected = [(u'1', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_delete_filter_children(self):
         self.model.objects.filter(
             desc__in=('2', '23', '231')).delete()
-        expected = [(u'1', 1, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_delete_nonexistant_nodes(self):
     def _multi_delete_same_node_twice(self):
         self.model.objects.filter(
             desc__in=('2', '2')).delete()
-        expected = [(u'1', 1, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_delete_all_root_nodes(self):
 
 class TestMoveErrors(TestNonEmptyTree):
     def _multi_move_invalid_pos(self):
-        node = self.model.objects.get(desc=u'231')
+        node = self.model.objects.get(desc='231')
         self.assertRaises(InvalidPosition, node.move, node, 'invalid_pos')
 
     def _multi_move_to_descendant(self):
-        node = self.model.objects.get(desc=u'2')
-        target = self.model.objects.get(desc=u'231')
+        node = self.model.objects.get(desc='2')
+        target = self.model.objects.get(desc='231')
         self.assertRaises(InvalidMoveToDescendant, node.move, target,
                           'first-sibling')
 
     def _multi_move_missing_nodeorderby(self):
-        node = self.model.objects.get(desc=u'231')
+        node = self.model.objects.get(desc='231')
         self.assertRaises(MissingNodeOrderBy, node.move, node,
                           'sorted-child')
         self.assertRaises(MissingNodeOrderBy, node.move, node,
 
 class TestMoveLeafRoot(TestNonEmptyTree):
     def _multi_move_leaf_last_sibling_root(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'2'), 'last-sibling')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0),
-                    (u'231', 1, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='2'), 'last-sibling')
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0),
+                    ('231', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_leaf_first_sibling_root(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'2'), 'first-sibling')
-        expected = [(u'231', 1, 0),
-                    (u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='2'), 'first-sibling')
+        expected = [('231', 1, 0),
+                    ('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_leaf_left_sibling_root(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'2'), 'left')
-        expected = [(u'1', 1, 0),
-                    (u'231', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='2'), 'left')
+        expected = [('1', 1, 0),
+                    ('231', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_leaf_right_sibling_root(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'2'), 'right')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'231', 1, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='2'), 'right')
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('231', 1, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_leaf_last_child_root(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'2'), 'last-child')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'231', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='2'), 'last-child')
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('231', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_leaf_first_child_root(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'2'), 'first-child')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'231', 2, 0),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='2'), 'first-child')
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('231', 2, 0),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
 
 class TestMoveLeaf(TestNonEmptyTree):
     def _multi_move_leaf_last_sibling(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'22'), 'last-sibling')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'231', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='22'), 'last-sibling')
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('231', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_leaf_first_sibling(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'22'), 'first-sibling')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'231', 2, 0),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='22'), 'first-sibling')
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('231', 2, 0),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_leaf_left_sibling(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'22'), 'left')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'231', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='22'), 'left')
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('231', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_leaf_right_sibling(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'22'), 'right')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'231', 2, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='22'), 'right')
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('231', 2, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_leaf_left_sibling_itself(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'231'), 'left')
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='231'), 'left')
         self.assertEqual(self.got(), self.unchanged)
 
     def _multi_move_leaf_last_child(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'22'), 'last-child')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 1),
-                    (u'231', 3, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='22'), 'last-child')
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 1),
+                    ('231', 3, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_leaf_first_child(self):
-        self.model.objects.get(desc=u'231').move(
-            self.model.objects.get(desc=u'22'), 'first-child')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 1),
-                    (u'231', 3, 0),
-                    (u'23', 2, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        self.model.objects.get(desc='231').move(
+            self.model.objects.get(desc='22'), 'first-child')
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 1),
+                    ('231', 3, 0),
+                    ('23', 2, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
 
     def _multi_move_branch_first_sibling_root(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='2'), 'first-sibling')
-        expected = [(u'4', 1, 1),
-                    (u'41', 2, 0),
-                    (u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0)]
+        expected = [('4', 1, 1),
+                    ('41', 2, 0),
+                    ('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_last_sibling_root(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='2'), 'last-sibling')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_left_sibling_root(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='2'), 'left')
-        expected = [(u'1', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0)]
+        expected = [('1', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_right_sibling_root(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='2'), 'right')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0),
-                    (u'3', 1, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_left_noleft_sibling_root(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='2').get_first_sibling(), 'left')
-        expected = [(u'4', 1, 1),
-                    (u'41', 2, 0),
-                    (u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0)]
+        expected = [('4', 1, 1),
+                    ('41', 2, 0),
+                    ('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_right_noright_sibling_root(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='2').get_last_sibling(), 'right')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0),
-                    (u'4', 1, 1),
-                    (u'41', 2, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 4),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0),
+                    ('4', 1, 1),
+                    ('41', 2, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_first_child_root(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='2'), 'first-child')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'4', 2, 1),
-                    (u'41', 3, 0),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('4', 2, 1),
+                    ('41', 3, 0),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_last_child_root(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='2'), 'last-child')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'4', 2, 1),
-                    (u'41', 3, 0),
-                    (u'3', 1, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('4', 2, 1),
+                    ('41', 3, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
 
     def _multi_move_branch_first_sibling(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='23'), 'first-sibling')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'4', 2, 1),
-                    (u'41', 3, 0),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('4', 2, 1),
+                    ('41', 3, 0),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_last_sibling(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='23'), 'last-sibling')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'4', 2, 1),
-                    (u'41', 3, 0),
-                    (u'3', 1, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('4', 2, 1),
+                    ('41', 3, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_left_sibling(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='23'), 'left')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'4', 2, 1),
-                    (u'41', 3, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('4', 2, 1),
+                    ('41', 3, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_right_sibling(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='23'), 'right')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'4', 2, 1),
-                    (u'41', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('4', 2, 1),
+                    ('41', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_left_noleft_sibling(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='23').get_first_sibling(), 'left')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'4', 2, 1),
-                    (u'41', 3, 0),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('4', 2, 1),
+                    ('41', 3, 0),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_right_noright_sibling(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='23').get_last_sibling(), 'right')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 5),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 1),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'4', 2, 1),
-                    (u'41', 3, 0),
-                    (u'3', 1, 0)]
+        expected = [('1', 1, 0),
+                    ('2', 1, 5),
+                    ('21', 2, 0),
+                    ('22', 2, 0),
+                    ('23', 2, 1),
+                    ('231', 3, 0),
+                    ('24', 2, 0),
+                    ('4', 2, 1),
+                    ('41', 3, 0),
+                    ('3', 1, 0)]
         self.assertEqual(self.got(), expected)
 
     def _multi_move_branch_left_itself_sibling(self):
     def _multi_move_branch_first_child(self):
         self.model.objects.get(desc='4').move(
             self.model.objects.get(desc='23'), 'first-child')
-        expected = [(u'1', 1, 0),
-                    (u'2', 1, 4),
-                    (u'21', 2, 0),
-                    (u'22', 2, 0),
-                    (u'23', 2, 2),
-                    (u'4', 3, 1),
-                    (u'41', 4, 0),
-                    (u'231', 3, 0),
-                    (u'24', 2, 0),
-                    (u'3', 1, 0)]