Commits

Gustavo Picon committed 8d8398d

Ported tests to py.test. Using pytest fixtures instead of the ugly unit test hack to have multiple tests per case.

Comments (0)

Files changed (3)

treebeard/tests/conftest.py

 from django.core.management import call_command
 from django.core import mail
 from django.db import connection
+from django.db.models.base import ModelBase
+from _pytest import python as _pytest_python
+
+
+def idmaker(argnames, argvalues):
+    idlist = []
+    for valindex, valset in enumerate(argvalues):
+        this_id = []
+        for nameindex, val in enumerate(valset):
+            argname = argnames[nameindex]
+            if isinstance(val, (float, int, str)):
+                this_id.append(str(val))
+            elif isinstance(val, ModelBase):
+                this_id.append(val.__name__)
+            else:
+                this_id.append("{0}-{1}={2!s}".format(argname, valindex))
+        idlist.append("][".join(this_id))
+    return idlist
+_pytest_python.idmaker = idmaker
 
 
 def pytest_report_header(config):

treebeard/tests/models.py

 from django.db import models
 from django.contrib.auth.models import User
-from django.conf import settings
 
 from treebeard.mp_tree import MP_Node
 from treebeard.al_tree import AL_Node
 
 MP_TestSortedNodeShortPath._meta.get_field('path').max_length = 4
 
-class MP_TestIssue14(MP_Node):
+
+class MP_TestManyToManyWithUser(MP_Node):
     name = models.CharField(max_length=255)
     users = models.ManyToManyField(User)
 
+
 BASE_MODELS = AL_TestNode, MP_TestNode, NS_TestNode
+PROXY_MODELS = AL_TestNode_Proxy, MP_TestNode_Proxy, NS_TestNode_Proxy
+SORTED_MODELS = AL_TestNodeSorted, MP_TestNodeSorted, NS_TestNodeSorted
 DEP_MODELS = AL_TestNodeSomeDep, MP_TestNodeSomeDep, NS_TestNodeSomeDep
+MP_SHORTPATH_MODELS = MP_TestNodeShortPath, MP_TestSortedNodeShortPath
 
 
 def empty_base_tables():

treebeard/tests/test_treebeard.py

 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 django.test import TestCase
-from django.db import transaction
 from django.contrib.auth.models import User
 from django.db.models import Q
-from django.conf import settings
-from django.utils.functional import wraps
 import pytest
 
 from treebeard import numconv
     {'data': {'desc': '3'}},
     {'data': {'desc': '4'}, 'children': [
         {'data': {'desc': '41'}},
-    ]},
-]
+    ]}]
+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 thetype(treetype, proxy):
-    def decorator(f):
-        @wraps(f)
-        def _testtype(self):
-            # tyreetype = MP, AL, NS
-            getattr(self, 'set_' + treetype)(proxy)
-            try:
-                f(self)
-            finally:
-                transaction.rollback()
-                self.model = None
-                self.sorted_model = None
-                self.dep_model = None
+def _prepare_db_test(request):
+    case = TestCase(methodName='__init__')
+    case._pre_setup()
+    request.addfinalizer(case._post_teardown)
+    return request.param
 
-        return _testtype
 
-    return decorator
+@pytest.fixture(scope='function',
+                params=models.BASE_MODELS + models.PROXY_MODELS)
+def model(request):
+    return _prepare_db_test(request)
 
 
-def _load_test_methods(cls, proxy=True):
-    if proxy:
-        proxyopts = (False, True)
-    else:
-        proxyopts = (False,)
-    for m in dir(cls):
-        if not m.startswith('_multi_'):
-            continue
-        for t in ('MP', 'AL', 'NS'):
-            for p in proxyopts:
-                deco = thetype(t, p)
-                if p:
-                    _proxy = '_proxy'
-                else:
-                    _proxy = ''
-                name = 'test_%s%s_%s' % (t.lower(),
-                                         _proxy,
-                                         m.split('_', 2)[2])
-                test = deco(getattr(cls, m))
+@pytest.fixture(scope='function', params=models.BASE_MODELS)
+def model_without_proxy(request):
+    return _prepare_db_test(request)
 
-                # expected test failures
-                if (
-                    # Test class is TestDelete, and
-                    cls.__name__ == 'TestDelete' and
-                    # testing Materialized Path trees, and
-                    t == 'MP' and
-                    # testing proxy models, and
-                    p and
-                    # using Django is 1.3.X, and
-                    DJANGO_VERSION[:2] == (1, 3) and
-                    # database is MySQL
-                    settings.DATABASES['default']['ENGINE'].endswith(
-                        '.mysql')):
-                    # If the above conditions are met, we expect this test to
-                    # fail due to a bug in Django.
-                    # See: Issue 44 in the bug tracker.
-                    test = pytest.mark.xfail(test)
 
-                setattr(cls, name, test)
-        delattr(cls, m)
+@pytest.fixture(scope='function', params=models.SORTED_MODELS)
+def sorted_model(request):
+    return _prepare_db_test(request)
 
 
-class TestTreeBase(TestCase):
+@pytest.fixture(scope='function', params=models.MP_SHORTPATH_MODELS)
+def mpshort_model(request):
+    return _prepare_db_test(request)
 
-    @classmethod
-    def setUpClass(cls):
-        cls.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:
-            self.model = models.MP_TestNode_Proxy
-        else:
-            self.model = models.MP_TestNode
-        self.sorted_model = models.MP_TestNodeSorted
-        self.dep_model = models.MP_TestNodeSomeDep
+@pytest.fixture(scope='function', params=[models.MP_TestNodeShortPath])
+def mpshortnotsorted_model(request):
+    return _prepare_db_test(request)
 
-    def set_NS(self, proxy=False):
-        if proxy:
-            self.model = models.NS_TestNode_Proxy
-        else:
-            self.model = models.NS_TestNode
-        self.sorted_model = models.NS_TestNodeSorted
-        self.dep_model = models.NS_TestNodeSomeDep
 
-    def set_AL(self, proxy=False):
-        if proxy:
-            self.model = models.AL_TestNode_Proxy
-        else:
-            self.model = models.AL_TestNode
-        self.sorted_model = models.AL_TestNodeSorted
-        self.dep_model = models.AL_TestNodeSomeDep
+@pytest.fixture(scope='function', params=[models.MP_TestNodeAlphabet])
+def mpalphabet_model(request):
+    return _prepare_db_test(request)
 
-    def got(self):
-        if self.model in [models.NS_TestNode, models.NS_TestNode_Proxy]:
+
+@pytest.fixture(scope='function', params=[models.MP_TestNodeSortedAutoNow])
+def mpsortedautonow_model(request):
+    return _prepare_db_test(request)
+
+
+@pytest.fixture(scope='function', params=[models.MP_TestNodeSmallStep])
+def mpsmallstep_model(request):
+    return _prepare_db_test(request)
+
+
+@pytest.fixture(scope='function', params=[models.MP_TestManyToManyWithUser])
+def mpm2muser_model(request):
+    return _prepare_db_test(request)
+
+
+class TestTreeBase(object):
+    def got(self, model):
+        if model in [models.NS_TestNode, models.NS_TestNode_Proxy]:
             # this slows down nested sets tests quite a bit, but it has the
             # advantage that we'll check the node edges are correct
             d = {}
