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_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()