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.

test: check that certain globals are populated in execution context (#1989)

Dylan Madisettib06dc8a9d0f3
diff --git a/tests/_runtime/test_runtime.py b/tests/_runtime/test_runtime.py
index 1dd38539e4..c1ef0c9c17 100644
--- a/tests/_runtime/test_runtime.py
+++ b/tests/_runtime/test_runtime.py
@@ -46,6 +46,28 @@ def _check_edges(error: Error, expected_edges: Sequence[EdgeWithVar]) -> None:
class TestExecution:
+ async def test_expected_gloals(self, any_kernel: Kernel):
+ k = any_kernel
+ await k.run(
+ [
+ ExecutionRequest(
+ cell_id="0", code="assert __file__; success = 1"
+ )
+ ]
+ )
+ expected_globals = {
+ "__builtin__",
+ "__doc__",
+ "__file__",
+ "__marimo__",
+ "__name__",
+ "__package__",
+ "__loader__",
+ "__spec__",
+ }
+ assert not (expected_globals - set(k.globals.keys()))
+ assert k.globals["success"] == 1
+
async def test_triangle(self, any_kernel: Kernel) -> None:
k = any_kernel
# x