diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-06-30 23:45:41 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-06-30 23:45:41 (GMT) |
commit | 6bcbad5f519d1e09fc32a3a2afc7082245b6080b (patch) | |
tree | e85a966c219f7fc0b74c0f075d572cf867b59f8a /Lib/test/test_unittest.py | |
parent | e1759f8da5d4d2e1ee276eb16c569021afd5d28c (diff) | |
download | cpython-6bcbad5f519d1e09fc32a3a2afc7082245b6080b.zip cpython-6bcbad5f519d1e09fc32a3a2afc7082245b6080b.tar.gz cpython-6bcbad5f519d1e09fc32a3a2afc7082245b6080b.tar.bz2 |
test that depreacted methods give warnings
Diffstat (limited to 'Lib/test/test_unittest.py')
-rw-r--r-- | Lib/test/test_unittest.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py index 0d940b6..af684c0 100644 --- a/Lib/test/test_unittest.py +++ b/Lib/test/test_unittest.py @@ -9,6 +9,7 @@ Still need testing: import os import re import sys +import warnings from test import support import unittest from unittest import TestCase, TestProgram @@ -2810,13 +2811,20 @@ test case 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 |