r73719 - python/branches/py3k/Lib/test/test_unittest.py
Author: benjamin.peterson Date: Wed Jul 1 01:45:41 2009 New Revision: 73719 Log: test that depreacted methods give warnings Modified: python/branches/py3k/Lib/test/test_unittest.py Modified: python/branches/py3k/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k/Lib/test/test_unittest.py (original) +++ python/branches/py3k/Lib/test/test_unittest.py Wed Jul 1 01:45:41 2009 @@ -9,6 +9,7 @@ import os import re import sys +import warnings from test import support import unittest from unittest import TestCase, TestProgram @@ -2810,13 +2811,20 @@ Do not use these methods. They will go away in 3.3. """ - self.failIfEqual(3, 5) - self.failUnlessEqual(3, 3) - self.failUnlessAlmostEqual(2.0, 2.0) - self.failIfAlmostEqual(3.0, 5.0) - self.failUnless(True) - self.failUnlessRaises(TypeError, lambda _: 3.14 + 'spam') - self.failIf(False) + old = ( + (self.failIfEqual, (3, 5)), + (self.failUnlessEqual, (3, 3)), + (self.failUnlessAlmostEqual, (2.0, 2.0)), + (self.failIfAlmostEqual, (3.0, 5.0)), + (self.failUnless, (True,)), + (self.failUnlessRaises, (TypeError, lambda _: 3.14 + 'spam')), + (self.failIf, (False,)) + ) + for meth, args in old: + with warnings.catch_warnings(record=True) as w: + meth(*args) + self.assertEqual(len(w), 1) + self.assertIs(w[0].category, DeprecationWarning) def testDeepcopy(self): # Issue: 5660
participants (1)
-
benjamin.peterson