~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-24 01:08:12 UTC
  • mfrom: (3948.3.9 deprecation)
  • Revision ID: pqm@pqm.ubuntu.com-20090324010812-lrfx6zoeu7q0fftv
(mbp) remove code deprecated up to 1.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
43
43
    weaverepo,
44
44
    )
45
45
from bzrlib.symbol_versioning import (
46
 
    one_zero,
47
 
    zero_eleven,
48
 
    zero_ten,
 
46
    deprecated_function,
 
47
    deprecated_in,
 
48
    deprecated_method,
49
49
    )
50
50
from bzrlib.tests import (
51
51
                          ChrootedTestCase,
1654
1654
            self.assertListRaises, _TestException, success_generator)
1655
1655
 
1656
1656
 
1657
 
@symbol_versioning.deprecated_function(zero_eleven)
 
1657
# NB: Don't delete this; it's not actually from 0.11!
 
1658
@deprecated_function(deprecated_in((0, 11, 0)))
1658
1659
def sample_deprecated_function():
1659
1660
    """A deprecated function to test applyDeprecated with."""
1660
1661
    return 2
1667
1668
class ApplyDeprecatedHelper(object):
1668
1669
    """A helper class for ApplyDeprecated tests."""
1669
1670
 
1670
 
    @symbol_versioning.deprecated_method(zero_eleven)
 
1671
    @deprecated_method(deprecated_in((0, 11, 0)))
1671
1672
    def sample_deprecated_method(self, param_one):
1672
1673
        """A deprecated method for testing with."""
1673
1674
        return param_one
1675
1676
    def sample_normal_method(self):
1676
1677
        """A undeprecated method."""
1677
1678
 
1678
 
    @symbol_versioning.deprecated_method(zero_ten)
 
1679
    @deprecated_method(deprecated_in((0, 10, 0)))
1679
1680
    def sample_nested_deprecation(self):
1680
1681
        return sample_deprecated_function()
1681
1682
 
1696
1697
    def test_applyDeprecated_not_deprecated(self):
1697
1698
        sample_object = ApplyDeprecatedHelper()
1698
1699
        # calling an undeprecated callable raises an assertion
1699
 
        self.assertRaises(AssertionError, self.applyDeprecated, zero_eleven,
 
1700
        self.assertRaises(AssertionError, self.applyDeprecated,
 
1701
            deprecated_in((0, 11, 0)),
1700
1702
            sample_object.sample_normal_method)
1701
 
        self.assertRaises(AssertionError, self.applyDeprecated, zero_eleven,
 
1703
        self.assertRaises(AssertionError, self.applyDeprecated,
 
1704
            deprecated_in((0, 11, 0)),
1702
1705
            sample_undeprecated_function, "a param value")
1703
1706
        # calling a deprecated callable (function or method) with the wrong
1704
1707
        # expected deprecation fails.
1705
 
        self.assertRaises(AssertionError, self.applyDeprecated, zero_ten,
 
1708
        self.assertRaises(AssertionError, self.applyDeprecated,
 
1709
            deprecated_in((0, 10, 0)),
1706
1710
            sample_object.sample_deprecated_method, "a param value")
1707
 
        self.assertRaises(AssertionError, self.applyDeprecated, zero_ten,
 
1711
        self.assertRaises(AssertionError, self.applyDeprecated,
 
1712
            deprecated_in((0, 10, 0)),
1708
1713
            sample_deprecated_function)
1709
1714
        # calling a deprecated callable (function or method) with the right
1710
1715
        # expected deprecation returns the functions result.
1711
 
        self.assertEqual("a param value", self.applyDeprecated(zero_eleven,
 
1716
        self.assertEqual("a param value",
 
1717
            self.applyDeprecated(deprecated_in((0, 11, 0)),
1712
1718
            sample_object.sample_deprecated_method, "a param value"))
1713
 
        self.assertEqual(2, self.applyDeprecated(zero_eleven,
 
1719
        self.assertEqual(2, self.applyDeprecated(deprecated_in((0, 11, 0)),
1714
1720
            sample_deprecated_function))
1715
1721
        # calling a nested deprecation with the wrong deprecation version
1716
1722
        # fails even if a deeper nested function was deprecated with the
1717
1723
        # supplied version.
1718
1724
        self.assertRaises(AssertionError, self.applyDeprecated,
1719
 
            zero_eleven, sample_object.sample_nested_deprecation)
 
1725
            deprecated_in((0, 11, 0)), sample_object.sample_nested_deprecation)
1720
1726
        # calling a nested deprecation with the right deprecation value
1721
1727
        # returns the calls result.
1722
 
        self.assertEqual(2, self.applyDeprecated(zero_ten,
 
1728
        self.assertEqual(2, self.applyDeprecated(deprecated_in((0, 10, 0)),
1723
1729
            sample_object.sample_nested_deprecation))
1724
1730
 
1725
1731
    def test_callDeprecated(self):