Commits

Gustavo Picon committed d9a57c2

pep8

Comments (0)

Files changed (3)

treebeard/al_tree.py

             qset = qset.filter(parent__isnull=True)
         else:
             qset = qset.filter(parent=target_node.parent)
-        qset.update(sib_order=models.F('sib_order')+1)
+        qset.update(sib_order=models.F('sib_order') + 1)
 
     @classmethod
     def _make_hole_and_get_sibling_order(cls, pos, target_node):

treebeard/models.py

         """Removes a node and all it's descendants."""
         self.__class__.objects.filter(id=self.pk).delete()
 
-
-    def _prepare_pos_var(self, pos, method_name, valid_pos,
-                                valid_sorted_pos):
+    def _prepare_pos_var(self, pos, method_name, valid_pos, valid_sorted_pos):
         if pos is None:
             if self.node_order_by:
                 pos = 'sorted-sibling'

treebeard/tests/test_treebeard.py

         mpalphabet_model(path='04', depth=10, numchild=1, numval=0).save()
         mpalphabet_model(path='0401', depth=20, numchild=0, numval=0).save()
 
+        def got(ids):
+            return [o.path for o in
+                    mpalphabet_model.objects.filter(id__in=ids)]
+
         (evil_chars, bad_steplen, orphans, wrong_depth, wrong_numchild) = (
             mpalphabet_model.find_problems())
-        got = [o.path for o in mpalphabet_model.objects.filter(id__in=evil_chars)]
-        assert ['abcd', 'qa#$%!'] == got
-        got = [o.path for o in mpalphabet_model.objects.filter(id__in=bad_steplen)]
-        assert ['1', '111'] == got
-        got = [o.path for o in mpalphabet_model.objects.filter(id__in=orphans)]
-        assert ['0201', '020201'] == got
-        got = [o.path for o in mpalphabet_model.objects.filter(id__in=wrong_numchild)]
-        assert ['03', '0301', '030102'] == got
-        got = [o.path for o in mpalphabet_model.objects.filter(id__in=wrong_depth)]
-        assert ['04', '0401'] == got
+        assert ['abcd', 'qa#$%!'] == got(evil_chars)
+        assert ['1', '111'] == got(bad_steplen)
+        assert ['0201', '020201'] == got(orphans)
+        assert ['03', '0301', '030102'] == got(wrong_numchild)
+        assert ['04', '0401'] == got(wrong_depth)
 
 
 class TestMP_TreeFix(TestTreeBase):