Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

1.5 KB
Raw Blame
# Copyright 2026 Marimo. All rights reserved.
from __future__ import annotations

import pytest


class TestVersionCache:
    @staticmethod
    @pytest.mark.skipif(
        "sys.version_info < (3, 12) or sys.version_info >= (3, 13)"
    )
    def test_load_v4_pickle(app) -> None:
        @app.cell
        def _():
            unhashable = [object()]

        @app.cell
        def v1(unhashable) -> tuple[int]:
            # Check top level import
            from marimo import persistent_cache

            ref = 1
            with persistent_cache(
                name="pickle-dump-v4",
                save_path="tests/_save/cache-dumps",
                method="pickle",
            ) as cache:
                value = 1 + len(unhashable) + ref
            assert cache.hit
            assert value == 3

    @staticmethod
    @pytest.mark.skipif(
        "sys.version_info < (3, 12) or sys.version_info >= (3, 13)"
    )
    def test_load_v4_json(app) -> None:
        @app.cell
        def _():
            unhashable = [object()]

        @app.cell
        def v1(unhashable) -> tuple[int]:
            # Check top level import
            from marimo import persistent_cache

            ref = 1
            with persistent_cache(
                name="json-dump-v4",
                save_path="tests/_save/cache-dumps",
                method="json",
            ) as cache:
                value = 1 + len(unhashable) + ref
            assert cache.hit
            assert value == 3