From: Georg Brandl Date: Mon, 14 Aug 2006 21:45:35 +0000 (+0000) Subject: Add an additional test: BZ2File write methods should raise IOError X-Git-Tag: v2.4.4c1~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee76a565c341fda903466e1a34d0a8d0b52391b3;p=thirdparty%2FPython%2Fcpython.git Add an additional test: BZ2File write methods should raise IOError when file is read-only. (backport from rev. 51287) --- diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py index 4e033942f9d4..c3a4f91f39ac 100644 --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -172,6 +172,15 @@ class BZ2FileTest(BaseTest): self.assertEqual(self.decompress(f.read()), self.TEXT) f.close() + def testWriteMethodsOnReadOnlyFile(self): + bz2f = BZ2File(self.filename, "w") + bz2f.write("abc") + bz2f.close() + + bz2f = BZ2File(self.filename, "r") + self.assertRaises(IOError, bz2f.write, "a") + self.assertRaises(IOError, bz2f.writelines, ["a"]) + def testSeekForward(self): # "Test BZ2File.seek(150, 0)" self.createTempFile()