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
fix sandbox test test_cli_sandbox_edit_new_file (#9018)
Myles Scolnick7924aed97b09
diff --git a/tests/_cli/test_cli.py b/tests/_cli/test_cli.pyindex 4c7b5b2201..35a7d6b7ad 100644--- a/tests/_cli/test_cli.py+++ b/tests/_cli/test_cli.py@@ -1271,23 +1271,21 @@ def test_cli_sandbox_edit_no_prompt(temp_marimo_file: str) -> None:@pytest.mark.skipif(not HAS_UV, reason="uv is required for sandbox tests")def test_cli_sandbox_edit_new_file() -> None:- port = _get_port()- d = tempfile.TemporaryDirectory()- path = os.path.join(d.name, "new_sandbox_file.py")- p = subprocess.Popen(- [- "marimo",- "edit",- path,- "-p",- str(port),- "--headless",- "--no-token",- "--sandbox",- ]- )- contents = _try_fetch(port)- _check_contents(p, b"edit", contents)+ with tempfile.TemporaryDirectory() as d:+ path = os.path.join(d, "new_sandbox_file.py")+ runner = CliRunner()+ with patch(+ "marimo._cli.sandbox.run_in_sandbox"+ ) as mock_run_in_sandbox:+ result = runner.invoke(+ cli_main,+ ["edit", path, "--headless", "--no-token", "--sandbox"],+ )+ assert result.exit_code == 0, result.output+ mock_run_in_sandbox.assert_called_once()+ call_kwargs = mock_run_in_sandbox.call_args+ assert call_kwargs.kwargs["name"] == path+ assert call_kwargs.kwargs["additional_features"] == ["lsp"]@pytest.mark.skipif(@@ -1709,25 +1707,23 @@ def test_cli_with_custom_pyproject_config_no_file(tmp_path: Path) -> None:p.kill()# marimo new --sandbox, in the directory with pyproject.toml- port = _get_port()- p = subprocess.Popen(- [- "marimo",- "new",- "--sandbox",- "-p",- str(port),- "--headless",- "--no-token",- ],- cwd=tmp_path,- )-+ runner = CliRunner()+ original_dir = os.getcwd()try:- contents = _try_fetch(port)- assert_custom_config(contents)+ os.chdir(tmp_path)+ with patch(+ "marimo._cli.sandbox.run_in_sandbox"+ ) as mock_run_in_sandbox:+ result = runner.invoke(+ cli_main,+ ["new", "--sandbox", "--headless", "--no-token"],+ )finally:- p.kill()+ os.chdir(original_dir)+ assert result.exit_code == 0, result.output+ mock_run_in_sandbox.assert_called_once()+ call_kwargs = mock_run_in_sandbox.call_args+ assert call_kwargs.kwargs["additional_features"] == ["lsp"]# shell-completion has 1 input (value of $SHELL) & 3 outputs (return code, stdout, & stderr)