-            for tree_id, lft, rgt in self.model.objects.values_list('tree_id',
-                                                                    'lft',
-                                                                    'rgt'):
+            for tree_id, lft, rgt in model.objects.values_list('tree_id',
+                                                               'lft',
+                                                               'rgt'):
                 d.setdefault(tree_id, []).extend([lft, rgt])
             for tree_id, got_edges in d.items():
-                self.assertEqual(len(got_edges), max(got_edges))
+                assert len(got_edges) == max(got_edges)
                 good_edges = list(range(1, len(got_edges) + 1))
-                self.assertEqual(sorted(got_edges), good_edges)
+                assert sorted(got_edges) == good_edges
 
         return [(o.desc, o.get_depth(), o.get_children_count())
-                for o in self.model.get_tree()]
+                for o in model.get_tree()]
 
-    def _assert_get_annotated_list(self, expected, parent=None):
+    def _assert_get_annotated_list(self, model, expected, parent=None):
         got = [
             (obj[0].desc, obj[1]['open'], obj[1]['close'], obj[1]['level'])
-            for obj in self.model.get_annotated_list(parent)
+            for obj in model.get_annotated_list(parent)
         ]
-        self.assertEqual(expected, got)
+        assert expected == got
 
 
 class TestEmptyTree(TestTreeBase):
 
-    def _multi_load_bulk_empty(self):
-        ids = self.model.load_bulk(BASE_DATA)
+    def test_load_bulk_empty(self, model):
+        ids = model.load_bulk(BASE_DATA)
         got_descs = [obj.desc
-                     for obj in self.model.objects.filter(id__in=ids)]
-        expected_descs = [x[0] for x in self.unchanged]
-        self.assertEqual(sorted(got_descs), sorted(expected_descs))
-        self.assertEqual(self.got(), self.unchanged)
+                     for obj in model.objects.filter(id__in=ids)]
+        expected_descs = [x[0] for x in UNCHANGED]
+        assert sorted(got_descs) == sorted(expected_descs)
+        assert self.got(model) == UNCHANGED
 
-    def _multi_dump_bulk_empty(self):
-        self.assertEqual(self.model.dump_bulk(), [])
+    def test_dump_bulk_empty(self, model):
+        assert model.dump_bulk() == []
 
-    def _multi_add_root_empty(self):
-        self.model.add_root(desc='1')
+    def test_add_root_empty(self, model):
+        model.add_root(desc='1')
         expected = [('1', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_get_root_nodes_empty(self):
-        got = self.model.get_root_nodes()
+    def test_get_root_nodes_empty(self, model):
+        got = model.get_root_nodes()
         expected = []
-        self.assertEqual([node.desc for node in got], expected)
+        assert [node.desc for node in got] == expected
 
-    def _multi_get_first_root_node_empty(self):
-        got = self.model.get_first_root_node()
-        self.assertEqual(got, None)
+    def test_get_first_root_node_empty(self, model):
+        got = model.get_first_root_node()
+        assert got is None
 
-    def _multi_get_last_root_node_empty(self):
-        got = self.model.get_last_root_node()
-        self.assertEqual(got, None)
+    def test_get_last_root_node_empty(self, model):
+        got = model.get_last_root_node()
+        assert got is None
 
-    def _multi_get_tree(self):
-        got = list(self.model.get_tree())
-        self.assertEqual(got, [])
+    def test_get_tree(self, model):
+        got = list(model.get_tree())
+        assert got == []
 
-    def _multi_get_annotated_list(self):
+    def test_get_annotated_list(self, model):
         expected = []
-        self._assert_get_annotated_list(expected)
+        self._assert_get_annotated_list(model, expected)
 
 
 class TestNonEmptyTree(TestTreeBase):
 
     @classmethod
-    def setUpClass(cls):
-        TestTreeBase.setUpClass()
+    def setup_class(cls):
         for model in models.BASE_MODELS:
             model.load_bulk(BASE_DATA)
 
     @classmethod
-    def tearDownClass(cls):
+    def teardown_class(cls):
         models.empty_base_tables()
 
 
 class TestClassMethods(TestNonEmptyTree):
 
-    def _multi_load_bulk_existing(self):
+    def test_load_bulk_existing(self, model):
         # inserting on an existing node
-        node = self.model.objects.get(desc='231')
-        ids = self.model.load_bulk(BASE_DATA, node)
+        node = model.objects.get(desc='231')
+        ids = model.load_bulk(BASE_DATA, node)
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 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.got(), expected)
+                     for obj in model.objects.filter(id__in=ids)]
+        assert sorted(got_descs) == sorted(expected_descs)
+        assert self.got(model) == expected
 
-    def _multi_get_tree_all(self):
+    def test_get_tree_all(self, model):
         got = [(o.desc, o.get_depth(), o.get_children_count())
-               for o in self.model.get_tree()]
-        self.assertEqual(got, self.unchanged)
+               for o in model.get_tree()]
+        assert got == UNCHANGED
 
-    def _multi_dump_bulk_all(self):
-        self.assertEqual(self.model.dump_bulk(keep_ids=False), BASE_DATA)
+    def test_dump_bulk_all(self, model):
+        assert model.dump_bulk(keep_ids=False) == BASE_DATA
 
-    def _multi_get_tree_node(self):
-        node = self.model.objects.get(desc='231')
-        self.model.load_bulk(BASE_DATA, node)
+    def test_get_tree_node(self, model):
+        node = model.objects.get(desc='231')
+        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)
+        node = model.objects.get(pk=node.pk)
 
         got = [(o.desc, o.get_depth(), o.get_children_count())
-               for o in self.model.get_tree(node)]
+               for o in model.get_tree(node)]
         expected = [('231', 3, 4),
                     ('1', 4, 0),
                     ('2', 4, 4),
                     ('3', 4, 0),
                     ('4', 4, 1),
                     ('41', 5, 0)]
-        self.assertEqual(got, expected)
+        assert got == expected
 
-    def _multi_get_tree_leaf(self):
-        node = self.model.objects.get(desc='1')
+    def test_get_tree_leaf(self, model):
+        node = model.objects.get(desc='1')
 
-        self.assertEqual(0, node.get_children_count())
+        assert 0 == node.get_children_count()
         got = [(o.desc, o.get_depth(), o.get_children_count())
-               for o in self.model.get_tree(node)]
+               for o in model.get_tree(node)]
         expected = [('1', 1, 0)]
-        self.assertEqual(got, expected)
+        assert got == expected
 
-    def _multi_get_annotated_list_all(self):
+    def test_get_annotated_list_all(self, model):
         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)
+        self._assert_get_annotated_list(model, expected)
 
-    def _multi_get_annotated_list_node(self):
-        node = self.model.objects.get(desc='2')
+    def test_get_annotated_list_node(self, model):
+        node = 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)
+        self._assert_get_annotated_list(model, expected, node)
 
-    def _multi_get_annotated_list_leaf(self):
-        node = self.model.objects.get(desc='1')
+    def test_get_annotated_list_leaf(self, model):
+        node = model.objects.get(desc='1')
         expected = [('1', True, [0], 0)]
