mirror of
https://github.com/python/cpython.git
synced 2025-07-29 22:24:49 +00:00
Add test of file.write(array) extracted from Jython.
This commit is contained in:
parent
b98d6b2cbc
commit
df756775f5
1 changed files with 19 additions and 0 deletions
|
@ -188,6 +188,25 @@ class BaseTest(unittest.TestCase):
|
||||||
f.close()
|
f.close()
|
||||||
test_support.unlink(test_support.TESTFN)
|
test_support.unlink(test_support.TESTFN)
|
||||||
|
|
||||||
|
def test_filewrite(self):
|
||||||
|
a = array.array(self.typecode, 2*self.example)
|
||||||
|
f = open(test_support.TESTFN, 'wb')
|
||||||
|
try:
|
||||||
|
f.write(a)
|
||||||
|
f.close()
|
||||||
|
b = array.array(self.typecode)
|
||||||
|
f = open(test_support.TESTFN, 'rb')
|
||||||
|
b.fromfile(f, len(self.example))
|
||||||
|
self.assertEqual(b, array.array(self.typecode, self.example))
|
||||||
|
self.assertNotEqual(a, b)
|
||||||
|
b.fromfile(f, len(self.example))
|
||||||
|
self.assertEqual(a, b)
|
||||||
|
f.close()
|
||||||
|
finally:
|
||||||
|
if not f.closed:
|
||||||
|
f.close()
|
||||||
|
test_support.unlink(test_support.TESTFN)
|
||||||
|
|
||||||
def test_tofromlist(self):
|
def test_tofromlist(self):
|
||||||
a = array.array(self.typecode, 2*self.example)
|
a = array.array(self.typecode, 2*self.example)
|
||||||
b = array.array(self.typecode)
|
b = array.array(self.typecode)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue