diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2009-03-31 19:59:14 +0000 |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2009-03-31 19:59:14 +0000 |
commit | 65ff00559a1192bccb23b5af9abb54db361d9124 (patch) | |
tree | 4e98f118bd90d4ee6762fd6ba75d8f73a09be744 /Lib/unittest.py | |
parent | 41448c58d25386b4040cebc9d8078fe1749365e6 (diff) | |
download | cpython-git-65ff00559a1192bccb23b5af9abb54db361d9124.tar.gz |
Issue an actual PendingDeprecationWarning for the TestCase.fail* methods.
Document the deprecation.
Diffstat (limited to 'Lib/unittest.py')
-rw-r--r-- | Lib/unittest.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py index ba6a0f9ce6..9718e8636c 100644 --- a/Lib/unittest.py +++ b/Lib/unittest.py @@ -54,6 +54,7 @@ import sys import time import traceback import types +import warnings ############################################################################## # Exported classes and functions @@ -574,15 +575,22 @@ class TestCase(object): assert_ = assertTrue # These fail* assertion method names are pending deprecation and will - # be a deprecation warning in 3.2; http://bugs.python.org/issue2578 - failUnlessEqual = assertEqual - failIfEqual = assertNotEqual - failUnlessAlmostEqual = assertAlmostEqual - failIfAlmostEqual = assertNotAlmostEqual - failUnless = assertTrue - failUnlessRaises = assertRaises - failIf = assertFalse - + # be a DeprecationWarning in 3.2; http://bugs.python.org/issue2578 + def __deprecate(original_func): + def deprecated_func(*args, **kwargs): + warnings.warn( + 'Please use {0} instead.'.format(original_func.__name__), + PendingDeprecationWarning, 2) + return original_func(*args, **kwargs) + return deprecated_func + + failUnlessEqual = __deprecate(assertEqual) + failIfEqual = __deprecate(assertNotEqual) + failUnlessAlmostEqual = __deprecate(assertAlmostEqual) + failIfAlmostEqual = __deprecate(assertNotAlmostEqual) + failUnless = __deprecate(assertTrue) + failUnlessRaises = __deprecate(assertRaises) + failIf = __deprecate(assertFalse) def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None): """An equality assertion for ordered sequences (like lists and tuples). |