[Python-checkins] r83811 - in sandbox/trunk/2to3/lib2to3: pytree.py tests/test_pytree.py
benjamin.peterson
python-checkins at python.org
Sun Aug 8 05:56:44 CEST 2010
Author: benjamin.peterson
Date: Sun Aug 8 05:56:44 2010
New Revision: 83811
Log:
Fix node.pre_order() to call the right method on its children.
This was a rather tragic copy-paste error.
Modified:
sandbox/trunk/2to3/lib2to3/pytree.py
sandbox/trunk/2to3/lib2to3/tests/test_pytree.py
Modified: sandbox/trunk/2to3/lib2to3/pytree.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/pytree.py (original)
+++ sandbox/trunk/2to3/lib2to3/pytree.py Sun Aug 8 05:56:44 2010
@@ -286,7 +286,7 @@
"""Return a pre-order iterator for the tree."""
yield self
for child in self.children:
- for node in child.post_order():
+ for node in child.pre_order():
yield node
def _prefix_getter(self):
Modified: sandbox/trunk/2to3/lib2to3/tests/test_pytree.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/tests/test_pytree.py (original)
+++ sandbox/trunk/2to3/lib2to3/tests/test_pytree.py Sun Aug 8 05:56:44 2010
@@ -181,14 +181,18 @@
def test_post_order(self):
l1 = pytree.Leaf(100, "foo")
l2 = pytree.Leaf(100, "bar")
- n1 = pytree.Node(1000, [l1, l2])
- self.assertEqual(list(n1.post_order()), [l1, l2, n1])
+ l3 = pytree.Leaf(100, "fooey")
+ c1 = pytree.Node(1000, [l1, l2])
+ n1 = pytree.Node(1000, [c1, l3])
+ self.assertEqual(list(n1.post_order()), [l1, l2, c1, l3, n1])
def test_pre_order(self):
l1 = pytree.Leaf(100, "foo")
l2 = pytree.Leaf(100, "bar")
- n1 = pytree.Node(1000, [l1, l2])
- self.assertEqual(list(n1.pre_order()), [n1, l1, l2])
+ l3 = pytree.Leaf(100, "fooey")
+ c1 = pytree.Node(1000, [l1, l2])
+ n1 = pytree.Node(1000, [c1, l3])
+ self.assertEqual(list(n1.pre_order()), [n1, c1, l1, l2, l3])
def test_changed(self):
l1 = pytree.Leaf(100, "f")
More information about the Python-checkins
mailing list