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.

ci: add rerun to flakey tests (#5751)

Myles Scolnick38d05223dfb6
diff --git a/pyproject.toml b/pyproject.toml
index 820d9434f1..fe3e9dc130 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -221,6 +221,7 @@ extra-dependencies = [
"pytest~=8.3.4",
"pytest-timeout~=2.3.1",
"pytest-codecov~=0.6.1",
+ "pytest-rerunfailures~=15.1",
"pytest-asyncio~=0.26.0",
]
@@ -249,6 +250,7 @@ extra-dependencies = [
"pytest~=8.3.4",
"pytest-timeout~=2.3.1",
"pytest-codecov~=0.6.1",
+ "pytest-rerunfailures~=15.1",
"pytest-asyncio~=0.26.0",
"python-lsp-server>=1.10.0",
# For testing mo.ui.chart, table, ...
diff --git a/tests/_server/api/endpoints/test_files.py b/tests/_server/api/endpoints/test_files.py
index 4121b701aa..04e6ffcbcd 100644
--- a/tests/_server/api/endpoints/test_files.py
+++ b/tests/_server/api/endpoints/test_files.py
@@ -67,6 +67,7 @@ def test_rename(client: TestClient) -> None:
_try_assert_n_times(5, _new_path_exists)
@with_session(SESSION_ID)
def test_read_code(client: TestClient) -> None:
response = client.post(
@@ -75,9 +76,10 @@ def test_read_code(client: TestClient) -> None:
json={},
)
assert response.status_code == 200, response.text
- assert response.json()["contents"].strip().startswith("import marimo")
+ assert "import marimo" in response.json()["contents"]
@with_session(SESSION_ID)
def test_save_file(client: TestClient) -> None:
filename = get_session_manager(client).file_router.get_unique_file_key()
diff --git a/tests/_server/api/test_middleware.py b/tests/_server/api/test_middleware.py
index 14e9ebc9dd..871e285f11 100644
--- a/tests/_server/api/test_middleware.py
+++ b/tests/_server/api/test_middleware.py
@@ -445,6 +445,7 @@ class TestProxyMiddleware:
)
return edit_app
+ @pytest.mark.flaky(reruns=5)
def test_proxy_static_file(self, app_with_static_proxy: Starlette) -> None:
client = TestClient(app_with_static_proxy)
response = client.get("/_static/css/page.css")
@@ -452,6 +453,7 @@ class TestProxyMiddleware:
assert response.headers["content-type"].startswith("text/css")
assert "body { color: red; }" in response.text
+ @pytest.mark.flaky(reruns=5)
def test_proxy_large_static_file(
self, app_with_static_proxy: Starlette
) -> None:
@@ -474,6 +476,7 @@ class TestProxyMiddleware:
content_length += len(chunk)
assert content_length == 1024 * 1024
+ @pytest.mark.flaky(reruns=5)
async def test_http_client_streaming(
self, app_with_proxy: Starlette
) -> None: