~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_symbol_versioning.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-04-27 01:14:33 UTC
  • mfrom: (1686.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060427011433-95634ee1da8a2049
Merge in faster joins from weave to knit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    return 1
28
28
 
29
29
 
30
 
a_deprecated_list = symbol_versioning.deprecated_list(symbol_versioning.zero_nine,
31
 
    'a_deprecated_list', ['one'], extra="Don't use me")
32
 
 
33
 
 
34
30
class TestDeprecationWarnings(TestCase):
35
31
 
36
32
    def capture_warning(self, message, category, stacklevel=None):
77
73
                                       "bzrlib.tests.test_symbol_versioning",
78
74
                                       deprecated_function)
79
75
 
80
 
    def test_deprecated_list(self):
81
 
        expected_warning = (
82
 
            "Modifying a_deprecated_list was deprecated in version 0.9."
83
 
            " Don't use me", DeprecationWarning, 3)
84
 
        expected_doctstring = ('appending to a_deprecated_list is deprecated')
85
 
 
86
 
        old_warning_method = symbol_versioning.warn
87
 
        try:
88
 
            symbol_versioning.set_warning_method(self.capture_warning)
89
 
            self.assertEqual(['one'], a_deprecated_list)
90
 
            self.assertEqual([], self._warnings)
91
 
 
92
 
            a_deprecated_list.append('foo')
93
 
            self.assertEqual([expected_warning], self._warnings)
94
 
            self.assertEqual(['one', 'foo'], a_deprecated_list)
95
 
 
96
 
            a_deprecated_list.extend(['bar', 'baz'])
97
 
            self.assertEqual([expected_warning]*2, self._warnings)
98
 
            self.assertEqual(['one', 'foo', 'bar', 'baz'], a_deprecated_list)
99
 
 
100
 
            a_deprecated_list.insert(1, 'xxx')
101
 
            self.assertEqual([expected_warning]*3, self._warnings)
102
 
            self.assertEqual(['one', 'xxx', 'foo', 'bar', 'baz'], a_deprecated_list)
103
 
 
104
 
            a_deprecated_list.remove('foo')
105
 
            self.assertEqual([expected_warning]*4, self._warnings)
106
 
            self.assertEqual(['one', 'xxx', 'bar', 'baz'], a_deprecated_list)
107
 
 
108
 
            val = a_deprecated_list.pop()
109
 
            self.assertEqual([expected_warning]*5, self._warnings)
110
 
            self.assertEqual('baz', val)
111
 
            self.assertEqual(['one', 'xxx', 'bar'], a_deprecated_list)
112
 
 
113
 
            val = a_deprecated_list.pop(1)
114
 
            self.assertEqual([expected_warning]*6, self._warnings)
115
 
            self.assertEqual('xxx', val)
116
 
            self.assertEqual(['one', 'bar'], a_deprecated_list)
117
 
        finally:
118
 
            symbol_versioning.set_warning_method(old_warning_method)
119
 
 
120
76
    def check_deprecated_callable(self, expected_warning, expected_docstring,
121
77
                                  expected_name, expected_module,
122
78
                                  deprecated_callable):