diff --git a/tests/units/utils/test_tasks.py b/tests/units/utils/test_tasks.py index ca8d76e8deb..7b898daaa95 100644 --- a/tests/units/utils/test_tasks.py +++ b/tests/units/utils/test_tasks.py @@ -1,11 +1,14 @@ import asyncio import contextlib +import os from unittest.mock import Mock import pytest from reflex.utils.tasks import ensure_task +CI = bool(os.environ.get("CI", False)) + class NotSuppressedError(Exception): """An exception that should not be suppressed.""" @@ -72,13 +75,13 @@ async def faulty_coro(): # noqa: RUF029 async def test_ensure_task_limit_window_passed(): - """Test that ensure_task raises after exceeding exception limit within the limit window.""" + """Test that ensure_task resets exception limit past the limit window.""" call_count = 0 async def faulty_coro(): nonlocal call_count call_count += 1 - await asyncio.sleep(0.05) + await asyncio.sleep(0.5 if CI else 0.05) if call_count > 3: raise RuntimeError("Test Passed") # noqa: EM101 raise ValueError("Should have been suppressed") # noqa: EM101 @@ -90,8 +93,8 @@ async def faulty_coro(): coro_function=faulty_coro, suppress_exceptions=[ValueError], exception_delay=0, - exception_limit=3, - exception_limit_window=0.1, + exception_limit=2, + exception_limit_window=0.1 if CI else 0.01, ) with contextlib.suppress(asyncio.CancelledError), pytest.raises(RuntimeError):