mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Merged revisions 74477 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r74477 | frank.wierzbicki | 2009-08-16 16:22:51 -0400 (Sun, 16 Aug 2009) | 2 lines Add test of file.write(array) extracted from Jython. ........
This commit is contained in:
parent
01099707db
commit
176834327f
1 changed files with 19 additions and 0 deletions
|
@ -326,6 +326,25 @@ class BaseTest(unittest.TestCase):
|
||||||
f.close()
|
f.close()
|
||||||
support.unlink(support.TESTFN)
|
support.unlink(support.TESTFN)
|
||||||
|
|
||||||
|
def test_filewrite(self):
|
||||||
|
a = array.array(self.typecode, 2*self.example)
|
||||||
|
f = open(support.TESTFN, 'wb')
|
||||||
|
try:
|
||||||
|
f.write(a)
|
||||||
|
f.close()
|
||||||
|
b = array.array(self.typecode)
|
||||||
|
f = open(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()
|
||||||
|
support.unlink(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