def test_corrupted_file(self):
    file_name = self._write_data()
    with open(file_name, 'rb') as f:
        data = f.read()
    corrupted_data = bytearray(data)
    corrupted_data[(- 1)] = ((corrupted_data[(- 1)] + 1) % 256)
    with tempfile.NamedTemporaryFile(delete=False, prefix=tempfile.template) as f:
        f.write(corrupted_data)
        corrupted_file_name = f.name
    source = _create_avro_source(corrupted_file_name, use_fastavro=self.use_fastavro)
    with self.assertRaisesRegex(ValueError, 'expected sync marker'):
        source_test_utils.read_from_source(source, None, None)
def test_corrupted_file(self):
    file_name = self._write_data()
    with open(file_name, 'rb') as f:
        data = f.read()
    corrupted_data = bytearray(data)
    corrupted_data[(- 1)] = ((corrupted_data[(- 1)] + 1) % 256)
    with tempfile.NamedTemporaryFile(delete=False, prefix=tempfile.template) as f:
        f.write(corrupted_data)
        corrupted_file_name = f.name
    source = _create_avro_source(corrupted_file_name, use_fastavro=self.use_fastavro)
    with self.assertRaisesRegex(ValueError, 'expected sync marker'):
        source_test_utils.read_from_source(source, None, None)