summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bz2.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2004-11-01 17:10:19 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2004-11-01 17:10:19 (GMT)
commitbb9c739806b9f0251fa4a564986e2cb5e92e766e (patch)
treee98ea3d19448ce76e31182e06d88a3a765592066 /Lib/test/test_bz2.py
parentbc1d1b80d1abfd7f95cb02e7f09be18b94504559 (diff)
downloadcpython-bb9c739806b9f0251fa4a564986e2cb5e92e766e.zip
cpython-bb9c739806b9f0251fa4a564986e2cb5e92e766e.tar.gz
cpython-bb9c739806b9f0251fa4a564986e2cb5e92e766e.tar.bz2
Add error checks for the bz2, cStringIO and operator modules.
Add function names to various PyArg_ParseTuple calls in bz2module.c.
Diffstat (limited to 'Lib/test/test_bz2.py')
-rw-r--r--Lib/test/test_bz2.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index 61f8047..7d844d8 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -59,6 +59,7 @@ class BZ2FileTest(BaseTest):
# "Test BZ2File.read()"
self.createTempFile()
bz2f = BZ2File(self.filename)
+ self.assertRaises(TypeError, bz2f.read, None)
self.assertEqual(bz2f.read(), self.TEXT)
bz2f.close()
@@ -86,6 +87,7 @@ class BZ2FileTest(BaseTest):
# "Test BZ2File.readline()"
self.createTempFile()
bz2f = BZ2File(self.filename)
+ self.assertRaises(TypeError, bz2f.readline, None)
sio = StringIO(self.TEXT)
for line in sio.readlines():
self.assertEqual(bz2f.readline(), line)
@@ -95,6 +97,7 @@ class BZ2FileTest(BaseTest):
# "Test BZ2File.readlines()"
self.createTempFile()
bz2f = BZ2File(self.filename)
+ self.assertRaises(TypeError, bz2f.readlines, None)
sio = StringIO(self.TEXT)
self.assertEqual(bz2f.readlines(), sio.readlines())
bz2f.close()
@@ -134,6 +137,7 @@ class BZ2FileTest(BaseTest):
def testWrite(self):
# "Test BZ2File.write()"
bz2f = BZ2File(self.filename, "w")
+ self.assertRaises(TypeError, bz2f.write)
bz2f.write(self.TEXT)
bz2f.close()
f = open(self.filename, 'rb')
@@ -158,6 +162,7 @@ class BZ2FileTest(BaseTest):
def testWriteLines(self):
# "Test BZ2File.writelines()"
bz2f = BZ2File(self.filename, "w")
+ self.assertRaises(TypeError, bz2f.writelines)
sio = StringIO(self.TEXT)
bz2f.writelines(sio.readlines())
bz2f.close()
@@ -169,6 +174,7 @@ class BZ2FileTest(BaseTest):
# "Test BZ2File.seek(150, 0)"
self.createTempFile()
bz2f = BZ2File(self.filename)
+ self.assertRaises(TypeError, bz2f.seek)
bz2f.seek(150)
self.assertEqual(bz2f.read(), self.TEXT[150:])
bz2f.close()
@@ -233,6 +239,7 @@ class BZ2CompressorTest(BaseTest):
def testCompress(self):
# "Test BZ2Compressor.compress()/flush()"
bz2c = BZ2Compressor()
+ self.assertRaises(TypeError, bz2c.compress)
data = bz2c.compress(self.TEXT)
data += bz2c.flush()
self.assertEqual(self.decompress(data), self.TEXT)
@@ -252,9 +259,13 @@ class BZ2CompressorTest(BaseTest):
self.assertEqual(self.decompress(data), self.TEXT)
class BZ2DecompressorTest(BaseTest):
+ def test_Constructor(self):
+ self.assertRaises(TypeError, BZ2Decompressor, 42)
+
def testDecompress(self):
# "Test BZ2Decompressor.decompress()"
bz2d = BZ2Decompressor()
+ self.assertRaises(TypeError, bz2d.decompress)
text = bz2d.decompress(self.DATA)
self.assertEqual(text, self.TEXT)