~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_symbol_versioning.py

  • Committer: Robert Collins
  • Date: 2006-01-05 11:03:07 UTC
  • mto: (1534.1.2 integration)
  • mto: This revision was merged to the branch mainline in revision 1536.
  • Revision ID: robertc@robertcollins.net-20060105110307-21db4cbdfd94f2c6
Implement deprecated_function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib.tests import TestCase
22
22
 
23
23
 
 
24
@symbol_versioning.deprecated_function(symbol_versioning.zero_seven)
 
25
def deprecated_function():
 
26
    return 1
 
27
 
24
28
 
25
29
class TestDeprecationWarnings(TestCase):
26
30
 
33
37
    
34
38
    @symbol_versioning.deprecated_method(symbol_versioning.zero_seven)
35
39
    def deprecated_method(self):
36
 
        return
 
40
        return 1
37
41
 
38
42
    def test_deprecated_method(self):
 
43
        expected_warning = (
 
44
            "bzrlib.tests.test_symbol_versioning."
 
45
            "TestDeprecationWarnings.deprecated_method "
 
46
            "was deprecated in version 0.7", DeprecationWarning)
 
47
        self.check_deprecated_callable(expected_warning,
 
48
                                       self.deprecated_method)
 
49
 
 
50
    def test_deprecated_function(self):
 
51
        expected_warning = (
 
52
            "bzrlib.tests.test_symbol_versioning.deprecated_function "
 
53
            "was deprecated in version 0.7", DeprecationWarning)
 
54
        self.check_deprecated_callable(expected_warning,
 
55
                                       deprecated_function)
 
56
 
 
57
    def check_deprecated_callable(self, expected_warning, deprecated_callable):
39
58
        old_warning_method = symbol_versioning.warn
40
 
        expected_warning = (
41
 
            "bzrlib.tests.test_symbol_versioning.TestDeprecationWarnings.deprecated_method "
42
 
            "was deprecated in version 0.7", DeprecationWarning)
43
59
        try:
44
60
            symbol_versioning.set_warning_method(self.capture_warning)
45
 
            self.deprecated_method()
 
61
            self.assertEqual(1, deprecated_callable())
46
62
            self.assertEqual([expected_warning], self._warnings)
47
 
            self.deprecated_method()
 
63
            deprecated_callable()
48
64
            self.assertEqual([expected_warning, expected_warning],
49
65
                             self._warnings)
50
66
        finally: