def test_compare_copy_default_format(snapshot_path):
    """"""
    with Snapshot(snapshot_path) as snap:
        new_snap_path = snapshot_path + "-test-copy"
        with Snapshot(new_snap_path) as new_snap:
            assert new_snap.format is FileFormat.DEFAULT
            assert new_snap.header == snap.header
            print(new_snap.inspect())
def test_copy(snapshot_path):
    """"""
    with Snapshot(snapshot_path) as snap:
        new_snap_path = snapshot_path + "-test-copy"
        with Snapshot(new_snap_path, "w") as new_snap:
            # First assign the header.
            new_snap.header = snap.header
            # Block assignment order matters.
            new_snap["POS"] = snap["POS"]
            new_snap["VEL"] = snap["VEL"]
            new_snap["ID"] = snap["ID"]
            new_snap.flush()
def test_copy_block_twice(snapshot_path):
    """"""
    with pytest.raises(KeyError):
        with Snapshot(snapshot_path) as snap:
            new_snap_path = snapshot_path + "-test-snap"
            with Snapshot(new_snap_path, "w") as new_snap:
                # First assign the header.
                new_snap.header = snap.header
                # This must fail.
                new_snap["POS"] = snap["POS"]
                new_snap.flush()
                new_snap["POS"] = snap["POS"]
                new_snap.flush()
def test_copy_default_format(snapshot_path):
    """"""
    with Snapshot(snapshot_path) as snap:
        new_snap_path = snapshot_path + "-test-copy"
        with Snapshot(new_snap_path, "w",
                      format=FileFormat.DEFAULT) as new_snap:
            # First assign the header.
            new_snap.header = snap.header
            # Block assignment order matters.
            new_snap["POS"] = snap["POS"]
            new_snap["VEL"] = snap["VEL"]
            new_snap["ID"] = snap["ID"]
            new_snap.flush()
def test_iter(snapshot_path):
    """"""
    with Snapshot(snapshot_path) as snap:
        for block in snap.values():
            print("************ Block ************")
            print(block)
        print("Number of reachable snapshot blocks: {}".format(len(snap)))
def test_read_invalid_mode(snapshot_path):
    """"""
    with pytest.raises(ValueError):
        # Although snapshots are open as binary, the mode does not accept
        # the ``b`` modifier.
        with Snapshot(snapshot_path, "rb") as snap:
            print(snap)
def test_load_blocks(snapshot_path):
    """"""
    with Snapshot(snapshot_path) as snap:
        positions1 = snap["POS"]
        velocities = snap["VEL"]
        positions2 = snap["POS"]
        print(snap.header)
        print(positions1)
        print(positions2)
        print(velocities)
def test_create(dummy_snap_header, dummy_snap_block):
    """"""
    file_path = Path(os.path.join(os.getcwd(), "test-dummy-snap"))
    file_format = FileFormat.ALT
    with Snapshot(file_path, "w", format=file_format) as snap:
        # Assign new header and block.
        snap.header = dummy_snap_header
        snap["POS"] = dummy_snap_block
        print(snap["POS"])
        snap.flush()
def test_inspect(snapshot_path):
    """"""
    with Snapshot(snapshot_path) as snap:
        block_specs = snap.inspect()
        print(block_specs)
def test_read(snapshot_path):
    """"""
    with Snapshot(snapshot_path) as snap:
        print(snap)
def test_read_created(dummy_snap_header):
    """"""
    file_path = Path(os.path.join(os.getcwd(), "test-dummy-snap"))
    with Snapshot(file_path) as snap:
        assert snap.header == dummy_snap_header
        print(snap["POS"])