summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bz2.py
diff options
context:
space:
mode:
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)