-        self._assert_get_annotated_list(expected, node)
+        self._assert_get_annotated_list(model, expected, node)
 
-    def _multi_dump_bulk_node(self):
-        node = self.model.objects.get(desc='231')
-        self.model.load_bulk(BASE_DATA, node)
+    def test_dump_bulk_node(self, model):
+        node = model.objects.get(desc='231')
+        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)
+        node = model.objects.get(pk=node.pk)
 
-        got = self.model.dump_bulk(node, False)
+        got = model.dump_bulk(node, False)
         expected = [{'data': {'desc': '231'}, 'children': BASE_DATA}]
-        self.assertEqual(got, expected)
+        assert got == expected
 
-    def _multi_load_and_dump_bulk_keeping_ids(self):
-        exp = self.model.dump_bulk(keep_ids=True)
-        self.model.objects.all().delete()
-        self.model.load_bulk(exp, None, True)
-        got = self.model.dump_bulk(keep_ids=True)
-        self.assertEqual(got, exp)
+    def test_load_and_dump_bulk_keeping_ids(self, model):
+        exp = model.dump_bulk(keep_ids=True)
+        model.objects.all().delete()
+        model.load_bulk(exp, None, True)
+        got = model.dump_bulk(keep_ids=True)
+        assert got == exp
         # do we really have an unchaged tree after the dump/delete/load?
         got = [(o.desc, o.get_depth(), o.get_children_count())
-               for o in self.model.get_tree()]
-        self.assertEqual(got, self.unchanged)
+               for o in model.get_tree()]
+        assert got == UNCHANGED
 
-    def _multi_get_root_nodes(self):
-        got = self.model.get_root_nodes()
+    def test_get_root_nodes(self, model):
+        got = model.get_root_nodes()
         expected = ['1', '2', '3', '4']
-        self.assertEqual([node.desc for node in got], expected)
+        assert [node.desc for node in got] == expected
 
-    def _multi_get_first_root_node(self):
-        got = self.model.get_first_root_node()
-        self.assertEqual(got.desc, '1')
+    def test_get_first_root_node(self, model):
+        got = model.get_first_root_node()
+        assert got.desc == '1'
 
-    def _multi_get_last_root_node(self):
-        got = self.model.get_last_root_node()
-        self.assertEqual(got.desc, '4')
+    def test_get_last_root_node(self, model):
+        got = model.get_last_root_node()
+        assert got.desc == '4'
 
-    def _multi_add_root(self):
-        obj = self.model.add_root(desc='5')
-        self.assertEqual(obj.get_depth(), 1)
-        self.assertEqual(self.model.get_last_root_node().desc, '5')
+    def test_add_root(self, model):
+        obj = model.add_root(desc='5')
+        assert obj.get_depth() == 1
+        assert model.get_last_root_node().desc == '5'
 
 
 class TestSimpleNodeMethods(TestNonEmptyTree):
-    def _multi_is_root(self):
+    def test_is_root(self, model):
         data = [
             ('2', True),
             ('1', True),
             ('231', False),
         ]
         for desc, expected in data:
-            got = self.model.objects.get(desc=desc).is_root()
-            self.assertEqual(got, expected)
+            got = model.objects.get(desc=desc).is_root()
+            assert got == expected
 
-    def _multi_is_leaf(self):
+    def test_is_leaf(self, model):
         data = [
             ('2', False),
             ('23', False),
             ('231', True),
         ]
         for desc, expected in data:
-            got = self.model.objects.get(desc=desc).is_leaf()
-            self.assertEqual(got, expected)
+            got = model.objects.get(desc=desc).is_leaf()
+            assert got == expected
 
-    def _multi_get_root(self):
+    def test_get_root(self, model):
         data = [
             ('2', '2'),
             ('1', '1'),
             ('231', '2'),
         ]
         for desc, expected in data:
-            node = self.model.objects.get(desc=desc).get_root()
-            self.assertEqual(node.desc, expected)
+            node = model.objects.get(desc=desc).get_root()
+            assert node.desc == expected
 
