summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-02-20 11:18:09 (GMT)
committerGeorg Brandl <georg@python.org>2011-02-20 11:18:09 (GMT)
commit2cebdd48657546bc89dd96e85210d3b56b302e8f (patch)
tree160598cdd73a3152750a1fcb9fe1eb3efbcfa9f6 /Lib/unittest/test
parentfa2c61a22279f286e6e3abee0581fe66eb812737 (diff)
downloadcpython-2cebdd48657546bc89dd96e85210d3b56b302e8f.zip
cpython-2cebdd48657546bc89dd96e85210d3b56b302e8f.tar.gz
cpython-2cebdd48657546bc89dd96e85210d3b56b302e8f.tar.bz2
Remove unittest methods scheduled for removal in 3.3 -- makes the unittest test suite pass again.
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r--Lib/unittest/test/_test_warnings.py7
-rw-r--r--Lib/unittest/test/test_assertions.py9
-rw-r--r--Lib/unittest/test/test_case.py52
-rw-r--r--Lib/unittest/test/test_runner.py10
4 files changed, 4 insertions, 74 deletions
diff --git a/Lib/unittest/test/_test_warnings.py b/Lib/unittest/test/_test_warnings.py
index d0be18d..bfabb02 100644
--- a/Lib/unittest/test/_test_warnings.py
+++ b/Lib/unittest/test/_test_warnings.py
@@ -19,17 +19,12 @@ def warnfun():
warnings.warn('rw', RuntimeWarning)
class TestWarnings(unittest.TestCase):
- # unittest warnings will be printed at most once per type (max one message
- # for the fail* methods, and one for the assert* methods)
+ # unittest warnings will be printed at most once per type
def test_assert(self):
self.assertEquals(2+2, 4)
self.assertEquals(2*2, 4)
self.assertEquals(2**2, 4)
- def test_fail(self):
- self.failUnless(1)
- self.failUnless(True)
-
def test_other_unittest(self):
self.assertAlmostEqual(2+2, 4)
self.assertNotAlmostEqual(4+4, 2)
diff --git a/Lib/unittest/test/test_assertions.py b/Lib/unittest/test/test_assertions.py
index a1d20eb..4a646c3 100644
--- a/Lib/unittest/test/test_assertions.py
+++ b/Lib/unittest/test/test_assertions.py
@@ -223,15 +223,6 @@ class TestLongMessage(unittest.TestCase):
"\+ \{'key': 'value'\}$",
"\+ \{'key': 'value'\} : oops$"])
- def testAssertDictContainsSubset(self):
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
-
- self.assertMessages('assertDictContainsSubset', ({'key': 'value'}, {}),
- ["^Missing: 'key'$", "^oops$",
- "^Missing: 'key'$",
- "^Missing: 'key' : oops$"])
-
def testAssertMultiLineEqual(self):
self.assertMessages('assertMultiLineEqual', ("", "foo"),
[r"\+ foo$", "^oops$",
diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py
index 314aef3..351b6f8 100644
--- a/Lib/unittest/test/test_case.py
+++ b/Lib/unittest/test/test_case.py
@@ -488,36 +488,6 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
self.assertRaises(self.failureException, self.assertNotIn, 'cow',
animals)
- def testAssertDictContainsSubset(self):
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
-
- self.assertDictContainsSubset({}, {})
- self.assertDictContainsSubset({}, {'a': 1})
- self.assertDictContainsSubset({'a': 1}, {'a': 1})
- self.assertDictContainsSubset({'a': 1}, {'a': 1, 'b': 2})
- self.assertDictContainsSubset({'a': 1, 'b': 2}, {'a': 1, 'b': 2})
-
- with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({1: "one"}, {})
-
- with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({'a': 2}, {'a': 1})
-
- with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({'c': 1}, {'a': 1})
-
- with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
-
- with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
-
- one = ''.join(chr(i) for i in range(255))
- # this used to cause a UnicodeDecodeError constructing the failure msg
- with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({'foo': one}, {'foo': '\uFFFD'})
-
def testAssertEqual(self):
equal_pairs = [
((), ()),
@@ -1094,20 +1064,11 @@ test case
have to stay around for a few more versions. See #9424.
"""
old = (
- (self.failIfEqual, (3, 5)),
(self.assertNotEquals, (3, 5)),
- (self.failUnlessEqual, (3, 3)),
(self.assertEquals, (3, 3)),
- (self.failUnlessAlmostEqual, (2.0, 2.0)),
(self.assertAlmostEquals, (2.0, 2.0)),
- (self.failIfAlmostEqual, (3.0, 5.0)),
(self.assertNotAlmostEquals, (3.0, 5.0)),
- (self.failUnless, (True,)),
(self.assert_, (True,)),
- (self.failUnlessRaises, (TypeError, lambda _: 3.14 + 'spam')),
- (self.failIf, (False,)),
- (self.assertSameElements, ([1, 1, 2, 3], [1, 2, 3])),
- (self.assertDictContainsSubset, (dict(a=1, b=2), dict(a=1, b=2, c=3))),
(self.assertRaisesRegexp, (KeyError, 'foo', lambda: {}['foo'])),
(self.assertRegexpMatches, ('bar', 'bar')),
)
@@ -1115,19 +1076,6 @@ test case
with self.assertWarns(DeprecationWarning):
meth(*args)
- def testDeprecatedFailMethods(self):
- """Test that the deprecated fail* methods get removed in 3.3"""
- if sys.version_info[:2] < (3, 3):
- return
- deprecated_names = [
- 'failIfEqual', 'failUnlessEqual', 'failUnlessAlmostEqual',
- 'failIfAlmostEqual', 'failUnless', 'failUnlessRaises', 'failIf',
- 'assertSameElements', 'assertDictContainsSubset',
- ]
- for deprecated_name in deprecated_names:
- with self.assertRaises(AttributeError):
- getattr(self, deprecated_name) # remove these in 3.3
-
def testDeepcopy(self):
# Issue: 5660
class TestableTest(unittest.TestCase):
diff --git a/Lib/unittest/test/test_runner.py b/Lib/unittest/test/test_runner.py
index 8e95410..1bd5183 100644
--- a/Lib/unittest/test/test_runner.py
+++ b/Lib/unittest/test/test_runner.py
@@ -257,19 +257,17 @@ class Test_TextTestRunner(unittest.TestCase):
return [b.splitlines() for b in p.communicate()]
opts = dict(stdout=subprocess.PIPE, stderr=subprocess.PIPE,
cwd=os.path.dirname(__file__))
- ae_msg = b'Please use assertEqual instead.'
- at_msg = b'Please use assertTrue instead.'
# no args -> all the warnings are printed, unittest warnings only once
p = subprocess.Popen([sys.executable, '_test_warnings.py'], **opts)
out, err = get_parse_out_err(p)
self.assertIn(b'OK', err)
# check that the total number of warnings in the output is correct
- self.assertEqual(len(out), 12)
+ self.assertEqual(len(out), 11)
# check that the numbers of the different kind of warnings is correct
for msg in [b'dw', b'iw', b'uw']:
self.assertEqual(out.count(msg), 3)
- for msg in [ae_msg, at_msg, b'rw']:
+ for msg in [b'rw']:
self.assertEqual(out.count(msg), 1)
args_list = (
@@ -294,11 +292,9 @@ class Test_TextTestRunner(unittest.TestCase):
**opts)
out, err = get_parse_out_err(p)
self.assertIn(b'OK', err)
- self.assertEqual(len(out), 14)
+ self.assertEqual(len(out), 13)
for msg in [b'dw', b'iw', b'uw', b'rw']:
self.assertEqual(out.count(msg), 3)
- for msg in [ae_msg, at_msg]:
- self.assertEqual(out.count(msg), 1)
def testStdErrLookedUpAtInstantiationTime(self):
# see issue 10786