summaryrefslogtreecommitdiff
path: root/Lib/lib2to3/tests/test_pytree.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/lib2to3/tests/test_pytree.py')
-rw-r--r--Lib/lib2to3/tests/test_pytree.py33
1 files changed, 8 insertions, 25 deletions
diff --git a/Lib/lib2to3/tests/test_pytree.py b/Lib/lib2to3/tests/test_pytree.py
index ac7d9006aa..4d585a8841 100644
--- a/Lib/lib2to3/tests/test_pytree.py
+++ b/Lib/lib2to3/tests/test_pytree.py
@@ -31,23 +31,6 @@ class TestNodes(support.TestCase):
"""Unit tests for nodes (Base, Leaf, Node)."""
- if sys.version_info >= (2,6):
- # warnings.catch_warnings is new in 2.6.
- def test_deprecated_prefix_methods(self):
- l = pytree.Leaf(100, "foo")
- with warnings.catch_warnings(record=True) as w:
- warnings.simplefilter("always", DeprecationWarning)
- self.assertEqual(l.get_prefix(), "")
- l.set_prefix("hi")
- self.assertEqual(l.prefix, "hi")
- self.assertEqual(len(w), 2)
- for warning in w:
- self.assertTrue(warning.category is DeprecationWarning)
- self.assertEqual(str(w[0].message), "get_prefix() is deprecated; " \
- "use the prefix property")
- self.assertEqual(str(w[1].message), "set_prefix() is deprecated; " \
- "use the prefix property")
-
def test_instantiate_base(self):
if __debug__:
# Test that instantiating Base() raises an AssertionError
@@ -160,12 +143,12 @@ class TestNodes(support.TestCase):
l3 = pytree.Leaf(100, "bar")
n1 = pytree.Node(1000, [l1, l2, l3])
self.assertEqual(n1.children, [l1, l2, l3])
- self.assertTrue(isinstance(n1.children, list))
+ self.assertIsInstance(n1.children, list)
self.assertFalse(n1.was_changed)
l2new = pytree.Leaf(100, "-")
l2.replace(l2new)
self.assertEqual(n1.children, [l1, l2new, l3])
- self.assertTrue(isinstance(n1.children, list))
+ self.assertIsInstance(n1.children, list)
self.assertTrue(n1.was_changed)
def test_replace_with_list(self):
@@ -176,7 +159,7 @@ class TestNodes(support.TestCase):
l2.replace([pytree.Leaf(100, "*"), pytree.Leaf(100, "*")])
self.assertEqual(str(n1), "foo**bar")
- self.assertTrue(isinstance(n1.children, list))
+ self.assertIsInstance(n1.children, list)
def test_leaves(self):
l1 = pytree.Leaf(100, "foo")
@@ -347,7 +330,7 @@ class TestNodes(support.TestCase):
n2 = pytree.Node(1000, [])
p1 = pytree.Node(1000, [n1, n2])
- self.assertTrue(n1.next_sibling is n2)
+ self.assertIs(n1.next_sibling, n2)
self.assertEqual(n2.next_sibling, None)
self.assertEqual(p1.next_sibling, None)
@@ -356,7 +339,7 @@ class TestNodes(support.TestCase):
l2 = pytree.Leaf(100, "b")
p1 = pytree.Node(1000, [l1, l2])
- self.assertTrue(l1.next_sibling is l2)
+ self.assertIs(l1.next_sibling, l2)
self.assertEqual(l2.next_sibling, None)
self.assertEqual(p1.next_sibling, None)
@@ -365,7 +348,7 @@ class TestNodes(support.TestCase):
n2 = pytree.Node(1000, [])
p1 = pytree.Node(1000, [n1, n2])
- self.assertTrue(n2.prev_sibling is n1)
+ self.assertIs(n2.prev_sibling, n1)
self.assertEqual(n1.prev_sibling, None)
self.assertEqual(p1.prev_sibling, None)
@@ -374,7 +357,7 @@ class TestNodes(support.TestCase):
l2 = pytree.Leaf(100, "b")
p1 = pytree.Node(1000, [l1, l2])
- self.assertTrue(l2.prev_sibling is l1)
+ self.assertIs(l2.prev_sibling, l1)
self.assertEqual(l1.prev_sibling, None)
self.assertEqual(p1.prev_sibling, None)
@@ -447,7 +430,7 @@ class TestPatterns(support.TestCase):
r = {}
self.assertTrue(pw.match_seq([l1, l3], r))
self.assertEqual(r, {"pl": l3, "pw": [l1, l3]})
- self.assertTrue(r["pl"] is l3)
+ self.assertIs(r["pl"], l3)
r = {}
def test_generate_matches(self):