-    def _multi_get_parent(self):
+    def test_get_parent(self, model):
         data = [
             ('2', None),
             ('1', None),
         data = dict(data)
         objs = {}
         for desc, expected in data.items():
-            node = self.model.objects.get(desc=desc)
+            node = model.objects.get(desc=desc)
             parent = node.get_parent()
             if expected:
-                self.assertEqual(parent.desc, expected)
+                assert parent.desc == expected
             else:
-                self.assertEqual(parent, None)
+                assert parent is None
             objs[desc] = node
             # corrupt the objects' parent cache
             node._parent_obj = 'CORRUPTED!!!'
             # corrupted it in the previous loop)
             parent = node.get_parent(True)
             if expected:
-                self.assertEqual(parent.desc, expected)
+                assert parent.desc == expected
             else:
-                self.assertEqual(parent, None)
+                assert parent is None
 
-    def _multi_get_children(self):
+    def test_get_children(self, model):
         data = [
             ('2', ['21', '22', '23', '24']),
             ('23', ['231']),
             ('231', []),
         ]
         for desc, expected in data:
-            children = self.model.objects.get(desc=desc).get_children()
-            self.assertEqual([node.desc for node in children], expected)
+            children = model.objects.get(desc=desc).get_children()
+            assert [node.desc for node in children] == expected
 
-    def _multi_get_children_count(self):
+    def test_get_children_count(self, model):
         data = [
             ('2', 4),
             ('23', 1),
             ('231', 0),
         ]
         for desc, expected in data:
-            got = self.model.objects.get(desc=desc).get_children_count()
-            self.assertEqual(got, expected)
+            got = model.objects.get(desc=desc).get_children_count()
+            assert got == expected
 
-    def _multi_get_siblings(self):
+    def test_get_siblings(self, model):
         data = [
             ('2', ['1', '2', '3', '4']),
             ('21', ['21', '22', '23', '24']),
             ('231', ['231']),
         ]
         for desc, expected in data:
-            siblings = self.model.objects.get(desc=desc).get_siblings()
-            self.assertEqual([node.desc for node in siblings], expected)
+            siblings = model.objects.get(desc=desc).get_siblings()
+            assert [node.desc for node in siblings] == expected
 
-    def _multi_get_first_sibling(self):
+    def test_get_first_sibling(self, model):
         data = [
             ('2', '1'),
             ('1', '1'),
             ('231', '231'),
         ]
         for desc, expected in data:
-            node = self.model.objects.get(desc=desc).get_first_sibling()
-            self.assertEqual(node.desc, expected)
+            node = model.objects.get(desc=desc).get_first_sibling()
+            assert node.desc == expected
 
-    def _multi_get_prev_sibling(self):
+    def test_get_prev_sibling(self, model):
         data = [
             ('2', '1'),
             ('1', None),
             ('231', None),
         ]
         for desc, expected in data:
-            node = self.model.objects.get(desc=desc).get_prev_sibling()
+            node = model.objects.get(desc=desc).get_prev_sibling()
             if expected is None:
-                self.assertEqual(node, None)
+                assert node is None
             else:
-                self.assertEqual(node.desc, expected)
+                assert node.desc == expected
 
-    def _multi_get_next_sibling(self):
+    def test_get_next_sibling(self, model):
         data = [
             ('2', '3'),
             ('1', '2'),
             ('231', None),
         ]
         for desc, expected in data:
-            node = self.model.objects.get(desc=desc).get_next_sibling()
+            node = model.objects.get(desc=desc).get_next_sibling()
             if expected is None:
-                self.assertEqual(node, None)
+                assert node is None
             else:
-                self.assertEqual(node.desc, expected)
+                assert node.desc == expected
 
-    def _multi_get_last_sibling(self):
+    def test_get_last_sibling(self, model):
         data = [
             ('2', '4'),
             ('1', '4'),
             ('231', '231'),
         ]
         for desc, expected in data:
-            node = self.model.objects.get(desc=desc).get_last_sibling()
-            self.assertEqual(node.desc, expected)
+            node = model.objects.get(desc=desc).get_last_sibling()
+            assert node.desc == expected
 
-    def _multi_get_first_child(self):
+    def test_get_first_child(self, model):
         data = [
             ('2', '21'),
             ('21', None),
             ('231', None),
         ]
         for desc, expected in data:
-            node = self.model.objects.get(desc=desc).get_first_child()
+            node = model.objects.get(desc=desc).get_first_child()
             if expected is None:
-                self.assertEqual(node, None)
+                assert node is None
             else:
-                self.assertEqual(node.desc, expected)
+                assert node.desc == expected
 
-    def _multi_get_last_child(self):
+    def test_get_last_child(self, model):
         data = [
             ('2', '24'),
             ('21', None),
             ('231', None),
         ]
         for desc, expected in data:
-            node = self.model.objects.get(desc=desc).get_last_child()
+            node = model.objects.get(desc=desc).get_last_child()
             if expected is None:
-                self.assertEqual(node, None)
+                assert node is None
             else:
-                self.assertEqual(node.desc, expected)
+                assert node.desc == expected
 
-    def _multi_get_ancestors(self):
+    def test_get_ancestors(self, model):
         data = [
             ('2', []),
             ('21', ['2']),
             ('231', ['2', '23']),
         ]
         for desc, expected in data:
-            nodes = self.model.objects.get(desc=desc).get_ancestors()
-            self.assertEqual([node.desc for node in nodes], expected)
+            nodes = model.objects.get(desc=desc).get_ancestors()
+            assert [node.desc for node in nodes] == expected
 
-    def _multi_get_descendants(self):
+    def test_get_descendants(self, model):
         data = [
             ('2', ['21', '22', '23', '231', '24']),
             ('23', ['231']),
             ('4', ['41']),
         ]
         for desc, expected in data:
-            nodes = self.model.objects.get(desc=desc).get_descendants()
-            self.assertEqual([node.desc for node in nodes], expected)
+            nodes = model.objects.get(desc=desc).get_descendants()
+            assert [node.desc for node in nodes] == expected
 
-    def _multi_get_descendant_count(self):
+    def test_get_descendant_count(self, model):
         data = [
             ('2', 5),
             ('23', 1),
             ('4', 1),
         ]
         for desc, expected in data:
-            got = self.model.objects.get(desc=desc).get_descendant_count()
-            self.assertEqual(got, expected)
+            got = model.objects.get(desc=desc).get_descendant_count()
+            assert got == expected
 
-    def _multi_is_sibling_of(self):
+    def test_is_sibling_of(self, model):
         data = [
             ('2', '2', True),
             ('2', '1', True),
             ('231', '231', True),
         ]
         for desc1, desc2, expected in data:
-            node1 = self.model.objects.get(desc=desc1)
-            node2 = self.model.objects.get(desc=desc2)
-            self.assertEqual(node1.is_sibling_of(node2), expected)
+            node1 = model.objects.get(desc=desc1)
+            node2 = model.objects.get(desc=desc2)
+            assert node1.is_sibling_of(node2) == expected
 
-    def _multi_is_child_of(self):
+    def test_is_child_of(self, model):
         data = [
             ('2', '2', False),
             ('2', '1', False),
             ('231', '231', False),
         ]
         for desc1, desc2, expected in data:
-            node1 = self.model.objects.get(desc=desc1)
-            node2 = self.model.objects.get(desc=desc2)
-            self.assertEqual(node1.is_child_of(node2), expected)
+            node1 = model.objects.get(desc=desc1)
+            node2 = model.objects.get(desc=desc2)
+            assert node1.is_child_of(node2) == expected
 
-    def _multi_is_descendant_of(self):
+    def test_is_descendant_of(self, model):
         data = [
             ('2', '2', False),
             ('2', '1', False),
             ('231', '231', False),
         ]
         for desc1, desc2, expected in data:
-            node1 = self.model.objects.get(desc=desc1)
-            node2 = self.model.objects.get(desc=desc2)
-            self.assertEqual(node1.is_descendant_of(node2), expected)
+            node1 = model.objects.get(desc=desc1)
+            node2 = model.objects.get(desc=desc2)
+            assert node1.is_descendant_of(node2) == expected
 
 
 class TestAddChild(TestNonEmptyTree):
-    def _multi_add_child_to_leaf(self):
-        self.model.objects.get(desc='231').add_child(desc='2311')
+    def test_add_child_to_leaf(self, model):
+        model.objects.get(desc='231').add_child(desc='2311')
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_add_child_to_node(self):
-        self.model.objects.get(desc='2').add_child(desc='25')
+    def test_add_child_to_node(self, model):
+        model.objects.get(desc='2').add_child(desc='25')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
 
 class TestAddSibling(TestNonEmptyTree):
-    def _multi_add_sibling_invalid_pos(self):
-        method = self.model.objects.get(desc='231').add_sibling
-        self.assertRaises(InvalidPosition, method, 'invalid_pos')
+    def test_add_sibling_invalid_pos(self, model):
+        with pytest.raises(InvalidPosition):
+            model.objects.get(desc='231').add_sibling('invalid_pos')
 
-    def _multi_add_sibling_missing_nodeorderby(self):
-        node_wchildren = self.model.objects.get(desc='2')
-        method = node_wchildren.add_sibling
-        self.assertRaises(MissingNodeOrderBy, method, 'sorted-sibling',
-                          desc='aaa')
+    def test_add_sibling_missing_nodeorderby(self, model):
+        node_wchildren = model.objects.get(desc='2')
+        with pytest.raises(MissingNodeOrderBy):
+            node_wchildren.add_sibling('sorted-sibling', desc='aaa')
 
-    def _multi_add_sibling_last_root(self):
-        node_wchildren = self.model.objects.get(desc='2')
+    def test_add_sibling_last_root(self, model):
+        node_wchildren = 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, '5')
+        assert obj.get_depth() == 1
+        assert node_wchildren.get_last_sibling().desc == '5'
 
-    def _multi_add_sibling_last(self):
-        node = self.model.objects.get(desc='231')
+    def test_add_sibling_last(self, model):
+        node = 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, '232')
+        assert obj.get_depth() == 3
+        assert node.get_last_sibling().desc == '232'
 
