def testWriteBytesIO(self):
    with BytesIO() as bio:
        with BZ2File(bio, 'w') as bz2f:
            self.assertRaises(TypeError, bz2f.write)
            bz2f.write(self.TEXT)
        self.assertEqual(ext_decompress(bio.getvalue()), self.TEXT)
        self.assertFalse(bio.closed)
def testWriteBytesIO(self):
    with BytesIO() as bio:
        with BZ2File(bio, 'w') as bz2f:
            self.assertRaises(TypeError, bz2f.write)
            bz2f.write(self.TEXT)
        self.assertEqual(ext_decompress(bio.getvalue()), self.TEXT)
        self.assertFalse(bio.closed)