]> granicus.if.org Git - python/commitdiff
Fix tset_bytes.py.
authorGuido van Rossum <guido@python.org>
Thu, 24 May 2007 17:52:00 +0000 (17:52 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 24 May 2007 17:52:00 +0000 (17:52 +0000)
Lib/test/test_bytes.py

index 9fdca7f2797e0f1f526f61aeb9121d46af1a02a3..efb4c98c9bbd71c6f44f250858ac276fd449a6bf 100644 (file)
@@ -146,8 +146,8 @@ class BytesTest(unittest.TestCase):
         self.failUnless(bytes.__doc__.startswith("bytes("))
 
     def test_buffer_api(self):
-        short_sample = "Hello world\n"
-        sample = short_sample + "x"*(20 - len(short_sample))
+        short_sample = b"Hello world\n"
+        sample = short_sample + b"x"*(20 - len(short_sample))
         tfn = tempfile.mktemp()
         try:
             # Prepare
@@ -155,10 +155,10 @@ class BytesTest(unittest.TestCase):
                 f.write(short_sample)
             # Test readinto
             with open(tfn, "rb") as f:
-                b = bytes([ord('x')]*20)
+                b = b"x"*20
                 n = f.readinto(b)
             self.assertEqual(n, len(short_sample))
-            self.assertEqual(list(b), map(ord, sample))
+            self.assertEqual(b, sample)
             # Test writing in binary mode
             with open(tfn, "wb") as f:
                 f.write(b)