~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:43:50 UTC
  • mto: (1534.1.2 integration)
  • mto: This revision was merged to the branch mainline in revision 1536.
  • Revision ID: robertc@robertcollins.net-20060105114350-e21c40532770563e
decorate docstrings in deprecated functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
@symbol_versioning.deprecated_function(symbol_versioning.zero_seven)
25
25
def deprecated_function():
 
26
    """Deprecated function docstring."""
26
27
    return 1
27
28
 
28
29
 
37
38
    
38
39
    @symbol_versioning.deprecated_method(symbol_versioning.zero_seven)
39
40
    def deprecated_method(self):
 
41
        """Deprecated method docstring.
 
42
        
 
43
        This might explain stuff.
 
44
        """
40
45
        return 1
41
46
 
42
47
    def test_deprecated_method(self):
43
48
        expected_warning = (
44
49
            "bzrlib.tests.test_symbol_versioning."
45
50
            "TestDeprecationWarnings.deprecated_method "
46
 
            "was deprecated in version 0.7", DeprecationWarning)
47
 
        self.check_deprecated_callable(expected_warning,
 
51
            "was deprecated in version 0.7.", DeprecationWarning)
 
52
        expected_docstring = ('Deprecated method docstring.\n'
 
53
                              '        \n'
 
54
                              '        This might explain stuff.\n'
 
55
                              '        \n'
 
56
                              '        This method was deprecated in version 0.7.\n'
 
57
                              '        ')
 
58
        self.check_deprecated_callable(expected_warning, expected_docstring,
48
59
                                       self.deprecated_method)
49
60
 
50
61
    def test_deprecated_function(self):
51
62
        expected_warning = (
52
63
            "bzrlib.tests.test_symbol_versioning.deprecated_function "
53
 
            "was deprecated in version 0.7", DeprecationWarning)
54
 
        self.check_deprecated_callable(expected_warning,
 
64
            "was deprecated in version 0.7.", DeprecationWarning)
 
65
        expected_docstring = ('Deprecated function docstring.\n'
 
66
                              '\n'
 
67
                              'This function was deprecated in version 0.7.\n'
 
68
                              )
 
69
        self.check_deprecated_callable(expected_warning, expected_docstring,
55
70
                                       deprecated_function)
56
71
 
57
 
    def check_deprecated_callable(self, expected_warning, deprecated_callable):
 
72
    def check_deprecated_callable(self, expected_warning, expected_docstring,
 
73
                                  deprecated_callable):
58
74
        old_warning_method = symbol_versioning.warn
59
75
        try:
60
76
            symbol_versioning.set_warning_method(self.capture_warning)
63
79
            deprecated_callable()
64
80
            self.assertEqual([expected_warning, expected_warning],
65
81
                             self._warnings)
 
82
            self.assertEqualDiff(expected_docstring, deprecated_callable.__doc__)
66
83
        finally:
67
84
            symbol_versioning.set_warning_method(old_warning_method)