-    def _multi_add_sibling_first_root(self):
-        node_wchildren = self.model.objects.get(desc='2')
+    def test_add_sibling_first_root(self, model):
+        node_wchildren = model.objects.get(desc='2')
         obj = node_wchildren.add_sibling('first-sibling', desc='new')
-        self.assertEqual(obj.get_depth(), 1)
+        assert obj.get_depth() == 1
         expected = [('new', 1, 0),
                     ('1', 1, 0),
                     ('2', 1, 4),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_add_sibling_first(self):
-        node_wchildren = self.model.objects.get(desc='23')
+    def test_add_sibling_first(self, model):
+        node_wchildren = model.objects.get(desc='23')
         obj = node_wchildren.add_sibling('first-sibling', desc='new')
-        self.assertEqual(obj.get_depth(), 2)
+        assert obj.get_depth() == 2
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('new', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_add_sibling_left_root(self):
-        node_wchildren = self.model.objects.get(desc='2')
+    def test_add_sibling_left_root(self, model):
+        node_wchildren = model.objects.get(desc='2')
         obj = node_wchildren.add_sibling('left', desc='new')
-        self.assertEqual(obj.get_depth(), 1)
+        assert obj.get_depth() == 1
         expected = [('1', 1, 0),
                     ('new', 1, 0),
                     ('2', 1, 4),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_add_sibling_left(self):
-        node_wchildren = self.model.objects.get(desc='23')
+    def test_add_sibling_left(self, model):
+        node_wchildren = model.objects.get(desc='23')
         obj = node_wchildren.add_sibling('left', desc='new')
-        self.assertEqual(obj.get_depth(), 2)
+        assert obj.get_depth() == 2
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_add_sibling_left_noleft_root(self):
-        node = self.model.objects.get(desc='1')
+    def test_add_sibling_left_noleft_root(self, model):
+        node = model.objects.get(desc='1')
         obj = node.add_sibling('left', desc='new')
-        self.assertEqual(obj.get_depth(), 1)
+        assert obj.get_depth() == 1
         expected = [('new', 1, 0),
                     ('1', 1, 0),
                     ('2', 1, 4),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_add_sibling_left_noleft(self):
-        node = self.model.objects.get(desc='231')
+    def test_add_sibling_left_noleft(self, model):
+        node = model.objects.get(desc='231')
         obj = node.add_sibling('left', desc='new')
-        self.assertEqual(obj.get_depth(), 3)
+        assert obj.get_depth() == 3
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_add_sibling_right_root(self):
-        node_wchildren = self.model.objects.get(desc='2')
+    def test_add_sibling_right_root(self, model):
+        node_wchildren = model.objects.get(desc='2')
         obj = node_wchildren.add_sibling('right', desc='new')
-        self.assertEqual(obj.get_depth(), 1)
+        assert obj.get_depth() == 1
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_add_sibling_right(self):
-        node_wchildren = self.model.objects.get(desc='23')
+    def test_add_sibling_right(self, model):
+        node_wchildren = model.objects.get(desc='23')
         obj = node_wchildren.add_sibling('right', desc='new')
-        self.assertEqual(obj.get_depth(), 2)
+        assert obj.get_depth() == 2
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_add_sibling_right_noright_root(self):
-        node = self.model.objects.get(desc='4')
+    def test_add_sibling_right_noright_root(self, model):
+        node = model.objects.get(desc='4')
         obj = node.add_sibling('right', desc='new')
-        self.assertEqual(obj.get_depth(), 1)
+        assert obj.get_depth() == 1
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('4', 1, 1),
                     ('41', 2, 0),
                     ('new', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_add_sibling_right_noright(self):
-        node = self.model.objects.get(desc='231')
+    def test_add_sibling_right_noright(self, model):
+        node = model.objects.get(desc='231')
         obj = node.add_sibling('right', desc='new')
-        self.assertEqual(obj.get_depth(), 3)
+        assert obj.get_depth() == 3
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
 
 class TestDelete(TestNonEmptyTree):
 
     @classmethod
-    def setUpClass(cls):
-        TestNonEmptyTree.setUpClass()
+    def setup_class(cls):
+        TestNonEmptyTree.setup_class()
         for model, dep_model in zip(models.BASE_MODELS, models.DEP_MODELS):
             for node in model.objects.all():
                 dep_model(node=node).save()
 
     @classmethod
-    def tearDownClass(cls):
+    def teardown_class(cls):
         models.empty_deps_tables()
-        TestNonEmptyTree.tearDownClass()
+        TestNonEmptyTree.teardown_class()
 
-    def _multi_delete_leaf(self):
-        self.model.objects.get(desc='231').delete()
+    def test_delete_leaf(self, model):
+        model.objects.get(desc='231').delete()
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_delete_node(self):
-        self.model.objects.get(desc='23').delete()
+    def test_delete_node(self, model):
+        model.objects.get(desc='23').delete()
         expected = [('1', 1, 0),
                     ('2', 1, 3),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_delete_root(self):
-        self.model.objects.get(desc='2').delete()
+    def test_delete_root(self, model):
+        model.objects.get(desc='2').delete()
         expected = [('1', 1, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_delete_filter_root_nodes(self):
-        self.model.objects.filter(desc__in=('2', '3')).delete()
+    def test_delete_filter_root_nodes(self, model):
+        model.objects.filter(desc__in=('2', '3')).delete()
         expected = [('1', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_delete_filter_children(self):
-        self.model.objects.filter(
+    def test_delete_filter_children(self, model):
+        model.objects.filter(
             desc__in=('2', '23', '231')).delete()
         expected = [('1', 1, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_delete_nonexistant_nodes(self):
-        self.model.objects.filter(desc__in=('ZZZ', 'XXX')).delete()
-        self.assertEqual(self.got(), self.unchanged)
+    def test_delete_nonexistant_nodes(self, model):
+        model.objects.filter(desc__in=('ZZZ', 'XXX')).delete()
+        assert self.got(model) == UNCHANGED
 
-    def _multi_delete_same_node_twice(self):
-        self.model.objects.filter(
+    def test_delete_same_node_twice(self, model):
+        model.objects.filter(
             desc__in=('2', '2')).delete()
         expected = [('1', 1, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_delete_all_root_nodes(self):
-        self.model.get_root_nodes().delete()
-        count = self.model.objects.count()
-        self.assertEqual(count, 0)
+    def test_delete_all_root_nodes(self, model):
+        model.get_root_nodes().delete()
+        count = model.objects.count()
+        assert count == 0
 
-    def _multi_delete_all_nodes(self):
-        self.model.objects.all().delete()
-        count = self.model.objects.count()
-        self.assertEqual(count, 0)
+    def test_delete_all_nodes(self, model):
+        model.objects.all().delete()
+        count = model.objects.count()
+        assert count == 0
 
 
 class TestMoveErrors(TestNonEmptyTree):
-    def _multi_move_invalid_pos(self):
-        node = self.model.objects.get(desc='231')
-        self.assertRaises(InvalidPosition, node.move, node, 'invalid_pos')
+    def test_move_invalid_pos(self, model):
+        node = model.objects.get(desc='231')
+        with pytest.raises(InvalidPosition):
+            node.move(node, 'invalid_pos')
 
-    def _multi_move_to_descendant(self):
-        node = self.model.objects.get(desc='2')
-        target = self.model.objects.get(desc='231')
-        self.assertRaises(InvalidMoveToDescendant, node.move, target,
-                          'first-sibling')
+    def test_move_to_descendant(self, model):
+        node = model.objects.get(desc='2')
+        target = model.objects.get(desc='231')
+        with pytest.raises(InvalidMoveToDescendant):
+            node.move(target, 'first-sibling')
 
-    def _multi_move_missing_nodeorderby(self):
-        node = self.model.objects.get(desc='231')
-        self.assertRaises(MissingNodeOrderBy, node.move, node,
-                          'sorted-child')
-        self.assertRaises(MissingNodeOrderBy, node.move, node,
-                          'sorted-sibling')
+    def test_move_missing_nodeorderby(self, model):
+        node = model.objects.get(desc='231')
+        with pytest.raises(MissingNodeOrderBy):
+            node.move(node, 'sorted-child')
+        with pytest.raises(MissingNodeOrderBy):
+            node.move(node, 'sorted-sibling')
 
 
 class TestMoveSortedErrors(TestTreeBase):
 
-    def _multi_nonsorted_move_in_sorted(self):
-        node = self.sorted_model.add_root(val1=3, val2=3, desc='zxy')
-        self.assertRaises(InvalidPosition, node.move, node, 'left')
+    def test_nonsorted_move_in_sorted(self, sorted_model):
+        node = sorted_model.add_root(val1=3, val2=3, desc='zxy')
+        with pytest.raises(InvalidPosition):
+            node.move(node, 'left')
 
 
 class TestMoveLeafRoot(TestNonEmptyTree):
-    def _multi_move_leaf_last_sibling_root(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='2'), 'last-sibling')
+    def test_move_leaf_last_sibling_root(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='2'), 'last-sibling')
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('4', 1, 1),
                     ('41', 2, 0),
                     ('231', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_leaf_first_sibling_root(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='2'), 'first-sibling')
+    def test_move_leaf_first_sibling_root(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='2'), 'first-sibling')
         expected = [('231', 1, 0),
                     ('1', 1, 0),
                     ('2', 1, 4),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_leaf_left_sibling_root(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='2'), 'left')
+    def test_move_leaf_left_sibling_root(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='2'), 'left')
         expected = [('1', 1, 0),
                     ('231', 1, 0),
                     ('2', 1, 4),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_leaf_right_sibling_root(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='2'), 'right')
+    def test_move_leaf_right_sibling_root(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='2'), 'right')
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_leaf_last_child_root(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='2'), 'last-child')
+    def test_move_leaf_last_child_root(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='2'), 'last-child')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_leaf_first_child_root(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='2'), 'first-child')
+    def test_move_leaf_first_child_root(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='2'), 'first-child')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('231', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
 
 class TestMoveLeaf(TestNonEmptyTree):
-    def _multi_move_leaf_last_sibling(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='22'), 'last-sibling')
+    def test_move_leaf_last_sibling(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='22'), 'last-sibling')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_leaf_first_sibling(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='22'), 'first-sibling')
+    def test_move_leaf_first_sibling(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='22'), 'first-sibling')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('231', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_leaf_left_sibling(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='22'), 'left')
+    def test_move_leaf_left_sibling(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='22'), 'left')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_leaf_right_sibling(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='22'), 'right')
+    def test_move_leaf_right_sibling(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='22'), 'right')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_leaf_left_sibling_itself(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='231'), 'left')
-        self.assertEqual(self.got(), self.unchanged)
+    def test_move_leaf_left_sibling_itself(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='231'), 'left')
+        assert self.got(model) == UNCHANGED
 
