def test_no_crash_when_iterating_too_far(): from protozfits import rawzfitsreader from protozfits import L0_pb2 rawzfitsreader.open(example_file_path + ':Events') for i in range(rawzfitsreader.getNumRows()): event = L0_pb2.CameraEvent() event.ParseFromString(rawzfitsreader.readEvent()) # At this point we iterated through the entire file. # In version 0.43 we got a crash (seg fault or so) when iterating too # far. This test should ensure this behaviour is fixed in 0.44 with pytest.raises(EOFError): rawzfitsreader.readEvent()
def test_import_open_and_read(): from protozfits import rawzfitsreader from protozfits import L0_pb2 relative_test_file_path = os.path.relpath(example_file_path) rawzfitsreader.open(relative_test_file_path + ':Events') raw = rawzfitsreader.readEvent()
def test_rawreader_can_iterate(): from protozfits import rawzfitsreader from protozfits import L0_pb2 rawzfitsreader.open(example_file_path + ':Events') for i in range(rawzfitsreader.getNumRows()): event = L0_pb2.CameraEvent() event.ParseFromString(rawzfitsreader.readEvent())
def test_rawreader_can_work_with_absolute_path(): from protozfits import rawzfitsreader from protozfits import L0_pb2 rawzfitsreader.open(example_file_path + ':Events') raw = rawzfitsreader.readEvent() assert rawzfitsreader.getNumRows() == EVENTS_IN_EXAMPLE_FILE event = L0_pb2.CameraEvent() event.ParseFromString(raw)
def test_import_open_read_and_parse(): from protozfits import rawzfitsreader from protozfits import L0_pb2 relative_test_file_path = os.path.relpath(example_file_path) rawzfitsreader.open(relative_test_file_path + ':Events') raw = rawzfitsreader.readEvent() event = L0_pb2.CameraEvent() event.ParseFromString(raw)
def test_examplefile_has_no_runheader(): from protozfits import rawzfitsreader from protozfits import L0_pb2 rawzfitsreader.open(example_file_path + ':RunHeader') raw = rawzfitsreader.readEvent() assert raw < 0 header = L0_pb2.CameraRunHeader() with pytest.raises(TypeError): header.ParseFromString(raw)