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.

Add a unit test for cell runner's output (#362)

Akshay Agrawala04cffca4ac5
diff --git a/marimo/_runtime/test_cell_runner.py b/marimo/_runtime/test_cell_runner.py
new file mode 100644
index 0000000000..7e687061ee
--- /dev/null
+++ b/marimo/_runtime/test_cell_runner.py
@@ -0,0 +1,16 @@
+# Copyright 2023 Marimo. All rights reserved.
+from marimo._runtime.cell_runner import Runner
+from marimo._runtime.conftest import ExecReqProvider
+from marimo._runtime.runtime import Kernel
+
+
+def test_cell_output(k: Kernel, exec_req: ExecReqProvider) -> None:
+ # run the cell to populate the graph, globals
+ k.run([er := exec_req.get("'hello'; 123")])
+
+ runner = Runner(
+ cell_ids=set(k.graph.cells.keys()), graph=k.graph, glbls=k.globals
+ )
+ run_result = runner.run(er.cell_id)
+ # last expression of cell is output
+ assert run_result.output == 123