-    def _multi_move_leaf_last_child(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='22'), 'last-child')
+    def test_move_leaf_last_child(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='22'), 'last-child')
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_leaf_first_child(self):
-        self.model.objects.get(desc='231').move(
-            self.model.objects.get(desc='22'), 'first-child')
+    def test_move_leaf_first_child(self, model):
+        model.objects.get(desc='231').move(
+            model.objects.get(desc='22'), 'first-child')
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
 
 class TestMoveBranchRoot(TestNonEmptyTree):
-    def _multi_move_branch_first_sibling_root(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='2'), 'first-sibling')
+    def test_move_branch_first_sibling_root(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='2'), 'first-sibling')
         expected = [('4', 1, 1),
                     ('41', 2, 0),
                     ('1', 1, 0),
                     ('231', 3, 0),
                     ('24', 2, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_branch_last_sibling_root(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='2'), 'last-sibling')
+    def test_move_branch_last_sibling_root(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='2'), 'last-sibling')
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_branch_left_sibling_root(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='2'), 'left')
+    def test_move_branch_left_sibling_root(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='2'), 'left')
         expected = [('1', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0),
                     ('231', 3, 0),
                     ('24', 2, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_branch_right_sibling_root(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='2'), 'right')
+    def test_move_branch_right_sibling_root(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='2'), 'right')
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('4', 1, 1),
                     ('41', 2, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == 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')
+    def test_move_branch_left_noleft_sibling_root(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='2').get_first_sibling(), 'left')
         expected = [('4', 1, 1),
                     ('41', 2, 0),
                     ('1', 1, 0),
                     ('231', 3, 0),
                     ('24', 2, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == 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')
+    def test_move_branch_right_noright_sibling_root(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='2').get_last_sibling(), 'right')
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('3', 1, 0),
                     ('4', 1, 1),
                     ('41', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_branch_first_child_root(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='2'), 'first-child')
+    def test_move_branch_first_child_root(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='2'), 'first-child')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('4', 2, 1),
                     ('231', 3, 0),
                     ('24', 2, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_branch_last_child_root(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='2'), 'last-child')
+    def test_move_branch_last_child_root(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='2'), 'last-child')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('4', 2, 1),
                     ('41', 3, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
 
 class TestMoveBranch(TestNonEmptyTree):
-    def _multi_move_branch_first_sibling(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='23'), 'first-sibling')
+    def test_move_branch_first_sibling(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='23'), 'first-sibling')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('4', 2, 1),
                     ('231', 3, 0),
                     ('24', 2, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_branch_last_sibling(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='23'), 'last-sibling')
+    def test_move_branch_last_sibling(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='23'), 'last-sibling')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('4', 2, 1),
                     ('41', 3, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_branch_left_sibling(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='23'), 'left')
+    def test_move_branch_left_sibling(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='23'), 'left')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('231', 3, 0),
                     ('24', 2, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_branch_right_sibling(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='23'), 'right')
+    def test_move_branch_right_sibling(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='23'), 'right')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('41', 3, 0),
                     ('24', 2, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == 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')
+    def test_move_branch_left_noleft_sibling(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='23').get_first_sibling(), 'left')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('4', 2, 1),
                     ('231', 3, 0),
                     ('24', 2, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == 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')
+    def test_move_branch_right_noright_sibling(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='23').get_last_sibling(), 'right')
         expected = [('1', 1, 0),
                     ('2', 1, 5),
                     ('21', 2, 0),
                     ('4', 2, 1),
                     ('41', 3, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_branch_left_itself_sibling(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='4'), 'left')
-        self.assertEqual(self.got(), self.unchanged)
+    def test_move_branch_left_itself_sibling(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='4'), 'left')
+        assert self.got(model) == UNCHANGED
 
