Commit e61fd5b5 authored by Guido van Rossum's avatar Guido van Rossum

Patch by Christian Heimes to change self.assert_(x == y) into

self.assertEqual(x, y).  (Christian used self.failUnlessEqual(),
but the double negative makes it hard to grok, so I changed it.)
parent c9b9de17
...@@ -409,7 +409,7 @@ class StrTest(unittest.TestCase): ...@@ -409,7 +409,7 @@ class StrTest(unittest.TestCase):
def test_format(self, size): def test_format(self, size):
s = '-' * size s = '-' * size
sf = '%s' % (s,) sf = '%s' % (s,)
self.failUnless(s == sf) self.assertEqual(s, sf)
del sf del sf
sf = '..%s..' % (s,) sf = '..%s..' % (s,)
self.assertEquals(len(sf), len(s) + 4) self.assertEquals(len(sf), len(s) + 4)
...@@ -527,7 +527,7 @@ class StrTest(unittest.TestCase): ...@@ -527,7 +527,7 @@ class StrTest(unittest.TestCase):
def test_compare(self, size): def test_compare(self, size):
s1 = '-' * size s1 = '-' * size
s2 = '-' * size s2 = '-' * size
self.failUnless(s1 == s2) self.assertEqual(s1, s2)
del s2 del s2
s2 = s1 + 'a' s2 = s1 + 'a'
self.failIf(s1 == s2) self.failIf(s1 == s2)
...@@ -564,7 +564,7 @@ class TupleTest(unittest.TestCase): ...@@ -564,7 +564,7 @@ class TupleTest(unittest.TestCase):
def test_compare(self, size): def test_compare(self, size):
t1 = ('',) * size t1 = ('',) * size
t2 = ('',) * size t2 = ('',) * size
self.failUnless(t1 == t2) self.assertEqual(t1, t2)
del t2 del t2
t2 = ('',) * (size + 1) t2 = ('',) * (size + 1)
self.failIf(t1 == t2) self.failIf(t1 == t2)
...@@ -669,7 +669,7 @@ class ListTest(unittest.TestCase): ...@@ -669,7 +669,7 @@ class ListTest(unittest.TestCase):
def test_compare(self, size): def test_compare(self, size):
l1 = [''] * size l1 = [''] * size
l2 = [''] * size l2 = [''] * size
self.failUnless(l1 == l2) self.assertEqual(l1, l2)
del l2 del l2
l2 = [''] * (size + 1) l2 = [''] * (size + 1)
self.failIf(l1 == l2) self.failIf(l1 == l2)
......
...@@ -84,7 +84,7 @@ class BytesTest(unittest.TestCase): ...@@ -84,7 +84,7 @@ class BytesTest(unittest.TestCase):
b2 = bytes([1, 2, 3]) b2 = bytes([1, 2, 3])
b3 = bytes([1, 3]) b3 = bytes([1, 3])
self.failUnless(b1 == b2) self.assertEqual(b1, b2)
self.failUnless(b2 != b3) self.failUnless(b2 != b3)
self.failUnless(b1 <= b2) self.failUnless(b1 <= b2)
self.failUnless(b1 <= b3) self.failUnless(b1 <= b3)
......
...@@ -316,7 +316,7 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase): ...@@ -316,7 +316,7 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
def test_compare(self): def test_compare(self):
t1 = timedelta(2, 3, 4) t1 = timedelta(2, 3, 4)
t2 = timedelta(2, 3, 4) t2 = timedelta(2, 3, 4)
self.failUnless(t1 == t2) self.assertEqual(t1, t2)
self.failUnless(t1 <= t2) self.failUnless(t1 <= t2)
self.failUnless(t1 >= t2) self.failUnless(t1 >= t2)
self.failUnless(not t1 != t2) self.failUnless(not t1 != t2)
...@@ -913,7 +913,7 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase): ...@@ -913,7 +913,7 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase):
def test_compare(self): def test_compare(self):
t1 = self.theclass(2, 3, 4) t1 = self.theclass(2, 3, 4)
t2 = self.theclass(2, 3, 4) t2 = self.theclass(2, 3, 4)
self.failUnless(t1 == t2) self.assertEqual(t1, t2)
self.failUnless(t1 <= t2) self.failUnless(t1 <= t2)
self.failUnless(t1 >= t2) self.failUnless(t1 >= t2)
self.failUnless(not t1 != t2) self.failUnless(not t1 != t2)
...@@ -1375,7 +1375,7 @@ class TestDateTime(TestDate): ...@@ -1375,7 +1375,7 @@ class TestDateTime(TestDate):
args = [2000, 11, 29, 20, 58, 16, 999998] args = [2000, 11, 29, 20, 58, 16, 999998]
t1 = self.theclass(*args) t1 = self.theclass(*args)
t2 = self.theclass(*args) t2 = self.theclass(*args)
self.failUnless(t1 == t2) self.assertEqual(t1, t2)
self.failUnless(t1 <= t2) self.failUnless(t1 <= t2)
self.failUnless(t1 >= t2) self.failUnless(t1 >= t2)
self.failUnless(not t1 != t2) self.failUnless(not t1 != t2)
...@@ -1662,7 +1662,7 @@ class TestTime(HarmlessMixedComparison, unittest.TestCase): ...@@ -1662,7 +1662,7 @@ class TestTime(HarmlessMixedComparison, unittest.TestCase):
args = [1, 2, 3, 4] args = [1, 2, 3, 4]
t1 = self.theclass(*args) t1 = self.theclass(*args)
t2 = self.theclass(*args) t2 = self.theclass(*args)
self.failUnless(t1 == t2) self.assertEqual(t1, t2)
self.failUnless(t1 <= t2) self.failUnless(t1 <= t2)
self.failUnless(t1 >= t2) self.failUnless(t1 >= t2)
self.failUnless(not t1 != t2) self.failUnless(not t1 != t2)
...@@ -2343,8 +2343,8 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase): ...@@ -2343,8 +2343,8 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
self.failUnless(t1 != t2) self.failUnless(t1 != t2)
self.failUnless(t2 > t1) self.failUnless(t2 > t1)
self.failUnless(t1 == t1) self.assertEqual(t1, t1)
self.failUnless(t2 == t2) self.assertEqual(t2, t2)
# Equal afer adjustment. # Equal afer adjustment.
t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, "")) t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""))
......
...@@ -819,7 +819,7 @@ class DecimalUsabilityTest(unittest.TestCase): ...@@ -819,7 +819,7 @@ class DecimalUsabilityTest(unittest.TestCase):
self.failUnless(dc >= da) self.failUnless(dc >= da)
self.failUnless(da < dc) self.failUnless(da < dc)
self.failUnless(da <= dc) self.failUnless(da <= dc)
self.failUnless(da == db) self.assertEqual(da, db)
self.failUnless(da != dc) self.failUnless(da != dc)
self.failUnless(da <= db) self.failUnless(da <= db)
self.failUnless(da >= db) self.failUnless(da >= db)
...@@ -830,7 +830,7 @@ class DecimalUsabilityTest(unittest.TestCase): ...@@ -830,7 +830,7 @@ class DecimalUsabilityTest(unittest.TestCase):
#a Decimal and an int #a Decimal and an int
self.failUnless(dc > 23) self.failUnless(dc > 23)
self.failUnless(23 < dc) self.failUnless(23 < dc)
self.failUnless(dc == 45) self.assertEqual(dc, 45)
self.assertEqual(cmp(dc,23), 1) self.assertEqual(cmp(dc,23), 1)
self.assertEqual(cmp(23,dc), -1) self.assertEqual(cmp(23,dc), -1)
self.assertEqual(cmp(dc,45), 0) self.assertEqual(cmp(dc,45), 0)
......
...@@ -103,28 +103,28 @@ class DirCompareTestCase(unittest.TestCase): ...@@ -103,28 +103,28 @@ class DirCompareTestCase(unittest.TestCase):
self.assertEqual([d.left_list, d.right_list],[['file'], ['FiLe']]) self.assertEqual([d.left_list, d.right_list],[['file'], ['FiLe']])
else: else:
self.assertEqual([d.left_list, d.right_list],[['file'], ['file']]) self.assertEqual([d.left_list, d.right_list],[['file'], ['file']])
self.failUnless(d.common == ['file']) self.assertEqual(d.common, ['file'])
self.failUnless(d.left_only == d.right_only == []) self.failUnless(d.left_only == d.right_only == [])
self.failUnless(d.same_files == ['file']) self.assertEqual(d.same_files, ['file'])
self.failUnless(d.diff_files == []) self.assertEqual(d.diff_files, [])
# Check attributes for comparison of two different directories # Check attributes for comparison of two different directories
d = filecmp.dircmp(self.dir, self.dir_diff) d = filecmp.dircmp(self.dir, self.dir_diff)
self.failUnless(d.left_list == ['file']) self.assertEqual(d.left_list, ['file'])
self.failUnless(d.right_list == ['file', 'file2']) self.failUnless(d.right_list == ['file', 'file2'])
self.failUnless(d.common == ['file']) self.assertEqual(d.common, ['file'])
self.failUnless(d.left_only == []) self.assertEqual(d.left_only, [])
self.failUnless(d.right_only == ['file2']) self.assertEqual(d.right_only, ['file2'])
self.failUnless(d.same_files == ['file']) self.assertEqual(d.same_files, ['file'])
self.failUnless(d.diff_files == []) self.assertEqual(d.diff_files, [])
# Add different file2 # Add different file2
output = open(os.path.join(self.dir, 'file2'), 'w') output = open(os.path.join(self.dir, 'file2'), 'w')
output.write('Different contents.\n') output.write('Different contents.\n')
output.close() output.close()
d = filecmp.dircmp(self.dir, self.dir_diff) d = filecmp.dircmp(self.dir, self.dir_diff)
self.failUnless(d.same_files == ['file']) self.assertEqual(d.same_files, ['file'])
self.failUnless(d.diff_files == ['file2']) self.assertEqual(d.diff_files, ['file2'])
def test_main(): def test_main():
......
...@@ -108,7 +108,7 @@ class SanityTestCase(unittest.TestCase): ...@@ -108,7 +108,7 @@ class SanityTestCase(unittest.TestCase):
# NOTE: this whitebox test depends on the hmac class internals # NOTE: this whitebox test depends on the hmac class internals
import hashlib import hashlib
h = hmac.HMAC("key") h = hmac.HMAC("key")
self.failUnless(h.digest_cons == hashlib.md5) self.assertEqual(h.digest_cons, hashlib.md5)
def test_exercise_all_methods(self): def test_exercise_all_methods(self):
# Exercising all methods once. # Exercising all methods once.
...@@ -130,9 +130,9 @@ class CopyTestCase(unittest.TestCase): ...@@ -130,9 +130,9 @@ class CopyTestCase(unittest.TestCase):
h2 = h1.copy() h2 = h1.copy()
self.failUnless(h1.digest_cons == h2.digest_cons, self.failUnless(h1.digest_cons == h2.digest_cons,
"digest constructors don't match.") "digest constructors don't match.")
self.failUnless(type(h1.inner) == type(h2.inner), self.assertEqual(type(h1.inner), type(h2.inner),
"Types of inner don't match.") "Types of inner don't match.")
self.failUnless(type(h1.outer) == type(h2.outer), self.assertEqual(type(h1.outer), type(h2.outer),
"Types of outer don't match.") "Types of outer don't match.")
def test_realcopy(self): def test_realcopy(self):
...@@ -151,9 +151,9 @@ class CopyTestCase(unittest.TestCase): ...@@ -151,9 +151,9 @@ class CopyTestCase(unittest.TestCase):
h1 = hmac.HMAC("key") h1 = hmac.HMAC("key")
h1.update("some random text") h1.update("some random text")
h2 = h1.copy() h2 = h1.copy()
self.failUnless(h1.digest() == h2.digest(), self.assertEqual(h1.digest(), h2.digest(),
"Digest of copy doesn't match original digest.") "Digest of copy doesn't match original digest.")
self.failUnless(h1.hexdigest() == h2.hexdigest(), self.assertEqual(h1.hexdigest(), h2.hexdigest(),
"Hexdigest of copy doesn't match original hexdigest.") "Hexdigest of copy doesn't match original hexdigest.")
def test_main(): def test_main():
......
...@@ -77,7 +77,7 @@ class HotShotTestCase(unittest.TestCase): ...@@ -77,7 +77,7 @@ class HotShotTestCase(unittest.TestCase):
log = self.get_logreader() log = self.get_logreader()
info = log._info info = log._info
list(log) list(log)
self.failUnless(info["test-key"] == ["test-value"]) self.assertEqual(info["test-key"], ["test-value"])
def test_line_numbers(self): def test_line_numbers(self):
def f(): def f():
......
...@@ -6,7 +6,7 @@ import unittest ...@@ -6,7 +6,7 @@ import unittest
class MacPathTestCase(unittest.TestCase): class MacPathTestCase(unittest.TestCase):
def test_abspath(self): def test_abspath(self):
self.assert_(macpath.abspath("xx:yy") == "xx:yy") self.assertEqual(macpath.abspath("xx:yy"), "xx:yy")
def test_isabs(self): def test_isabs(self):
isabs = macpath.isabs isabs = macpath.isabs
......
This diff is collapsed.
...@@ -67,14 +67,14 @@ class MaildirTestCase(unittest.TestCase): ...@@ -67,14 +67,14 @@ class MaildirTestCase(unittest.TestCase):
"""Test an empty maildir mailbox""" """Test an empty maildir mailbox"""
# Test for regression on bug #117490: # Test for regression on bug #117490:
self.mbox = mailbox.Maildir(test_support.TESTFN) self.mbox = mailbox.Maildir(test_support.TESTFN)
self.assert_(len(self.mbox) == 0) self.assertEqual(len(self.mbox), 0)
self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None)
self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None)
def test_nonempty_maildir_cur(self): def test_nonempty_maildir_cur(self):
self.createMessage("cur") self.createMessage("cur")
self.mbox = mailbox.Maildir(test_support.TESTFN) self.mbox = mailbox.Maildir(test_support.TESTFN)
self.assert_(len(self.mbox) == 1) self.assertEqual(len(self.mbox), 1)
self.assert_(self.mbox.next() is not None) self.assert_(self.mbox.next() is not None)
self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None)
self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None)
...@@ -82,7 +82,7 @@ class MaildirTestCase(unittest.TestCase): ...@@ -82,7 +82,7 @@ class MaildirTestCase(unittest.TestCase):
def test_nonempty_maildir_new(self): def test_nonempty_maildir_new(self):
self.createMessage("new") self.createMessage("new")
self.mbox = mailbox.Maildir(test_support.TESTFN) self.mbox = mailbox.Maildir(test_support.TESTFN)
self.assert_(len(self.mbox) == 1) self.assertEqual(len(self.mbox), 1)
self.assert_(self.mbox.next() is not None) self.assert_(self.mbox.next() is not None)
self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None)
self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None)
...@@ -91,7 +91,7 @@ class MaildirTestCase(unittest.TestCase): ...@@ -91,7 +91,7 @@ class MaildirTestCase(unittest.TestCase):
self.createMessage("cur") self.createMessage("cur")
self.createMessage("new") self.createMessage("new")
self.mbox = mailbox.Maildir(test_support.TESTFN) self.mbox = mailbox.Maildir(test_support.TESTFN)
self.assert_(len(self.mbox) == 2) self.assertEqual(len(self.mbox), 2)
self.assert_(self.mbox.next() is not None) self.assert_(self.mbox.next() is not None)
self.assert_(self.mbox.next() is not None) self.assert_(self.mbox.next() is not None)
self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None)
...@@ -139,7 +139,7 @@ body4 ...@@ -139,7 +139,7 @@ body4
""") """)
f.close() f.close()
box = mailbox.UnixMailbox(open(self._path, 'r')) box = mailbox.UnixMailbox(open(self._path, 'r'))
self.assert_(len(list(iter(box))) == 4) self.assertEqual(len(list(iter(box))), 4)
# XXX We still need more tests! # XXX We still need more tests!
......
...@@ -102,8 +102,8 @@ class OperatorTestCase(unittest.TestCase): ...@@ -102,8 +102,8 @@ class OperatorTestCase(unittest.TestCase):
def test_abs(self): def test_abs(self):
self.failUnlessRaises(TypeError, operator.abs) self.failUnlessRaises(TypeError, operator.abs)
self.failUnlessRaises(TypeError, operator.abs, None) self.failUnlessRaises(TypeError, operator.abs, None)
self.failUnless(operator.abs(-1) == 1) self.assertEqual(operator.abs(-1), 1)
self.failUnless(operator.abs(1) == 1) self.assertEqual(operator.abs(1), 1)
def test_add(self): def test_add(self):
self.failUnlessRaises(TypeError, operator.add) self.failUnlessRaises(TypeError, operator.add)
...@@ -144,7 +144,7 @@ class OperatorTestCase(unittest.TestCase): ...@@ -144,7 +144,7 @@ class OperatorTestCase(unittest.TestCase):
self.failUnless(operator.delslice(a, 2, 8) is None) self.failUnless(operator.delslice(a, 2, 8) is None)
self.assert_(a == [0, 1, 8, 9]) self.assert_(a == [0, 1, 8, 9])
operator.delslice(a, 0, test_support.MAX_Py_ssize_t) operator.delslice(a, 0, test_support.MAX_Py_ssize_t)
self.assert_(a == []) self.assertEqual(a, [])
def test_floordiv(self): def test_floordiv(self):
self.failUnlessRaises(TypeError, operator.floordiv, 5) self.failUnlessRaises(TypeError, operator.floordiv, 5)
...@@ -168,7 +168,7 @@ class OperatorTestCase(unittest.TestCase): ...@@ -168,7 +168,7 @@ class OperatorTestCase(unittest.TestCase):
self.failUnlessRaises(TypeError, operator.getslice, a, None, None) self.failUnlessRaises(TypeError, operator.getslice, a, None, None)
self.failUnless(operator.getslice(a, 4, 6) == [4, 5]) self.failUnless(operator.getslice(a, 4, 6) == [4, 5])
b = operator.getslice(a, 0, test_support.MAX_Py_ssize_t) b = operator.getslice(a, 0, test_support.MAX_Py_ssize_t)
self.assert_(b == a) self.assertEqual(b, a)
def test_indexOf(self): def test_indexOf(self):
self.failUnlessRaises(TypeError, operator.indexOf) self.failUnlessRaises(TypeError, operator.indexOf)
...@@ -179,7 +179,7 @@ class OperatorTestCase(unittest.TestCase): ...@@ -179,7 +179,7 @@ class OperatorTestCase(unittest.TestCase):
def test_invert(self): def test_invert(self):
self.failUnlessRaises(TypeError, operator.invert) self.failUnlessRaises(TypeError, operator.invert)
self.failUnlessRaises(TypeError, operator.invert, None) self.failUnlessRaises(TypeError, operator.invert, None)
self.failUnless(operator.inv(4) == -5) self.assertEqual(operator.inv(4), -5)
def test_isMappingType(self): def test_isMappingType(self):
self.failUnlessRaises(TypeError, operator.isMappingType) self.failUnlessRaises(TypeError, operator.isMappingType)
...@@ -226,10 +226,10 @@ class OperatorTestCase(unittest.TestCase): ...@@ -226,10 +226,10 @@ class OperatorTestCase(unittest.TestCase):
def test_neg(self): def test_neg(self):
self.failUnlessRaises(TypeError, operator.neg) self.failUnlessRaises(TypeError, operator.neg)
self.failUnlessRaises(TypeError, operator.neg, None) self.failUnlessRaises(TypeError, operator.neg, None)
self.failUnless(operator.neg(5) == -5) self.assertEqual(operator.neg(5), -5)
self.failUnless(operator.neg(-5) == 5) self.assertEqual(operator.neg(-5), 5)
self.failUnless(operator.neg(0) == 0) self.assertEqual(operator.neg(0), 0)
self.failUnless(operator.neg(-0) == 0) self.assertEqual(operator.neg(-0), 0)
def test_bitwise_or(self): def test_bitwise_or(self):
self.failUnlessRaises(TypeError, operator.or_) self.failUnlessRaises(TypeError, operator.or_)
...@@ -239,16 +239,16 @@ class OperatorTestCase(unittest.TestCase): ...@@ -239,16 +239,16 @@ class OperatorTestCase(unittest.TestCase):
def test_pos(self): def test_pos(self):
self.failUnlessRaises(TypeError, operator.pos) self.failUnlessRaises(TypeError, operator.pos)
self.failUnlessRaises(TypeError, operator.pos, None) self.failUnlessRaises(TypeError, operator.pos, None)
self.failUnless(operator.pos(5) == 5) self.assertEqual(operator.pos(5), 5)
self.failUnless(operator.pos(-5) == -5) self.assertEqual(operator.pos(-5), -5)
self.failUnless(operator.pos(0) == 0) self.assertEqual(operator.pos(0), 0)
self.failUnless(operator.pos(-0) == 0) self.assertEqual(operator.pos(-0), 0)
def test_pow(self): def test_pow(self):
self.failUnlessRaises(TypeError, operator.pow) self.failUnlessRaises(TypeError, operator.pow)
self.failUnlessRaises(TypeError, operator.pow, None, None) self.failUnlessRaises(TypeError, operator.pow, None, None)
self.failUnless(operator.pow(3,5) == 3**5) self.assertEqual(operator.pow(3,5), 3**5)
self.failUnless(operator.__pow__(3,5) == 3**5) self.assertEqual(operator.__pow__(3,5), 3**5)
self.assertRaises(TypeError, operator.pow, 1) self.assertRaises(TypeError, operator.pow, 1)
self.assertRaises(TypeError, operator.pow, 1, 2, 3) self.assertRaises(TypeError, operator.pow, 1, 2, 3)
...@@ -305,7 +305,7 @@ class OperatorTestCase(unittest.TestCase): ...@@ -305,7 +305,7 @@ class OperatorTestCase(unittest.TestCase):
self.failUnless(operator.setslice(a, 1, 3, [2, 1]) is None) self.failUnless(operator.setslice(a, 1, 3, [2, 1]) is None)
self.assert_(a == [0, 2, 1, 3]) self.assert_(a == [0, 2, 1, 3])
operator.setslice(a, 0, test_support.MAX_Py_ssize_t, []) operator.setslice(a, 0, test_support.MAX_Py_ssize_t, [])
self.assert_(a == []) self.assertEqual(a, [])
def test_sub(self): def test_sub(self):
self.failUnlessRaises(TypeError, operator.sub) self.failUnlessRaises(TypeError, operator.sub)
......
...@@ -53,7 +53,7 @@ class TemporaryFileTests(unittest.TestCase): ...@@ -53,7 +53,7 @@ class TemporaryFileTests(unittest.TestCase):
self.check_tempfile(name) self.check_tempfile(name)
name = os.tempnam(test_support.TESTFN, "pfx") name = os.tempnam(test_support.TESTFN, "pfx")
self.assert_(os.path.basename(name)[:3] == "pfx") self.assertEqual(os.path.basename(name)[:3], "pfx")
self.check_tempfile(name) self.check_tempfile(name)
def test_tmpfile(self): def test_tmpfile(self):
......
...@@ -130,17 +130,17 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''') ...@@ -130,17 +130,17 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
@withpythonimplementation @withpythonimplementation
def test_encodestring(self): def test_encodestring(self):
for p, e in self.STRINGS: for p, e in self.STRINGS:
self.assert_(quopri.encodestring(p) == e) self.assertEqual(quopri.encodestring(p), e)
@withpythonimplementation @withpythonimplementation
def test_decodestring(self): def test_decodestring(self):
for p, e in self.STRINGS: for p, e in self.STRINGS:
self.assert_(quopri.decodestring(e) == p) self.assertEqual(quopri.decodestring(e), p)
@withpythonimplementation @withpythonimplementation
def test_idempotent_string(self): def test_idempotent_string(self):
for p, e in self.STRINGS: for p, e in self.STRINGS:
self.assert_(quopri.decodestring(quopri.encodestring(e)) == e) self.assertEqual(quopri.decodestring(quopri.encodestring(e)), e)
@withpythonimplementation @withpythonimplementation
def test_encode(self): def test_encode(self):
...@@ -148,7 +148,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''') ...@@ -148,7 +148,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
infp = cStringIO.StringIO(p) infp = cStringIO.StringIO(p)
outfp = cStringIO.StringIO() outfp = cStringIO.StringIO()
quopri.encode(infp, outfp, quotetabs=False) quopri.encode(infp, outfp, quotetabs=False)
self.assert_(outfp.getvalue() == e) self.assertEqual(outfp.getvalue(), e)
@withpythonimplementation @withpythonimplementation
def test_decode(self): def test_decode(self):
...@@ -156,13 +156,13 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''') ...@@ -156,13 +156,13 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
infp = cStringIO.StringIO(e) infp = cStringIO.StringIO(e)
outfp = cStringIO.StringIO() outfp = cStringIO.StringIO()
quopri.decode(infp, outfp) quopri.decode(infp, outfp)
self.assert_(outfp.getvalue() == p) self.assertEqual(outfp.getvalue(), p)
@withpythonimplementation @withpythonimplementation
def test_embedded_ws(self): def test_embedded_ws(self):
for p, e in self.ESTRINGS: for p, e in self.ESTRINGS:
self.assert_(quopri.encodestring(p, quotetabs=True) == e) self.assert_(quopri.encodestring(p, quotetabs=True) == e)
self.assert_(quopri.decodestring(e) == p) self.assertEqual(quopri.decodestring(e), p)
@withpythonimplementation @withpythonimplementation
def test_encode_header(self): def test_encode_header(self):
...@@ -182,14 +182,14 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''') ...@@ -182,14 +182,14 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
# On Windows, Python will output the result to stdout using # On Windows, Python will output the result to stdout using
# CRLF, as the mode of stdout is text mode. To compare this # CRLF, as the mode of stdout is text mode. To compare this
# with the expected result, we need to do a line-by-line comparison. # with the expected result, we need to do a line-by-line comparison.
self.assert_(cout.splitlines() == e.splitlines()) self.assertEqual(cout.splitlines(), e.splitlines())
def test_scriptdecode(self): def test_scriptdecode(self):
(p, e) = self.STRINGS[-1] (p, e) = self.STRINGS[-1]
process = subprocess.Popen([sys.executable, "-mquopri", "-d"], process = subprocess.Popen([sys.executable, "-mquopri", "-d"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE) stdin=subprocess.PIPE, stdout=subprocess.PIPE)
cout, cerr = process.communicate(e) cout, cerr = process.communicate(e)
self.assert_(cout.splitlines() == p.splitlines()) self.assertEqual(cout.splitlines(), p.splitlines())
def test_main(): def test_main():
test_support.run_unittest(QuopriTestCase) test_support.run_unittest(QuopriTestCase)
......
...@@ -274,7 +274,7 @@ class SystemRandom_TestBasicOps(TestBasicOps): ...@@ -274,7 +274,7 @@ class SystemRandom_TestBasicOps(TestBasicOps):
numbits = i+1 numbits = i+1
k = int(1.00001 + _log(n, 2)) k = int(1.00001 + _log(n, 2))
self.assertEqual(k, numbits) self.assertEqual(k, numbits)
self.assert_(n == 2**(k-1)) self.assertEqual(n, 2**(k-1))
n += n - 1 # check 1 below the next power of two n += n - 1 # check 1 below the next power of two
k = int(1.00001 + _log(n, 2)) k = int(1.00001 + _log(n, 2))
...@@ -430,7 +430,7 @@ class MersenneTwister_TestBasicOps(TestBasicOps): ...@@ -430,7 +430,7 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
numbits = i+1 numbits = i+1
k = int(1.00001 + _log(n, 2)) k = int(1.00001 + _log(n, 2))
self.assertEqual(k, numbits) self.assertEqual(k, numbits)
self.assert_(n == 2**(k-1)) self.assertEqual(n, 2**(k-1))
n += n - 1 # check 1 below the next power of two n += n - 1 # check 1 below the next power of two
k = int(1.00001 + _log(n, 2)) k = int(1.00001 + _log(n, 2))
......
...@@ -29,10 +29,10 @@ class MessageTestCase(unittest.TestCase): ...@@ -29,10 +29,10 @@ class MessageTestCase(unittest.TestCase):
self.assert_(msg.setdefault("New-Header", "New-Value") == "New-Value") self.assert_(msg.setdefault("New-Header", "New-Value") == "New-Value")
self.assert_(msg.setdefault("New-Header", "Different-Value") self.assert_(msg.setdefault("New-Header", "Different-Value")
== "New-Value") == "New-Value")
self.assert_(msg["new-header"] == "New-Value") self.assertEqual(msg["new-header"], "New-Value")
self.assert_(msg.setdefault("Another-Header") == "") self.assertEqual(msg.setdefault("Another-Header"), "")
self.assert_(msg["another-header"] == "") self.assertEqual(msg["another-header"], "")
def check(self, msg, results): def check(self, msg, results):
"""Check addresses and the date.""" """Check addresses and the date."""
......
...@@ -272,9 +272,9 @@ class DictTest(unittest.TestCase): ...@@ -272,9 +272,9 @@ class DictTest(unittest.TestCase):
imag1b[k] = v imag1b[k] = v
imag2 = imag1b.copy() imag2 = imag1b.copy()
imag2[k] = v + 1.0 imag2[k] = v + 1.0
self.assert_(imag1a == imag1a) self.assertEqual(imag1a, imag1a)
self.assert_(imag1a == imag1b) self.assertEqual(imag1a, imag1b)
self.assert_(imag2 == imag2) self.assertEqual(imag2, imag2)
self.assert_(imag1a != imag2) self.assert_(imag1a != imag2)
for opname in ("lt", "le", "gt", "ge"): for opname in ("lt", "le", "gt", "ge"):
for op in opmap[opname]: for op in opmap[opname]:
......
...@@ -45,8 +45,8 @@ class RunModuleCodeTest(unittest.TestCase): ...@@ -45,8 +45,8 @@ class RunModuleCodeTest(unittest.TestCase):
True) True)
self.failUnless("result" not in d1) self.failUnless("result" not in d1)
self.failUnless(d2["initial"] is initial) self.failUnless(d2["initial"] is initial)
self.failUnless(d2["result"] == self.expected_result) self.assertEqual(d2["result"], self.expected_result)
self.failUnless(d2["nested"]["x"] == 1) self.assertEqual(d2["nested"]["x"], 1)
self.failUnless(d2["__name__"] is name) self.failUnless(d2["__name__"] is name)
self.failUnless(d2["run_name"] is name) self.failUnless(d2["run_name"] is name)
self.failUnless(d2["__file__"] is file) self.failUnless(d2["__file__"] is file)
...@@ -58,7 +58,7 @@ class RunModuleCodeTest(unittest.TestCase): ...@@ -58,7 +58,7 @@ class RunModuleCodeTest(unittest.TestCase):
def test_run_module_code_defaults(self): def test_run_module_code_defaults(self):
saved_argv0 = sys.argv[0] saved_argv0 = sys.argv[0]
d = _run_module_code(self.test_source) d = _run_module_code(self.test_source)
self.failUnless(d["result"] == self.expected_result) self.assertEqual(d["result"], self.expected_result)
self.failUnless(d["__name__"] is None) self.failUnless(d["__name__"] is None)
self.failUnless(d["__file__"] is None) self.failUnless(d["__file__"] is None)
self.failUnless(d["__loader__"] is None) self.failUnless(d["__loader__"] is None)
...@@ -146,13 +146,13 @@ class RunModuleTest(unittest.TestCase): ...@@ -146,13 +146,13 @@ class RunModuleTest(unittest.TestCase):
try: try:
if verbose: print("Running from source:", mod_name) if verbose: print("Running from source:", mod_name)
d1 = run_module(mod_name) # Read from source d1 = run_module(mod_name) # Read from source
self.failUnless(d1["x"] == 1) self.assertEqual(d1["x"], 1)
del d1 # Ensure __loader__ entry doesn't keep file open del d1 # Ensure __loader__ entry doesn't keep file open
__import__(mod_name) __import__(mod_name)
os.remove(mod_fname) os.remove(mod_fname)
if verbose: print("Running from compiled:", mod_name) if verbose: print("Running from compiled:", mod_name)
d2 = run_module(mod_name) # Read from bytecode d2 = run_module(mod_name) # Read from bytecode
self.failUnless(d2["x"] == 1) self.assertEqual(d2["x"], 1)
del d2 # Ensure __loader__ entry doesn't keep file open del d2 # Ensure __loader__ entry doesn't keep file open
finally: finally:
self._del_pkg(pkg_dir, depth, mod_name) self._del_pkg(pkg_dir, depth, mod_name)
......
...@@ -301,7 +301,7 @@ class SysModuleTest(unittest.TestCase): ...@@ -301,7 +301,7 @@ class SysModuleTest(unittest.TestCase):
def test_43581(self): def test_43581(self):
# Can't use sys.stdout, as this is a cStringIO object when # Can't use sys.stdout, as this is a cStringIO object when
# the test runs under regrtest. # the test runs under regrtest.
self.assert_(sys.__stdout__.encoding == sys.__stderr__.encoding) self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding)
def test_intern(self): def test_intern(self):
self.assertRaises(TypeError, sys.intern) self.assertRaises(TypeError, sys.intern)
......
...@@ -98,27 +98,27 @@ class UstarReadTest(ReadTest): ...@@ -98,27 +98,27 @@ class UstarReadTest(ReadTest):
text = fobj.read() text = fobj.read()
fobj.seek(0) fobj.seek(0)
self.assert_(0 == fobj.tell(), self.assertEqual(0, fobj.tell(),
"seek() to file's start failed") "seek() to file's start failed")
fobj.seek(2048, 0) fobj.seek(2048, 0)
self.assert_(2048 == fobj.tell(), self.assertEqual(2048, fobj.tell(),
"seek() to absolute position failed") "seek() to absolute position failed")
fobj.seek(-1024, 1) fobj.seek(-1024, 1)
self.assert_(1024 == fobj.tell(), self.assertEqual(1024, fobj.tell(),
"seek() to negative relative position failed") "seek() to negative relative position failed")
fobj.seek(1024, 1) fobj.seek(1024, 1)
self.assert_(2048 == fobj.tell(), self.assertEqual(2048, fobj.tell(),
"seek() to positive relative position failed") "seek() to positive relative position failed")
s = fobj.read(10) s = fobj.read(10)
self.assert_(s == data[2048:2058], self.assert_(s == data[2048:2058],
"read() after seek failed") "read() after seek failed")
fobj.seek(0, 2) fobj.seek(0, 2)
self.assert_(tarinfo.size == fobj.tell(), self.assertEqual(tarinfo.size, fobj.tell(),
"seek() to file's end failed") "seek() to file's end failed")
self.assert_(fobj.read() == "", self.assert_(fobj.read() == "",
"read() at file's end did not return empty string") "read() at file's end did not return empty string")
fobj.seek(-tarinfo.size, 2) fobj.seek(-tarinfo.size, 2)
self.assert_(0 == fobj.tell(), self.assertEqual(0, fobj.tell(),
"relative seek() to file's start failed") "relative seek() to file's start failed")
fobj.seek(512) fobj.seek(512)
s1 = fobj.readlines() s1 = fobj.readlines()
...@@ -127,14 +127,14 @@ class UstarReadTest(ReadTest): ...@@ -127,14 +127,14 @@ class UstarReadTest(ReadTest):
self.assert_(s1 == s2, self.assert_(s1 == s2,
"readlines() after seek failed") "readlines() after seek failed")
fobj.seek(0) fobj.seek(0)
self.assert_(len(fobj.readline()) == fobj.tell(), self.assertEqual(len(fobj.readline()), fobj.tell(),
"tell() after readline() failed") "tell() after readline() failed")
fobj.seek(512) fobj.seek(512)
self.assert_(len(fobj.readline()) + 512 == fobj.tell(), self.assert_(len(fobj.readline()) + 512 == fobj.tell(),
"tell() after seek() and readline() failed") "tell() after seek() and readline() failed")
fobj.seek(0) fobj.seek(0)
line = fobj.readline() line = fobj.readline()
self.assert_(fobj.read() == data[len(line):], self.assertEqual(fobj.read(), data[len(line):],
"read() after readline() failed") "read() after readline() failed")
fobj.close() fobj.close()
...@@ -235,7 +235,7 @@ class StreamReadTest(ReadTest): ...@@ -235,7 +235,7 @@ class StreamReadTest(ReadTest):
if v1 is None: if v1 is None:
continue continue
self.assert_(v2 is not None, "stream.extractfile() failed") self.assert_(v2 is not None, "stream.extractfile() failed")
self.assert_(v1.read() == v2.read(), "stream extraction failed") self.assertEqual(v1.read(), v2.read(), "stream extraction failed")
tar1.close() tar1.close()
...@@ -417,7 +417,7 @@ class GNUReadTest(LongnameTest): ...@@ -417,7 +417,7 @@ class GNUReadTest(LongnameTest):
fobj1 = self.tar.extractfile(tarinfo1) fobj1 = self.tar.extractfile(tarinfo1)
tarinfo2 = self.tar.getmember("gnu/sparse") tarinfo2 = self.tar.getmember("gnu/sparse")
fobj2 = self.tar.extractfile(tarinfo2) fobj2 = self.tar.extractfile(tarinfo2)
self.assert_(fobj1.read() == fobj2.read(), self.assertEqual(fobj1.read(), fobj2.read(),
"sparse file extraction failed") "sparse file extraction failed")
......
...@@ -30,10 +30,10 @@ class TracebackCases(unittest.TestCase): ...@@ -30,10 +30,10 @@ class TracebackCases(unittest.TestCase):
def test_caret(self): def test_caret(self):
err = self.get_exception_format(self.syntax_error_with_caret, err = self.get_exception_format(self.syntax_error_with_caret,
SyntaxError) SyntaxError)
self.assert_(len(err) == 4) self.assertEqual(len(err), 4)
self.assert_(err[1].strip() == "return x!") self.assert_(err[1].strip() == "return x!")
self.assert_("^" in err[2]) # third line has caret self.assert_("^" in err[2]) # third line has caret
self.assert_(err[1].find("!") == err[2].find("^")) # in the right place self.assertEqual(err[1].find("!"), err[2].find("^")) # in the right place
def test_nocaret(self): def test_nocaret(self):
if is_jython: if is_jython:
...@@ -41,16 +41,16 @@ class TracebackCases(unittest.TestCase): ...@@ -41,16 +41,16 @@ class TracebackCases(unittest.TestCase):
return return
err = self.get_exception_format(self.syntax_error_without_caret, err = self.get_exception_format(self.syntax_error_without_caret,
SyntaxError) SyntaxError)
self.assert_(len(err) == 3) self.assertEqual(len(err), 3)
self.assert_(err[1].strip() == "[x for x in x] = x") self.assert_(err[1].strip() == "[x for x in x] = x")
def test_bad_indentation(self): def test_bad_indentation(self):
err = self.get_exception_format(self.syntax_error_bad_indentation, err = self.get_exception_format(self.syntax_error_bad_indentation,
IndentationError) IndentationError)
self.assert_(len(err) == 4) self.assertEqual(len(err), 4)
self.assert_(err[1].strip() == "print(2)") self.assertEqual(err[1].strip(), "print(2)")
self.assert_("^" in err[2]) self.assert_("^" in err[2])
self.assert_(err[1].find(")") == err[2].find("^")) self.assertEqual(err[1].find(")"), err[2].find("^"))
def test_members(self): def test_members(self):
# Covers Python/structmember.c::listmembers() # Covers Python/structmember.c::listmembers()
......
...@@ -7,24 +7,24 @@ class UnaryOpTestCase(unittest.TestCase): ...@@ -7,24 +7,24 @@ class UnaryOpTestCase(unittest.TestCase):
def test_negative(self): def test_negative(self):
self.assert_(-2 == 0 - 2) self.assert_(-2 == 0 - 2)
self.assert_(-0 == 0) self.assertEqual(-0, 0)
self.assert_(--2 == 2) self.assertEqual(--2, 2)
self.assert_(-2 == 0 - 2) self.assert_(-2 == 0 - 2)
self.assert_(-2.0 == 0 - 2.0) self.assert_(-2.0 == 0 - 2.0)
self.assert_(-2j == 0 - 2j) self.assert_(-2j == 0 - 2j)
def test_positive(self): def test_positive(self):
self.assert_(+2 == 2) self.assertEqual(+2, 2)
self.assert_(+0 == 0) self.assertEqual(+0, 0)
self.assert_(++2 == 2) self.assertEqual(++2, 2)
self.assert_(+2 == 2) self.assertEqual(+2, 2)
self.assert_(+2.0 == 2.0) self.assertEqual(+2.0, 2.0)
self.assert_(+2j == 2j) self.assertEqual(+2j, 2j)
def test_invert(self): def test_invert(self):
self.assert_(-2 == 0 - 2) self.assert_(-2 == 0 - 2)
self.assert_(-0 == 0) self.assertEqual(-0, 0)
self.assert_(--2 == 2) self.assertEqual(--2, 2)
self.assert_(-2 == 0 - 2) self.assert_(-2 == 0 - 2)
def test_no_overflow(self): def test_no_overflow(self):
......
...@@ -1113,7 +1113,7 @@ class Test_TestLoader(TestCase): ...@@ -1113,7 +1113,7 @@ class Test_TestLoader(TestCase):
# "The default value is 'test'" # "The default value is 'test'"
def test_testMethodPrefix__default_value(self): def test_testMethodPrefix__default_value(self):
loader = unittest.TestLoader() loader = unittest.TestLoader()
self.failUnless(loader.testMethodPrefix == 'test') self.assertEqual(loader.testMethodPrefix, 'test')
################################################################ ################################################################
### /Tests for TestLoader.testMethodPrefix ### /Tests for TestLoader.testMethodPrefix
......
...@@ -107,7 +107,7 @@ class ReferencesTestCase(TestBase): ...@@ -107,7 +107,7 @@ class ReferencesTestCase(TestBase):
self.assertRaises(ReferenceError, check, ref1) self.assertRaises(ReferenceError, check, ref1)
self.assertRaises(ReferenceError, check, ref2) self.assertRaises(ReferenceError, check, ref2)
self.assertRaises(ReferenceError, bool, weakref.proxy(C())) self.assertRaises(ReferenceError, bool, weakref.proxy(C()))
self.assert_(self.cbcalled == 2) self.assertEqual(self.cbcalled, 2)
def check_basic_ref(self, factory): def check_basic_ref(self, factory):
o = factory() o = factory()
...@@ -769,10 +769,10 @@ class MappingTestCase(TestBase): ...@@ -769,10 +769,10 @@ class MappingTestCase(TestBase):
"wrong object returned by weak dict!") "wrong object returned by weak dict!")
items1 = dict.items() items1 = dict.items()
items2 = dict.copy().items() items2 = dict.copy().items()
self.assert_(set(items1) == set(items2), self.assertEqual(set(items1), set(items2),
"cloning of weak-keyed dictionary did not work!") "cloning of weak-keyed dictionary did not work!")
del items1, items2 del items1, items2
self.assert_(len(dict) == self.COUNT) self.assertEqual(len(dict), self.COUNT)
del objects[0] del objects[0]
self.assert_(len(dict) == (self.COUNT - 1), self.assert_(len(dict) == (self.COUNT - 1),
"deleting object did not cause dictionary update") "deleting object did not cause dictionary update")
...@@ -865,13 +865,13 @@ class MappingTestCase(TestBase): ...@@ -865,13 +865,13 @@ class MappingTestCase(TestBase):
def test_make_weak_keyed_dict_from_dict(self): def test_make_weak_keyed_dict_from_dict(self):
o = Object(3) o = Object(3)
dict = weakref.WeakKeyDictionary({o:364}) dict = weakref.WeakKeyDictionary({o:364})
self.assert_(dict[o] == 364) self.assertEqual(dict[o], 364)
def test_make_weak_keyed_dict_from_weak_keyed_dict(self): def test_make_weak_keyed_dict_from_weak_keyed_dict(self):
o = Object(3) o = Object(3)
dict = weakref.WeakKeyDictionary({o:364}) dict = weakref.WeakKeyDictionary({o:364})
dict2 = weakref.WeakKeyDictionary(dict) dict2 = weakref.WeakKeyDictionary(dict)
self.assert_(dict[o] == 364) self.assertEqual(dict[o], 364)
def make_weak_keyed_dict(self): def make_weak_keyed_dict(self):
dict = weakref.WeakKeyDictionary() dict = weakref.WeakKeyDictionary()
...@@ -891,15 +891,15 @@ class MappingTestCase(TestBase): ...@@ -891,15 +891,15 @@ class MappingTestCase(TestBase):
weakdict = klass() weakdict = klass()
weakdict[key1] = value1 weakdict[key1] = value1
weakdict[key2] = value2 weakdict[key2] = value2
self.assert_(len(weakdict) == 2) self.assertEqual(len(weakdict), 2)
k, v = weakdict.popitem() k, v = weakdict.popitem()
self.assert_(len(weakdict) == 1) self.assertEqual(len(weakdict), 1)
if k is key1: if k is key1:
self.assert_(v is value1) self.assert_(v is value1)
else: else:
self.assert_(v is value2) self.assert_(v is value2)
k, v = weakdict.popitem() k, v = weakdict.popitem()
self.assert_(len(weakdict) == 0) self.assertEqual(len(weakdict), 0)
if k is key1: if k is key1:
self.assert_(v is value1) self.assert_(v is value1)
else: else:
...@@ -945,7 +945,7 @@ class MappingTestCase(TestBase): ...@@ -945,7 +945,7 @@ class MappingTestCase(TestBase):
# #
weakdict = klass() weakdict = klass()
weakdict.update(dict) weakdict.update(dict)
self.assert_(len(weakdict) == len(dict)) self.assertEqual(len(weakdict), len(dict))
for k in weakdict.keys(): for k in weakdict.keys():
self.assert_(k in dict, self.assert_(k in dict,
"mysterious new key appeared in weak dict") "mysterious new key appeared in weak dict")
...@@ -973,10 +973,10 @@ class MappingTestCase(TestBase): ...@@ -973,10 +973,10 @@ class MappingTestCase(TestBase):
o2 = Object('2') o2 = Object('2')
d[o1] = 'something' d[o1] = 'something'
d[o2] = 'something' d[o2] = 'something'
self.assert_(len(d) == 2) self.assertEqual(len(d), 2)
del d[o1] del d[o1]
self.assert_(len(d) == 1) self.assertEqual(len(d), 1)
self.assert_(d.keys() == [o2]) self.assertEqual(d.keys(), [o2])
def test_weak_valued_delitem(self): def test_weak_valued_delitem(self):
d = weakref.WeakValueDictionary() d = weakref.WeakValueDictionary()
...@@ -984,9 +984,9 @@ class MappingTestCase(TestBase): ...@@ -984,9 +984,9 @@ class MappingTestCase(TestBase):
o2 = Object('2') o2 = Object('2')
d['something'] = o1 d['something'] = o1
d['something else'] = o2 d['something else'] = o2
self.assert_(len(d) == 2) self.assertEqual(len(d), 2)
del d['something'] del d['something']
self.assert_(len(d) == 1) self.assertEqual(len(d), 1)
self.assert_(d.items() == [('something else', o2)]) self.assert_(d.items() == [('something else', o2)])
def test_weak_keyed_bad_delitem(self): def test_weak_keyed_bad_delitem(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment