Kaydet (Commit) 286a0d2f authored tarafından Benjamin Peterson's avatar Benjamin Peterson

Merged revisions 73725 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

................
  r73725 | benjamin.peterson | 2009-06-30 19:49:09 -0500 (Tue, 30 Jun 2009) | 21 lines

  Merged revisions 73379,73388,73507,73722 via svnmerge from
  svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3

  ........
    r73379 | benjamin.peterson | 2009-06-11 18:06:21 -0500 (Thu, 11 Jun 2009) | 1 line

    use a real conditional expresion
  ........
    r73388 | benjamin.peterson | 2009-06-12 09:44:29 -0500 (Fri, 12 Jun 2009) | 1 line

    fix typo in last fix
  ........
    r73507 | benjamin.peterson | 2009-06-22 13:32:04 -0500 (Mon, 22 Jun 2009) | 1 line

    remove svn:executable property
  ........
    r73722 | benjamin.peterson | 2009-06-30 19:44:30 -0500 (Tue, 30 Jun 2009) | 1 line

    replace fail* with assert*
  ........
................
üst a4aba66e
...@@ -66,7 +66,7 @@ class FixDict(fixer_base.BaseFix): ...@@ -66,7 +66,7 @@ class FixDict(fixer_base.BaseFix):
new = pytree.Node(syms.power, args) new = pytree.Node(syms.power, args)
if not special: if not special:
new.prefix = "" new.prefix = ""
new = Call(Name(isiter and "iter" or "list"), [new]) new = Call(Name("iter" if isiter else "list"), [new])
if tail: if tail:
new = pytree.Node(syms.power, [new] + tail) new = pytree.Node(syms.power, [new] + tail)
new.prefix = node.prefix new.prefix = node.prefix
......
File mode changed from 100755 to 100644
...@@ -32,20 +32,20 @@ class FixerTestCase(support.TestCase): ...@@ -32,20 +32,20 @@ class FixerTestCase(support.TestCase):
before = support.reformat(before) before = support.reformat(before)
after = support.reformat(after) after = support.reformat(after)
tree = self.refactor.refactor_string(before, self.filename) tree = self.refactor.refactor_string(before, self.filename)
self.failUnlessEqual(after, str(tree)) self.assertEqual(after, str(tree))
return tree return tree
def check(self, before, after, ignore_warnings=False): def check(self, before, after, ignore_warnings=False):
tree = self._check(before, after) tree = self._check(before, after)
self.failUnless(tree.was_changed) self.assertTrue(tree.was_changed)
if not ignore_warnings: if not ignore_warnings:
self.failUnlessEqual(self.fixer_log, []) self.assertEqual(self.fixer_log, [])
def warns(self, before, after, message, unchanged=False): def warns(self, before, after, message, unchanged=False):
tree = self._check(before, after) tree = self._check(before, after)
self.failUnless(message in "".join(self.fixer_log)) self.assertTrue(message in "".join(self.fixer_log))
if not unchanged: if not unchanged:
self.failUnless(tree.was_changed) self.assertTrue(tree.was_changed)
def warns_unchanged(self, before, message): def warns_unchanged(self, before, message):
self.warns(before, before, message, unchanged=True) self.warns(before, before, message, unchanged=True)
...@@ -53,7 +53,7 @@ class FixerTestCase(support.TestCase): ...@@ -53,7 +53,7 @@ class FixerTestCase(support.TestCase):
def unchanged(self, before, ignore_warnings=False): def unchanged(self, before, ignore_warnings=False):
self._check(before, before) self._check(before, before)
if not ignore_warnings: if not ignore_warnings:
self.failUnlessEqual(self.fixer_log, []) self.assertEqual(self.fixer_log, [])
def assert_runs_after(self, *names): def assert_runs_after(self, *names):
fixes = [self.fixer] fixes = [self.fixer]
......
...@@ -81,10 +81,10 @@ class TestNodes(support.TestCase): ...@@ -81,10 +81,10 @@ class TestNodes(support.TestCase):
def test_leaf_prefix(self): def test_leaf_prefix(self):
l1 = pytree.Leaf(100, "foo") l1 = pytree.Leaf(100, "foo")
self.assertEqual(l1.prefix, "") self.assertEqual(l1.prefix, "")
self.failIf(l1.was_changed) self.assertFalse(l1.was_changed)
l1.prefix = " ##\n\n" l1.prefix = " ##\n\n"
self.assertEqual(l1.prefix, " ##\n\n") self.assertEqual(l1.prefix, " ##\n\n")
self.failUnless(l1.was_changed) self.assertTrue(l1.was_changed)
def test_node(self): def test_node(self):
l1 = pytree.Leaf(100, "foo") l1 = pytree.Leaf(100, "foo")
...@@ -154,13 +154,13 @@ class TestNodes(support.TestCase): ...@@ -154,13 +154,13 @@ class TestNodes(support.TestCase):
l3 = pytree.Leaf(100, "bar") l3 = pytree.Leaf(100, "bar")
n1 = pytree.Node(1000, [l1, l2, l3]) n1 = pytree.Node(1000, [l1, l2, l3])
self.assertEqual(n1.children, [l1, l2, l3]) self.assertEqual(n1.children, [l1, l2, l3])
self.failUnless(isinstance(n1.children, list)) self.assertTrue(isinstance(n1.children, list))
self.failIf(n1.was_changed) self.assertFalse(n1.was_changed)
l2new = pytree.Leaf(100, "-") l2new = pytree.Leaf(100, "-")
l2.replace(l2new) l2.replace(l2new)
self.assertEqual(n1.children, [l1, l2new, l3]) self.assertEqual(n1.children, [l1, l2new, l3])
self.failUnless(isinstance(n1.children, list)) self.assertTrue(isinstance(n1.children, list))
self.failUnless(n1.was_changed) self.assertTrue(n1.was_changed)
def test_replace_with_list(self): def test_replace_with_list(self):
l1 = pytree.Leaf(100, "foo") l1 = pytree.Leaf(100, "foo")
...@@ -170,7 +170,7 @@ class TestNodes(support.TestCase): ...@@ -170,7 +170,7 @@ class TestNodes(support.TestCase):
l2.replace([pytree.Leaf(100, "*"), pytree.Leaf(100, "*")]) l2.replace([pytree.Leaf(100, "*"), pytree.Leaf(100, "*")])
self.assertEqual(str(n1), "foo**bar") self.assertEqual(str(n1), "foo**bar")
self.failUnless(isinstance(n1.children, list)) self.assertTrue(isinstance(n1.children, list))
def test_post_order(self): def test_post_order(self):
l1 = pytree.Leaf(100, "foo") l1 = pytree.Leaf(100, "foo")
...@@ -186,34 +186,34 @@ class TestNodes(support.TestCase): ...@@ -186,34 +186,34 @@ class TestNodes(support.TestCase):
def test_changed(self): def test_changed(self):
l1 = pytree.Leaf(100, "f") l1 = pytree.Leaf(100, "f")
self.failIf(l1.was_changed) self.assertFalse(l1.was_changed)
l1.changed() l1.changed()
self.failUnless(l1.was_changed) self.assertTrue(l1.was_changed)
l1 = pytree.Leaf(100, "f") l1 = pytree.Leaf(100, "f")
n1 = pytree.Node(1000, [l1]) n1 = pytree.Node(1000, [l1])
self.failIf(n1.was_changed) self.assertFalse(n1.was_changed)
n1.changed() n1.changed()
self.failUnless(n1.was_changed) self.assertTrue(n1.was_changed)
l1 = pytree.Leaf(100, "foo") l1 = pytree.Leaf(100, "foo")
l2 = pytree.Leaf(100, "+") l2 = pytree.Leaf(100, "+")
l3 = pytree.Leaf(100, "bar") l3 = pytree.Leaf(100, "bar")
n1 = pytree.Node(1000, [l1, l2, l3]) n1 = pytree.Node(1000, [l1, l2, l3])
n2 = pytree.Node(1000, [n1]) n2 = pytree.Node(1000, [n1])
self.failIf(l1.was_changed) self.assertFalse(l1.was_changed)
self.failIf(n1.was_changed) self.assertFalse(n1.was_changed)
self.failIf(n2.was_changed) self.assertFalse(n2.was_changed)
n1.changed() n1.changed()
self.failUnless(n1.was_changed) self.assertTrue(n1.was_changed)
self.failUnless(n2.was_changed) self.assertTrue(n2.was_changed)
self.failIf(l1.was_changed) self.assertFalse(l1.was_changed)
def test_leaf_constructor_prefix(self): def test_leaf_constructor_prefix(self):
for prefix in ("xyz_", ""): for prefix in ("xyz_", ""):
l1 = pytree.Leaf(100, "self", prefix=prefix) l1 = pytree.Leaf(100, "self", prefix=prefix)
self.failUnless(str(l1), prefix + "self") self.assertTrue(str(l1), prefix + "self")
self.assertEqual(l1.prefix, prefix) self.assertEqual(l1.prefix, prefix)
def test_node_constructor_prefix(self): def test_node_constructor_prefix(self):
...@@ -221,7 +221,7 @@ class TestNodes(support.TestCase): ...@@ -221,7 +221,7 @@ class TestNodes(support.TestCase):
l1 = pytree.Leaf(100, "self") l1 = pytree.Leaf(100, "self")
l2 = pytree.Leaf(100, "foo", prefix="_") l2 = pytree.Leaf(100, "foo", prefix="_")
n1 = pytree.Node(1000, [l1, l2], prefix=prefix) n1 = pytree.Node(1000, [l1, l2], prefix=prefix)
self.failUnless(str(n1), prefix + "self_foo") self.assertTrue(str(n1), prefix + "self_foo")
self.assertEqual(n1.prefix, prefix) self.assertEqual(n1.prefix, prefix)
self.assertEqual(l1.prefix, prefix) self.assertEqual(l1.prefix, prefix)
self.assertEqual(l2.prefix, "_") self.assertEqual(l2.prefix, "_")
...@@ -237,8 +237,8 @@ class TestNodes(support.TestCase): ...@@ -237,8 +237,8 @@ class TestNodes(support.TestCase):
self.assertEqual(l1.parent, n1) self.assertEqual(l1.parent, n1)
self.assertEqual(n1.parent, None) self.assertEqual(n1.parent, None)
self.assertEqual(n2.parent, None) self.assertEqual(n2.parent, None)
self.failIf(n1.was_changed) self.assertFalse(n1.was_changed)
self.failUnless(n2.was_changed) self.assertTrue(n2.was_changed)
self.assertEqual(l2.remove(), 1) self.assertEqual(l2.remove(), 1)
self.assertEqual(l1.remove(), 0) self.assertEqual(l1.remove(), 0)
...@@ -246,8 +246,8 @@ class TestNodes(support.TestCase): ...@@ -246,8 +246,8 @@ class TestNodes(support.TestCase):
self.assertEqual(l1.parent, None) self.assertEqual(l1.parent, None)
self.assertEqual(n1.parent, None) self.assertEqual(n1.parent, None)
self.assertEqual(n2.parent, None) self.assertEqual(n2.parent, None)
self.failUnless(n1.was_changed) self.assertTrue(n1.was_changed)
self.failUnless(n2.was_changed) self.assertTrue(n2.was_changed)
def test_remove_parentless(self): def test_remove_parentless(self):
n1 = pytree.Node(1000, []) n1 = pytree.Node(1000, [])
...@@ -316,7 +316,7 @@ class TestNodes(support.TestCase): ...@@ -316,7 +316,7 @@ class TestNodes(support.TestCase):
n2 = pytree.Node(1000, []) n2 = pytree.Node(1000, [])
p1 = pytree.Node(1000, [n1, n2]) p1 = pytree.Node(1000, [n1, n2])
self.failUnless(n1.next_sibling is n2) self.assertTrue(n1.next_sibling is n2)
self.assertEqual(n2.next_sibling, None) self.assertEqual(n2.next_sibling, None)
self.assertEqual(p1.next_sibling, None) self.assertEqual(p1.next_sibling, None)
...@@ -325,7 +325,7 @@ class TestNodes(support.TestCase): ...@@ -325,7 +325,7 @@ class TestNodes(support.TestCase):
l2 = pytree.Leaf(100, "b") l2 = pytree.Leaf(100, "b")
p1 = pytree.Node(1000, [l1, l2]) p1 = pytree.Node(1000, [l1, l2])
self.failUnless(l1.next_sibling is l2) self.assertTrue(l1.next_sibling is l2)
self.assertEqual(l2.next_sibling, None) self.assertEqual(l2.next_sibling, None)
self.assertEqual(p1.next_sibling, None) self.assertEqual(p1.next_sibling, None)
...@@ -334,7 +334,7 @@ class TestNodes(support.TestCase): ...@@ -334,7 +334,7 @@ class TestNodes(support.TestCase):
n2 = pytree.Node(1000, []) n2 = pytree.Node(1000, [])
p1 = pytree.Node(1000, [n1, n2]) p1 = pytree.Node(1000, [n1, n2])
self.failUnless(n2.prev_sibling is n1) self.assertTrue(n2.prev_sibling is n1)
self.assertEqual(n1.prev_sibling, None) self.assertEqual(n1.prev_sibling, None)
self.assertEqual(p1.prev_sibling, None) self.assertEqual(p1.prev_sibling, None)
...@@ -343,7 +343,7 @@ class TestNodes(support.TestCase): ...@@ -343,7 +343,7 @@ class TestNodes(support.TestCase):
l2 = pytree.Leaf(100, "b") l2 = pytree.Leaf(100, "b")
p1 = pytree.Node(1000, [l1, l2]) p1 = pytree.Node(1000, [l1, l2])
self.failUnless(l2.prev_sibling is l1) self.assertTrue(l2.prev_sibling is l1)
self.assertEqual(l1.prev_sibling, None) self.assertEqual(l1.prev_sibling, None)
self.assertEqual(p1.prev_sibling, None) self.assertEqual(p1.prev_sibling, None)
...@@ -416,7 +416,7 @@ class TestPatterns(support.TestCase): ...@@ -416,7 +416,7 @@ class TestPatterns(support.TestCase):
r = {} r = {}
self.assertTrue(pw.match_seq([l1, l3], r)) self.assertTrue(pw.match_seq([l1, l3], r))
self.assertEqual(r, {"pl": l3, "pw": [l1, l3]}) self.assertEqual(r, {"pl": l3, "pw": [l1, l3]})
self.assert_(r["pl"] is l3) self.assertTrue(r["pl"] is l3)
r = {} r = {}
def test_generate_matches(self): def test_generate_matches(self):
...@@ -459,5 +459,5 @@ class TestPatterns(support.TestCase): ...@@ -459,5 +459,5 @@ class TestPatterns(support.TestCase):
l3 = pytree.Leaf(8, ")") l3 = pytree.Leaf(8, ")")
node = pytree.Node(331, [l1, l2, l3]) node = pytree.Node(331, [l1, l2, l3])
r = {} r = {}
self.assert_(pattern.match(node, r)) self.assertTrue(pattern.match(node, r))
self.assertEqual(r["args"], [l2]) self.assertEqual(r["args"], [l2])
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment