'Tests that files with bad CRCs raise a BadZipFile exception when read.'

def test_read_with_bad_crc(self):

    zipdata = self.zip_with_bad_crc
    with zipfile.ZipFile(io.BytesIO(zipdata), mode='r') as zipf:
        self.assertRaises(zipfile.BadZipFile, zipf.read, 'afile')
    with zipfile.ZipFile(io.BytesIO(zipdata), mode='r') as zipf:
        with zipf.open('afile', 'r') as corrupt_file:
            self.assertRaises(zipfile.BadZipFile, corrupt_file.read)
    with zipfile.ZipFile(io.BytesIO(zipdata), mode='r') as zipf:
        with zipf.open('afile', 'r') as corrupt_file:
            corrupt_file.MIN_READ_SIZE = 2
            with self.assertRaises(zipfile.BadZipFile):
                while corrupt_file.read(2):
                    pass
