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.

899 B
Raw Blame
# Copyright 2026 Marimo. All rights reserved.
from __future__ import annotations

import re
from pathlib import Path

import pytest

from marimo._convert.converters import MarimoConvert
from marimo._convert.ipynb.to_ir import convert_from_ipynb_to_notebook_ir
from tests.mocks import snapshotter

snapshot = snapshotter(__file__)

DIR_PATH = Path(__file__).parent / "fixtures" / "ipynb"


@pytest.mark.parametrize("ipynb_path", DIR_PATH.glob("*.ipynb"))
def test_ipynb_to_marimo_snapshots(ipynb_path: Path) -> None:
    contents = ipynb_path.read_text()
    ir = convert_from_ipynb_to_notebook_ir(contents)
    converted = MarimoConvert.from_ir(ir).to_py()

    converted = re.sub(r"__generated_with = .*\n", "", converted)
    converted = re.sub(r"# requires-python = .*\n", "", converted)
    snapshot(
        f"converted_{ipynb_path.name.replace('.ipynb', '.py.txt')}",
        converted,
    )