summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/case.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-11-22 12:56:58 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-11-22 12:56:58 (GMT)
commit2baf1a69f4d72e2107b0941a625fd7603f45ae38 (patch)
treecbd05dd5996a313b0cb813e2d8d01819b6154244 /Lib/unittest/case.py
parent60fafa276cefc677839927a0647c8bda3703be0b (diff)
downloadcpython-2baf1a69f4d72e2107b0941a625fd7603f45ae38.zip
cpython-2baf1a69f4d72e2107b0941a625fd7603f45ae38.tar.gz
cpython-2baf1a69f4d72e2107b0941a625fd7603f45ae38.tar.bz2
#9424: add a DeprecationWarning for assertEquals, assertNotEquals, assertAlmostEquals, assertNotAlmostEquals, and assert_
Diffstat (limited to 'Lib/unittest/case.py')
-rw-r--r--Lib/unittest/case.py26
1 files changed, 8 insertions, 18 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 68f6715..dbf7aa2 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -687,19 +687,7 @@ class TestCase(object):
msg = self._formatMessage(msg, standardMsg)
raise self.failureException(msg)
- # Synonyms for assertion methods
-
- # The plurals are undocumented. Keep them that way to discourage use.
- # Do not add more. Do not remove.
- # Going through a deprecation cycle on these would annoy many people.
- assertEquals = assertEqual
- assertNotEquals = assertNotEqual
- assertAlmostEquals = assertAlmostEqual
- assertNotAlmostEquals = assertNotAlmostEqual
- assert_ = assertTrue
-
- # These fail* assertion method names are pending deprecation and will
- # be a DeprecationWarning in 3.2; http://bugs.python.org/issue2578
+
def _deprecate(original_func):
def deprecated_func(*args, **kwargs):
warnings.warn(
@@ -708,11 +696,13 @@ class TestCase(object):
return original_func(*args, **kwargs)
return deprecated_func
- failUnlessEqual = _deprecate(assertEqual)
- failIfEqual = _deprecate(assertNotEqual)
- failUnlessAlmostEqual = _deprecate(assertAlmostEqual)
- failIfAlmostEqual = _deprecate(assertNotAlmostEqual)
- failUnless = _deprecate(assertTrue)
+ # The fail* methods can be removed in 3.3, the 5 assert* methods will
+ # have to stay around for a few more versions. See #9424.
+ failUnlessEqual = assertEquals = _deprecate(assertEqual)
+ failIfEqual = assertNotEquals = _deprecate(assertNotEqual)
+ failUnlessAlmostEqual = assertAlmostEquals = _deprecate(assertAlmostEqual)
+ failIfAlmostEqual = assertNotAlmostEquals = _deprecate(assertNotAlmostEqual)
+ failUnless = assert_ = _deprecate(assertTrue)
failUnlessRaises = _deprecate(assertRaises)
failIf = _deprecate(assertFalse)