~ubuntu-branches/ubuntu/natty/python3.1/natty-security

« back to all changes in this revision

Viewing changes to Lib/lib2to3/tests/test_pytree.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-07-06 16:52:42 UTC
  • mfrom: (1.2.1 upstream) (2.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20100706165242-2xv4i019r3et6c0j
Tags: 3.1.2+20100706-1ubuntu1
* Merge with Debian; remaining changes:
  - Regenerate the control file.
  - Add debian/patches/overwrite-semaphore-check for Lucid buildds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
especially when debugging a test.
10
10
"""
11
11
 
 
12
from __future__ import with_statement
 
13
 
 
14
import sys
12
15
import warnings
13
16
 
14
17
# Testing imports
28
31
 
29
32
    """Unit tests for nodes (Base, Leaf, Node)."""
30
33
 
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(), "")
36
 
            l.set_prefix("hi")
37
 
        self.assertEqual(l.prefix, "hi")
38
 
        self.assertEqual(len(w), 2)
39
 
        for warning in w:
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(), "")
 
41
                l.set_prefix("hi")
 
42
            self.assertEqual(l.prefix, "hi")
 
43
            self.assertEqual(len(w), 2)
 
44
            for warning in w:
 
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")
45
50
 
46
51
    def test_instantiate_base(self):
47
52
        if __debug__: