def read_header(path): from mrcfile.mrcinterpreter import MrcInterpreter mi = MrcInterpreter() mi._iostream = open(path, 'rb') mi._read_header() mi._iostream.close() return mi.header
def test_permissive_read_mode_with_file_too_small(self): stream = io.BytesIO() mrc = MrcInterpreter() mrc._iostream = stream mrc._create_default_attributes() mrc.set_data(np.arange(12, dtype=np.int16).reshape(1, 3, 4)) mrc.close() stream.seek(-1, io.SEEK_CUR) stream.truncate() stream.seek(0) with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") MrcInterpreter(iostream=stream, permissive=True) assert len(w) == 1 assert ("Expected 24 bytes in data block but could only read 23" in str(w[0].message))