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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
tidy/fix: clean up pytest default name (#6077)
Dylan Madisettiecf2b521f2a3
diff --git a/marimo/_runtime/pytest.py b/marimo/_runtime/pytest.pyindex 3a891da9d3..3a46bbb684 100644--- a/marimo/_runtime/pytest.py+++ b/marimo/_runtime/pytest.py@@ -12,7 +12,7 @@ from marimo._ast.pytest import MARIMO_TEST_STUB_NAMEfrom marimo._cli.print import bold, greenfrom marimo._dependencies.dependencies import DependencyManagerfrom marimo._runtime.capture import capture_stdout-from marimo._runtime.context import ContextNotInitializedError, get_context+from marimo._runtime.context import safe_get_contextMARIMO_TEST_BLOCK_REGEX = re.compile(rf"{MARIMO_TEST_STUB_NAME}_\d+[(?::)\.]+")@@ -44,14 +44,11 @@ class MarimoPytestResult:)-def _maybe_name() -> str:- try:- ctx: Any = get_context()- if ctx.filename is not None:- filename = ctx.filename- except ContextNotInitializedError:- filename = "notebook.py"- assert isinstance(filename, str)+def _get_name(default: str = "notebook.py") -> str:+ filename = default+ ctx = safe_get_context()+ if ctx and ctx.filename is not None:+ filename = ctx.filenamereturn filename@@ -63,7 +60,7 @@ def _to_marimo_uri(uri: str) -> str:return uricell_id = uri.split("_")[6]- notebook = os.path.relpath(_maybe_name(), marimo.notebook_location())+ notebook = os.path.relpath(_get_name(), marimo.notebook_location())return f"marimo://{notebook}#cell_id={cell_id}"@@ -249,7 +246,7 @@ def run_pytest(if not notebook_path:# Translate name to python module- notebook_path = _maybe_name()+ notebook_path = _get_name()notebook_path = str(notebook_path)# Hold on to modules since we want to refresh them in order to enable