summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_array.py
diff options
context:
space:
mode:
authorFrank Wierzbicki <fwierzbicki@gmail.com>2009-08-16 20:30:12 (GMT)
committerFrank Wierzbicki <fwierzbicki@gmail.com>2009-08-16 20:30:12 (GMT)
commit176834327f408b41ecd7c0313bb384d49f96ca15 (patch)
treee3e5db98da4be2a35532e267ecd4772a3bd33647 /Lib/test/test_array.py
parent01099707dbc1b7c774253ac0cd278c2c09272a30 (diff)
downloadcpython-176834327f408b41ecd7c0313bb384d49f96ca15.zip
cpython-176834327f408b41ecd7c0313bb384d49f96ca15.tar.gz
cpython-176834327f408b41ecd7c0313bb384d49f96ca15.tar.bz2
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. ........
Diffstat (limited to 'Lib/test/test_array.py')
-rwxr-xr-xLib/test/test_array.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index ba11656..5e3e0e0 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -326,6 +326,25 @@ class BaseTest(unittest.TestCase):
f.close()
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):
a = array.array(self.typecode, 2*self.example)
b = array.array(self.typecode)