Skip to content

Commit

Permalink
prevent flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
Light2Dark committed Jan 25, 2025
1 parent 469d137 commit 2e33e8a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/_cli/test_cli_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shutil
import subprocess
import sys
import time
from os import path
from pathlib import Path
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -162,6 +163,7 @@ def test_cli_export_html_wasm_read(temp_marimo_file: str) -> None:
)
assert "<marimo-wasm" in html

# if hangs on watchdog, add a dependency check
@staticmethod
def test_cli_export_html_wasm_watch(temp_marimo_file: str) -> None:
out_dir = Path(temp_marimo_file).parent / "out"
Expand All @@ -180,14 +182,15 @@ def test_cli_export_html_wasm_watch(temp_marimo_file: str) -> None:
)

watch_echo_found = False
for _ in range(10): # try 10 times
for _ in range(10): # read 10 lines
line = p.stdout.readline()
if not line:
break
line_str = line.decode()
if f"Watching {temp_marimo_file}" in line_str:
watch_echo_found = True
break
time.sleep(0.01) # avoid flaky test
assert watch_echo_found is True

# Modify file
Expand All @@ -200,6 +203,7 @@ def test_cli_export_html_wasm_watch(temp_marimo_file: str) -> None:
if line:
assert "Re-exporting" in line
break
time.sleep(0.01)

@staticmethod
def test_cli_export_async(temp_async_marimo_file: str) -> None:
Expand Down

0 comments on commit 2e33e8a

Please sign in to comment.