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.

stop gap: check header for race condition (#4589)

Dylan Madisetti2cc82340ef10
diff --git a/tests/_server/api/endpoints/test_files.py b/tests/_server/api/endpoints/test_files.py
index c67f0bed36..a7c3dafaa5 100644
--- a/tests/_server/api/endpoints/test_files.py
+++ b/tests/_server/api/endpoints/test_files.py
@@ -140,6 +140,9 @@ def test_save_with_header(client: TestClient) -> None:
assert "import marimo" in response.text
file_contents = open(filename).read()
assert "import marimo as mo" in file_contents
+ # Race condition with uv (seen in python 3.10)
+ if file_contents.startswith("# ///"):
+ file_contents = file_contents.split("# ///")[2].lstrip()
assert file_contents.startswith(header.rstrip()), "Header was removed"
assert "@app.cell(hide_code=True)" in file_contents
assert "my_cell" in file_contents
@@ -182,10 +185,14 @@ def test_save_with_invalid_file(client: TestClient) -> None:
assert response.status_code == 200, response.text
assert "import marimo" in response.text
file_contents = open(filename).read()
- assert file_contents.startswith("import marimo"), "Header was not removed"
assert "@app.cell(hide_code=True)" in file_contents
assert "my_cell" in file_contents
+ # Race condition with uv (seen in python 3.10)
+ if file_contents.startswith("# ///"):
+ file_contents = file_contents.split("# ///")[2].lstrip()
+ assert file_contents.startswith("import marimo"), "Header was not removed"
+
@with_session(SESSION_ID)
def test_save_file_cannot_rename(client: TestClient) -> None: