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))
1725
1731
def test_callDeprecated(self):