summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorFrank Wierzbicki <fwierzbicki@gmail.com>2009-08-16 20:22:51 (GMT)
committerFrank Wierzbicki <fwierzbicki@gmail.com>2009-08-16 20:22:51 (GMT)
commitdf756775f5c56c5eef959a90321a513802fbda8c (patch)
treef26baea147dfca2b41ebae81dcad390e56712408 /Lib/test
parentb98d6b2cbcba1344609a60c7c0fb9f595d19023b (diff)
downloadcpython-df756775f5c56c5eef959a90321a513802fbda8c.zip
cpython-df756775f5c56c5eef959a90321a513802fbda8c.tar.gz
cpython-df756775f5c56c5eef959a90321a513802fbda8c.tar.bz2
Add test of file.write(array) extracted from Jython.
Diffstat (limited to 'Lib/test')
-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 0ef5f9e..63f7083 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -188,6 +188,25 @@ class BaseTest(unittest.TestCase):
f.close()
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):
a = array.array(self.typecode, 2*self.example)
b = array.array(self.typecode)