mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Make sure that writing an array instance returns the number of bytes,
not the number of array elements.
This commit is contained in:
parent
aa43ed95cd
commit
d410395ea7
2 changed files with 17 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
import sys
|
||||
import time
|
||||
import array
|
||||
import unittest
|
||||
from itertools import chain
|
||||
from test import test_support
|
||||
|
@ -235,6 +236,16 @@ class IOTest(unittest.TestCase):
|
|||
self.assertEqual(f.read(), b"xxx")
|
||||
f.close()
|
||||
|
||||
def test_array_writes(self):
|
||||
a = array.array('i', range(10))
|
||||
n = len(buffer(a))
|
||||
f = io.open(test_support.TESTFN, "wb", 0)
|
||||
self.assertEqual(f.write(a), n)
|
||||
f.close()
|
||||
f = io.open(test_support.TESTFN, "wb")
|
||||
self.assertEqual(f.write(a), n)
|
||||
f.close()
|
||||
|
||||
|
||||
class MemorySeekTestMixin:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue