summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-26 21:46:44 (GMT)
committerGuido van Rossum <guido@python.org>2007-10-26 21:46:44 (GMT)
commitae404e2e0a957e1e584b476e21c51201e611ab44 (patch)
treebc4ea61fd56d2096942e3c4e378cd9bf746b0fd4 /Lib/test
parenta2074f0bd75b5e08a6f9094dc30c26e2252e3747 (diff)
downloadcpython-ae404e2e0a957e1e584b476e21c51201e611ab44.zip
cpython-ae404e2e0a957e1e584b476e21c51201e611ab44.tar.gz
cpython-ae404e2e0a957e1e584b476e21c51201e611ab44.tar.bz2
Sort the method lists for str8 and bytes so differences are more apparent.
Changed bytes.fromhex to take a str argument, as the docstring promises. Added str8.fromhex (untested so far).
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_bytes.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 2a4b6d8..112cb32 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -450,23 +450,21 @@ class BytesTest(unittest.TestCase):
self.assert_(alloc >= len(b))
if alloc not in seq:
seq.append(alloc)
- #print seq
def test_fromhex(self):
self.assertRaises(TypeError, bytes.fromhex)
self.assertRaises(TypeError, bytes.fromhex, 1)
- self.assertEquals(bytes.fromhex(b''), bytes())
+ self.assertEquals(bytes.fromhex(''), bytes())
b = bytes([0x1a, 0x2b, 0x30])
- self.assertEquals(bytes.fromhex(b'1a2B30'), b)
- self.assertEquals(bytes.fromhex(b' 1A 2B 30 '), b)
- self.assertEquals(bytes.fromhex(memoryview(b'')), bytes())
- self.assertEquals(bytes.fromhex(memoryview(b'0000')), bytes([0, 0]))
- self.assertRaises(TypeError, bytes.fromhex, '1B')
- self.assertRaises(ValueError, bytes.fromhex, b'a')
- self.assertRaises(ValueError, bytes.fromhex, b'rt')
- self.assertRaises(ValueError, bytes.fromhex, b'1a b cd')
- self.assertRaises(ValueError, bytes.fromhex, b'\x00')
- self.assertRaises(ValueError, bytes.fromhex, b'12 \x00 34')
+ self.assertEquals(bytes.fromhex('1a2B30'), b)
+ self.assertEquals(bytes.fromhex(' 1A 2B 30 '), b)
+ self.assertEquals(bytes.fromhex('0000'), b'\0\0')
+ self.assertRaises(TypeError, bytes.fromhex, b'1B')
+ self.assertRaises(ValueError, bytes.fromhex, 'a')
+ self.assertRaises(ValueError, bytes.fromhex, 'rt')
+ self.assertRaises(ValueError, bytes.fromhex, '1a b cd')
+ self.assertRaises(ValueError, bytes.fromhex, '\x00')
+ self.assertRaises(ValueError, bytes.fromhex, '12 \x00 34')
def test_join(self):
self.assertEqual(b"".join([]), bytes())