-    def _multi_move_branch_first_child(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='23'), 'first-child')
+    def test_move_branch_first_child(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='23'), 'first-child')
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('231', 3, 0),
                     ('24', 2, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
-    def _multi_move_branch_last_child(self):
-        self.model.objects.get(desc='4').move(
-            self.model.objects.get(desc='23'), 'last-child')
+    def test_move_branch_last_child(self, model):
+        model.objects.get(desc='4').move(
+            model.objects.get(desc='23'), 'last-child')
         expected = [('1', 1, 0),
                     ('2', 1, 4),
                     ('21', 2, 0),
                     ('41', 4, 0),
                     ('24', 2, 0),
                     ('3', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(model) == expected
 
 
 class TestTreeSorted(TestTreeBase):
 
-    def got(self):
+    def got(self, sorted_model):
         return [(o.val1, o.val2, o.desc, o.get_depth(), o.get_children_count())
-                for o in self.sorted_model.get_tree()]
+                for o in sorted_model.get_tree()]
 
-    def _multi_add_root_sorted(self):
-        self.sorted_model.add_root(val1=3, val2=3, desc='zxy')
-        self.sorted_model.add_root(val1=1, val2=4, desc='bcd')
-        self.sorted_model.add_root(val1=2, val2=5, desc='zxy')
-        self.sorted_model.add_root(val1=3, val2=3, desc='abc')
-        self.sorted_model.add_root(val1=4, val2=1, desc='fgh')
-        self.sorted_model.add_root(val1=3, val2=3, desc='abc')
-        self.sorted_model.add_root(val1=2, val2=2, desc='qwe')
-        self.sorted_model.add_root(val1=3, val2=2, desc='vcx')
+    def test_add_root_sorted(self, sorted_model):
+        sorted_model.add_root(val1=3, val2=3, desc='zxy')
+        sorted_model.add_root(val1=1, val2=4, desc='bcd')
+        sorted_model.add_root(val1=2, val2=5, desc='zxy')
+        sorted_model.add_root(val1=3, val2=3, desc='abc')
+        sorted_model.add_root(val1=4, val2=1, desc='fgh')
+        sorted_model.add_root(val1=3, val2=3, desc='abc')
+        sorted_model.add_root(val1=2, val2=2, desc='qwe')
+        sorted_model.add_root(val1=3, val2=2, desc='vcx')
         expected = [(1, 4, 'bcd', 1, 0),
                     (2, 2, 'qwe', 1, 0),
                     (2, 5, 'zxy', 1, 0),
                     (3, 3, 'abc', 1, 0),
                     (3, 3, 'zxy', 1, 0),
                     (4, 1, 'fgh', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(sorted_model) == expected
 
-    def _multi_add_child_root_sorted(self):
-        root = self.sorted_model.add_root(val1=0, val2=0, desc='aaa')
+    def test_add_child_root_sorted(self, sorted_model):
+        root = sorted_model.add_root(val1=0, val2=0, desc='aaa')
         root.add_child(val1=3, val2=3, desc='zxy')
         root.add_child(val1=1, val2=4, desc='bcd')
         root.add_child(val1=2, val2=5, desc='zxy')
                     (3, 3, 'abc', 2, 0),
                     (3, 3, 'zxy', 2, 0),
                     (4, 1, 'fgh', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(sorted_model) == expected
 
-    def _multi_add_child_nonroot_sorted(self):
-        get_node = lambda node_id: self.sorted_model.objects.get(pk=node_id)
+    def test_add_child_nonroot_sorted(self, sorted_model):
+        get_node = lambda node_id: sorted_model.objects.get(pk=node_id)
 
-        root_id = self.sorted_model.add_root(val1=0, val2=0, desc='a').pk
+        root_id = sorted_model.add_root(val1=0, val2=0, desc='a').pk
         node_id = get_node(root_id).add_child(val1=0, val2=0, desc='ac').pk
         get_node(root_id).add_child(val1=0, val2=0, desc='aa')
         get_node(root_id).add_child(val1=0, val2=0, desc='av')
                     (0, 0, 'acb', 3, 0),
                     (0, 0, 'acc', 3, 0),
                     (0, 0, 'av', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(sorted_model) == expected
 
-    def _multi_move_sorted(self):
-        self.sorted_model.add_root(val1=3, val2=3, desc='zxy')
-        self.sorted_model.add_root(val1=1, val2=4, desc='bcd')
-        self.sorted_model.add_root(val1=2, val2=5, desc='zxy')
-        self.sorted_model.add_root(val1=3, val2=3, desc='abc')
-        self.sorted_model.add_root(val1=4, val2=1, desc='fgh')
-        self.sorted_model.add_root(val1=3, val2=3, desc='abc')
-        self.sorted_model.add_root(val1=2, val2=2, desc='qwe')
-        self.sorted_model.add_root(val1=3, val2=2, desc='vcx')
-        root_nodes = self.sorted_model.get_root_nodes()
+    def test_move_sorted(self, sorted_model):
+        sorted_model.add_root(val1=3, val2=3, desc='zxy')
+        sorted_model.add_root(val1=1, val2=4, desc='bcd')
+        sorted_model.add_root(val1=2, val2=5, desc='zxy')
+        sorted_model.add_root(val1=3, val2=3, desc='abc')
+        sorted_model.add_root(val1=4, val2=1, desc='fgh')
+        sorted_model.add_root(val1=3, val2=3, desc='abc')
+        sorted_model.add_root(val1=2, val2=2, desc='qwe')
+        sorted_model.add_root(val1=3, val2=2, desc='vcx')
+        root_nodes = sorted_model.get_root_nodes()
         target = root_nodes[0]
         for node in root_nodes[1:]:
             # because raw queries don't update django objects
-            node = self.sorted_model.objects.get(pk=node.pk)
-            target = self.sorted_model.objects.get(pk=target.pk)
+            node = sorted_model.objects.get(pk=node.pk)
+            target = sorted_model.objects.get(pk=target.pk)
 
             node.move(target, 'sorted-child')
         expected = [(1, 4, 'bcd', 1, 7),
                     (3, 3, 'abc', 2, 0),
                     (3, 3, 'zxy', 2, 0),
                     (4, 1, 'fgh', 2, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(sorted_model) == expected
 
-    def _multi_move_sortedsibling(self):
+    def test_move_sortedsibling(self, sorted_model):
         # https://bitbucket.org/tabo/django-treebeard/issue/27
-        self.sorted_model.add_root(val1=3, val2=3, desc='zxy')
-        self.sorted_model.add_root(val1=1, val2=4, desc='bcd')
-        self.sorted_model.add_root(val1=2, val2=5, desc='zxy')
-        self.sorted_model.add_root(val1=3, val2=3, desc='abc')
-        self.sorted_model.add_root(val1=4, val2=1, desc='fgh')
-        self.sorted_model.add_root(val1=3, val2=3, desc='abc')
-        self.sorted_model.add_root(val1=2, val2=2, desc='qwe')
-        self.sorted_model.add_root(val1=3, val2=2, desc='vcx')
-        root_nodes = self.sorted_model.get_root_nodes()
+        sorted_model.add_root(val1=3, val2=3, desc='zxy')
+        sorted_model.add_root(val1=1, val2=4, desc='bcd')
+        sorted_model.add_root(val1=2, val2=5, desc='zxy')
+        sorted_model.add_root(val1=3, val2=3, desc='abc')
+        sorted_model.add_root(val1=4, val2=1, desc='fgh')
+        sorted_model.add_root(val1=3, val2=3, desc='abc')
+        sorted_model.add_root(val1=2, val2=2, desc='qwe')
+        sorted_model.add_root(val1=3, val2=2, desc='vcx')
+        root_nodes = sorted_model.get_root_nodes()
         target = root_nodes[0]
         for node in root_nodes[1:]:
             # because raw queries don't update django objects
-            node = self.sorted_model.objects.get(pk=node.pk)
-            target = self.sorted_model.objects.get(pk=target.pk)
+            node = sorted_model.objects.get(pk=node.pk)
+            target = sorted_model.objects.get(pk=target.pk)
 
             node.val1 -= 2
             node.save()
                     (1, 3, 'zxy', 1, 0),
                     (1, 4, 'bcd', 1, 0),
                     (2, 1, 'fgh', 1, 0)]
-        self.assertEqual(self.got(), expected)
+        assert self.got(sorted_model) == expected
 
 
-class TestMP_TreeAlphabet(TestCase):
-    def test_alphabet(self):
+class TestMP_TreeAlphabet(TestTreeBase):
+    def test_alphabet(self, mpalphabet_model):
         if not os.getenv('TREEBEARD_TEST_ALPHABET', False):
             # run this test only if the enviroment variable is set
             return
             expected.append(alphabet[2] + alphabet[0])
 
             # remove all nodes
-            models.MP_TestNodeAlphabet.objects.all().delete()
+            mpalphabet_model.objects.all().delete()
 
             # change the model's alphabet
-            models.MP_TestNodeAlphabet.alphabet = alphabet
+            mpalphabet_model.alphabet = alphabet
 
             # insert root nodes
             for pos in range(len(alphabet) * 2):
                 try:
-                    models.MP_TestNodeAlphabet.add_root(numval=pos)
+                    mpalphabet_model.add_root(numval=pos)
                 except:
                     got_err = True
                     break
             if got_err:
                 break
             got = [obj.path
-                   for obj in models.MP_TestNodeAlphabet.objects.all()]
+                   for obj in mpalphabet_model.objects.all()]
             if got != expected:
                 got_err = True
             last_good = alphabet
 class TestHelpers(TestTreeBase):
 
     @classmethod
-    def setUpClass(cls):
-        TestTreeBase.setUpClass()
+    def setup_class(cls):
         for model in models.BASE_MODELS:
             model.load_bulk(BASE_DATA)
             for node in model.get_root_nodes():
             model.add_root(desc='5')
 
     @classmethod
-    def tearDownClass(cls):
+    def teardown_class(cls):
         models.empty_base_tables()
 
-    def _multi_descendants_group_count_root(self):
+    def test_descendants_group_count_root(self, model):
         expected = [(o.desc, o.get_descendant_count())
-                    for o in self.model.get_root_nodes()]
+                    for o in model.get_root_nodes()]
         got = [(o.desc, o.descendants_count)
-               for o in self.model.get_descendants_group_count()]
-        self.assertEqual(got, expected)
+               for o in model.get_descendants_group_count()]
+        assert got == expected
 
-    def _multi_descendants_group_count_node(self):
-        parent = self.model.get_root_nodes().get(desc='2')
+    def test_descendants_group_count_node(self, model):
+        parent = model.get_root_nodes().get(desc='2')
         expected = [(o.desc, o.get_descendant_count())
                     for o in parent.get_children()]
         got = [(o.desc, o.descendants_count)
-               for o in self.model.get_descendants_group_count(parent)]
-        self.assertEqual(got, expected)
+               for o in model.get_descendants_group_count(parent)]
+        assert got == expected
 
 
-class TestMP_TreeSortedAutoNow(TestCase):
+class TestMP_TreeSortedAutoNow(TestTreeBase):
     """
     The sorting mechanism used by treebeard when adding a node can fail if the
     ordering is using an "auto_now" field
     """
 
-    def test_sorted_by_autonow_workaround(self):
+    def test_sorted_by_autonow_workaround(self, mpsortedautonow_model):
         # workaround
         import datetime
 
         for i in range(1, 5):
-            models.MP_TestNodeSortedAutoNow.add_root(
+            mpsortedautonow_model.add_root(
                 desc='node%d' % (i, ),
                 created=datetime.datetime.now()
             )
 
-    def test_sorted_by_autonow_FAIL(self):
+    def test_sorted_by_autonow_FAIL(self, mpsortedautonow_model):
         """
         This test asserts that we have a problem.
         fix this, somehow
         """
-        models.MP_TestNodeSortedAutoNow.add_root(desc='node1')
-        self.assertRaises(ValueError, models.MP_TestNodeSortedAutoNow.add_root,
-                          desc='node2')
+        mpsortedautonow_model.add_root(desc='node1')
+        with pytest.raises(ValueError):
+            mpsortedautonow_model.add_root(desc='node2')
 
 
-class TestMP_TreeStepOverflow(TestCase):
-    def test_add_root(self):
-        method = models.MP_TestNodeSmallStep.add_root
+class TestMP_TreeStepOverflow(TestTreeBase):
+    def test_add_root(self, mpsmallstep_model):
+        method = mpsmallstep_model.add_root
         for i in range(1, 10):
             method()
-        self.assertRaises(PathOverflow, method)
+        with pytest.raises(PathOverflow):
+            method()
 
-    def test_add_child(self):
-        root = models.MP_TestNodeSmallStep.add_root()
+    def test_add_child(self, mpsmallstep_model):
+        root = mpsmallstep_model.add_root()
         method = root.add_child
         for i in range(1, 10):
             method()
-        self.assertRaises(PathOverflow, method)
+        with pytest.raises(PathOverflow):
+            method()
 
-    def test_add_sibling(self):
-        root = models.MP_TestNodeSmallStep.add_root()
+    def test_add_sibling(self, mpsmallstep_model):
+        root = mpsmallstep_model.add_root()
         for i in range(1, 10):
             root.add_child()
-        method = root.get_last_child().add_sibling
         positions = ('first-sibling', 'left', 'right', 'last-sibling')
         for pos in positions:
-            self.assertRaises(PathOverflow, method, pos)
+            with pytest.raises(PathOverflow):
+                root.get_last_child().add_sibling(pos)
 
-    def test_move(self):
-        root = models.MP_TestNodeSmallStep.add_root()
+    def test_move(self, mpsmallstep_model):
+        root = mpsmallstep_model.add_root()
         for i in range(1, 10):
             root.add_child()
-        newroot = models.MP_TestNodeSmallStep.add_root()
+        newroot = mpsmallstep_model.add_root()
         targets = [(root, ['first-child', 'last-child']),
                    (root.get_first_child(), ['first-sibling',
                                              'left',
                                              'last-sibling'])]