summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bytes.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-06-30 23:06:06 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-06-30 23:06:06 (GMT)
commitc9c0f201fed21efcf669dbbf5f923eaf0eeb1db9 (patch)
tree6350dab0b481e6de307dc4e043c6230f463a9ca7 /Lib/test/test_bytes.py
parent98d23f2e065713ccfbc07d9a0b65f737a212bfb5 (diff)
downloadcpython-c9c0f201fed21efcf669dbbf5f923eaf0eeb1db9.zip
cpython-c9c0f201fed21efcf669dbbf5f923eaf0eeb1db9.tar.gz
cpython-c9c0f201fed21efcf669dbbf5f923eaf0eeb1db9.tar.bz2
convert old fail* assertions to assert*
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r--Lib/test/test_bytes.py112
1 files changed, 56 insertions, 56 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 992f3d2..caea909 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -102,22 +102,22 @@ class BaseBytesTest(unittest.TestCase):
b3 = self.type2test([1, 3])
self.assertEqual(b1, b2)
- self.failUnless(b2 != b3)
- self.failUnless(b1 <= b2)
- self.failUnless(b1 <= b3)
- self.failUnless(b1 < b3)
- self.failUnless(b1 >= b2)
- self.failUnless(b3 >= b2)
- self.failUnless(b3 > b2)
-
- self.failIf(b1 != b2)
- self.failIf(b2 == b3)
- self.failIf(b1 > b2)
- self.failIf(b1 > b3)
- self.failIf(b1 >= b3)
- self.failIf(b1 < b2)
- self.failIf(b3 < b2)
- self.failIf(b3 <= b2)
+ self.assertTrue(b2 != b3)
+ self.assertTrue(b1 <= b2)
+ self.assertTrue(b1 <= b3)
+ self.assertTrue(b1 < b3)
+ self.assertTrue(b1 >= b2)
+ self.assertTrue(b3 >= b2)
+ self.assertTrue(b3 > b2)
+
+ self.assertFalse(b1 != b2)
+ self.assertFalse(b2 == b3)
+ self.assertFalse(b1 > b2)
+ self.assertFalse(b1 > b3)
+ self.assertFalse(b1 >= b3)
+ self.assertFalse(b1 < b2)
+ self.assertFalse(b3 < b2)
+ self.assertFalse(b3 <= b2)
def test_compare_to_str(self):
warnings.simplefilter('ignore', BytesWarning)
@@ -220,27 +220,27 @@ class BaseBytesTest(unittest.TestCase):
def test_contains(self):
b = self.type2test(b"abc")
- self.failUnless(ord('a') in b)
- self.failUnless(int(ord('a')) in b)
- self.failIf(200 in b)
- self.failIf(200 in b)
+ self.assertTrue(ord('a') in b)
+ self.assertTrue(int(ord('a')) in b)
+ self.assertFalse(200 in b)
+ self.assertFalse(200 in b)
self.assertRaises(ValueError, lambda: 300 in b)
self.assertRaises(ValueError, lambda: -1 in b)
self.assertRaises(TypeError, lambda: None in b)
self.assertRaises(TypeError, lambda: float(ord('a')) in b)
self.assertRaises(TypeError, lambda: "a" in b)
for f in bytes, bytearray:
- self.failUnless(f(b"") in b)
- self.failUnless(f(b"a") in b)
- self.failUnless(f(b"b") in b)
- self.failUnless(f(b"c") in b)
- self.failUnless(f(b"ab") in b)
- self.failUnless(f(b"bc") in b)
- self.failUnless(f(b"abc") in b)
- self.failIf(f(b"ac") in b)
- self.failIf(f(b"d") in b)
- self.failIf(f(b"dab") in b)
- self.failIf(f(b"abd") in b)
+ self.assertTrue(f(b"") in b)
+ self.assertTrue(f(b"a") in b)
+ self.assertTrue(f(b"b") in b)
+ self.assertTrue(f(b"c") in b)
+ self.assertTrue(f(b"ab") in b)
+ self.assertTrue(f(b"bc") in b)
+ self.assertTrue(f(b"abc") in b)
+ self.assertFalse(f(b"ac") in b)
+ self.assertFalse(f(b"d") in b)
+ self.assertFalse(f(b"dab") in b)
+ self.assertFalse(f(b"abd") in b)
def test_fromhex(self):
self.assertRaises(TypeError, self.type2test.fromhex)
@@ -626,7 +626,7 @@ class ByteArrayTest(BaseBytesTest):
b += b"def"
self.assertEqual(b, b"abcdef")
self.assertEqual(b, b1)
- self.failUnless(b is b1)
+ self.assertTrue(b is b1)
b += b"xyz"
self.assertEqual(b, b"abcdefxyz")
try:
@@ -642,7 +642,7 @@ class ByteArrayTest(BaseBytesTest):
b *= 3
self.assertEqual(b, b"abcabcabc")
self.assertEqual(b, b1)
- self.failUnless(b is b1)
+ self.assertTrue(b is b1)
def test_irepeat_1char(self):
b = bytearray(b"x")
@@ -650,17 +650,17 @@ class ByteArrayTest(BaseBytesTest):
b *= 100
self.assertEqual(b, b"x"*100)
self.assertEqual(b, b1)
- self.failUnless(b is b1)
+ self.assertTrue(b is b1)
def test_alloc(self):
b = bytearray()
alloc = b.__alloc__()
- self.assert_(alloc >= 0)
+ self.assertTrue(alloc >= 0)
seq = [alloc]
for i in range(100):
b += b"x"
alloc = b.__alloc__()
- self.assert_(alloc >= len(b))
+ self.assertTrue(alloc >= len(b))
if alloc not in seq:
seq.append(alloc)
@@ -759,7 +759,7 @@ class ByteArrayTest(BaseBytesTest):
a, b, c = bytearray(b"x").partition(b"y")
self.assertEqual(b, b"")
self.assertEqual(c, b"")
- self.assert_(b is not c)
+ self.assertTrue(b is not c)
b += b"!"
self.assertEqual(c, b"")
a, b, c = bytearray(b"x").partition(b"y")
@@ -769,7 +769,7 @@ class ByteArrayTest(BaseBytesTest):
b, c, a = bytearray(b"x").rpartition(b"y")
self.assertEqual(b, b"")
self.assertEqual(c, b"")
- self.assert_(b is not c)
+ self.assertTrue(b is not c)
b += b"!"
self.assertEqual(c, b"")
c, b, a = bytearray(b"x").rpartition(b"y")
@@ -860,10 +860,10 @@ class AssortedBytesTest(unittest.TestCase):
self.assertEqual(bytes(b"abc") <= b"ab", False)
def test_doc(self):
- self.failUnless(bytearray.__doc__ != None)
- self.failUnless(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__)
- self.failUnless(bytes.__doc__ != None)
- self.failUnless(bytes.__doc__.startswith("bytes("), bytes.__doc__)
+ self.assertTrue(bytearray.__doc__ != None)
+ self.assertTrue(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__)
+ self.assertTrue(bytes.__doc__ != None)
+ self.assertTrue(bytes.__doc__.startswith("bytes("), bytes.__doc__)
def test_from_bytearray(self):
sample = bytes(b"Hello world\n\x80\x81\xfe\xff")
@@ -920,7 +920,7 @@ class AssortedBytesTest(unittest.TestCase):
def test_return_self(self):
# bytearray.replace must always return a new bytearray
b = bytearray()
- self.failIf(b.replace(b'', b'') is b)
+ self.assertFalse(b.replace(b'', b'') is b)
def test_compare(self):
if sys.flags.bytes_warning:
@@ -997,20 +997,20 @@ class ByteArraySubclass(bytearray):
class ByteArraySubclassTest(unittest.TestCase):
def test_basic(self):
- self.assert_(issubclass(ByteArraySubclass, bytearray))
- self.assert_(isinstance(ByteArraySubclass(), bytearray))
+ self.assertTrue(issubclass(ByteArraySubclass, bytearray))
+ self.assertTrue(isinstance(ByteArraySubclass(), bytearray))
a, b = b"abcd", b"efgh"
_a, _b = ByteArraySubclass(a), ByteArraySubclass(b)
# test comparison operators with subclass instances
- self.assert_(_a == _a)
- self.assert_(_a != _b)
- self.assert_(_a < _b)
- self.assert_(_a <= _b)
- self.assert_(_b >= _a)
- self.assert_(_b > _a)
- self.assert_(_a is not a)
+ self.assertTrue(_a == _a)
+ self.assertTrue(_a != _b)
+ self.assertTrue(_a < _b)
+ self.assertTrue(_a <= _b)
+ self.assertTrue(_b >= _a)
+ self.assertTrue(_b > _a)
+ self.assertTrue(_a is not a)
# test concat of subclass instances
self.assertEqual(a + b, _a + _b)
@@ -1018,7 +1018,7 @@ class ByteArraySubclassTest(unittest.TestCase):
self.assertEqual(a + b, _a + b)
# test repeat
- self.assert_(a*5 == _a*5)
+ self.assertTrue(a*5 == _a*5)
def test_join(self):
# Make sure join returns a NEW object for single item sequences
@@ -1026,12 +1026,12 @@ class ByteArraySubclassTest(unittest.TestCase):
# Make sure that it is of the appropriate type.
s1 = ByteArraySubclass(b"abcd")
s2 = bytearray().join([s1])
- self.assert_(s1 is not s2)
- self.assert_(type(s2) is bytearray, type(s2))
+ self.assertTrue(s1 is not s2)
+ self.assertTrue(type(s2) is bytearray, type(s2))
# Test reverse, calling join on subclass
s3 = s1.join([b"abcd"])
- self.assert_(type(s3) is bytearray)
+ self.assertTrue(type(s3) is bytearray)
def test_pickle(self):
a = ByteArraySubclass(b"abcd")