From: Frank Wierzbicki Date: Sun, 16 Aug 2009 20:22:51 +0000 (+0000) Subject: Add test of file.write(array) extracted from Jython. X-Git-Tag: v2.7a1~653 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df756775f5c56c5eef959a90321a513802fbda8c;p=thirdparty%2FPython%2Fcpython.git Add test of file.write(array) extracted from Jython. --- diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 0ef5f9e518bc..63f7083d3373 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)