29
32
"""Unit tests for nodes (Base, Leaf, Node)."""
31
def test_deprecated_prefix_methods(self):
32
l = pytree.Leaf(100, "foo")
33
with warnings.catch_warnings(record=True) as w:
34
warnings.simplefilter("always", DeprecationWarning)
35
self.assertEqual(l.get_prefix(), "")
37
self.assertEqual(l.prefix, "hi")
38
self.assertEqual(len(w), 2)
40
self.assertTrue(warning.category is DeprecationWarning)
41
self.assertEqual(str(w[0].message), "get_prefix() is deprecated; " \
42
"use the prefix property")
43
self.assertEqual(str(w[1].message), "set_prefix() is deprecated; " \
44
"use the prefix property")
34
if sys.version_info >= (2,6):
35
# warnings.catch_warnings is new in 2.6.
36
def test_deprecated_prefix_methods(self):
37
l = pytree.Leaf(100, "foo")
38
with warnings.catch_warnings(record=True) as w:
39
warnings.simplefilter("always", DeprecationWarning)
40
self.assertEqual(l.get_prefix(), "")
42
self.assertEqual(l.prefix, "hi")
43
self.assertEqual(len(w), 2)
45
self.assertTrue(warning.category is DeprecationWarning)
46
self.assertEqual(str(w[0].message), "get_prefix() is deprecated; " \
47
"use the prefix property")
48
self.assertEqual(str(w[1].message), "set_prefix() is deprecated; " \
49
"use the prefix property")
46
51
def test_instantiate_base(self):