mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Fix tset_bytes.py.
This commit is contained in:
parent
eceb0fbb0a
commit
75d6f1a2fa
1 changed files with 4 additions and 4 deletions
|
@ -146,8 +146,8 @@ class BytesTest(unittest.TestCase):
|
||||||
self.failUnless(bytes.__doc__.startswith("bytes("))
|
self.failUnless(bytes.__doc__.startswith("bytes("))
|
||||||
|
|
||||||
def test_buffer_api(self):
|
def test_buffer_api(self):
|
||||||
short_sample = "Hello world\n"
|
short_sample = b"Hello world\n"
|
||||||
sample = short_sample + "x"*(20 - len(short_sample))
|
sample = short_sample + b"x"*(20 - len(short_sample))
|
||||||
tfn = tempfile.mktemp()
|
tfn = tempfile.mktemp()
|
||||||
try:
|
try:
|
||||||
# Prepare
|
# Prepare
|
||||||
|
@ -155,10 +155,10 @@ class BytesTest(unittest.TestCase):
|
||||||
f.write(short_sample)
|
f.write(short_sample)
|
||||||
# Test readinto
|
# Test readinto
|
||||||
with open(tfn, "rb") as f:
|
with open(tfn, "rb") as f:
|
||||||
b = bytes([ord('x')]*20)
|
b = b"x"*20
|
||||||
n = f.readinto(b)
|
n = f.readinto(b)
|
||||||
self.assertEqual(n, len(short_sample))
|
self.assertEqual(n, len(short_sample))
|
||||||
self.assertEqual(list(b), map(ord, sample))
|
self.assertEqual(b, sample)
|
||||||
# Test writing in binary mode
|
# Test writing in binary mode
|
||||||
with open(tfn, "wb") as f:
|
with open(tfn, "wb") as f:
|
||||||
f.write(b)
|
f.write(b)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue