mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
I don't know how come bytes.join() was a class method, but that's clearly
a mistake. It's not a regular (instance) method. b".".join([b"a", b"b"]) now returns b"a.b" -- it used to return b"ab"!
This commit is contained in:
parent
0925e419df
commit
cd6ae68943
2 changed files with 18 additions and 10 deletions
|
@ -466,13 +466,14 @@ class BytesTest(unittest.TestCase):
|
|||
self.assertRaises(ValueError, bytes.fromhex, '12 \x00 34')
|
||||
|
||||
def test_join(self):
|
||||
self.assertEqual(bytes.join([]), bytes())
|
||||
self.assertEqual(bytes.join([bytes()]), bytes())
|
||||
self.assertEqual(b"".join([]), bytes())
|
||||
self.assertEqual(b"".join([bytes()]), bytes())
|
||||
for part in [("abc",), ("a", "bc"), ("ab", "c"), ("a", "b", "c")]:
|
||||
lst = map(bytes, part)
|
||||
self.assertEqual(bytes.join(lst), bytes("abc"))
|
||||
self.assertEqual(bytes.join(tuple(lst)), bytes("abc"))
|
||||
self.assertEqual(bytes.join(iter(lst)), bytes("abc"))
|
||||
self.assertEqual(b"".join(lst), bytes("abc"))
|
||||
self.assertEqual(b"".join(tuple(lst)), bytes("abc"))
|
||||
self.assertEqual(b"".join(iter(lst)), bytes("abc"))
|
||||
self.assertEqual(b".".join([b"ab", b"cd"]), b"ab.cd")
|
||||
# XXX more...
|
||||
|
||||
def test_literal(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue