Jelajahi Sumber

make test_call_script more reliable (#5038)

Khaleel Al-Adhami 1 bulan lalu
induk
melakukan
07e056c6d6
2 mengubah file dengan 7 tambahan dan 3 penghapusan
  1. 6 2
      reflex/testing.py
  2. 1 1
      tests/integration/test_call_script.py

+ 6 - 2
reflex/testing.py

@@ -27,6 +27,7 @@ from typing import (
     Callable,
     Coroutine,
     Optional,
+    Sequence,
     Type,
     TypeVar,
 )
@@ -768,7 +769,7 @@ class AppHarness:
         self,
         element: "WebElement",
         timeout: TimeoutType = None,
-        exp_not_equal: str = "",
+        exp_not_equal: str | Sequence[str] = "",
     ) -> str | None:
         """Poll element.get_attribute("value") for change.
 
@@ -783,8 +784,11 @@ class AppHarness:
         Raises:
             TimeoutError: when the timeout expires before value changes
         """
+        exp_not_equal = (
+            (exp_not_equal,) if isinstance(exp_not_equal, str) else exp_not_equal
+        )
         if not self._poll_for(
-            target=lambda: element.get_attribute("value") != exp_not_equal,
+            target=lambda: element.get_attribute("value") not in exp_not_equal,
             timeout=timeout,
         ):
             raise TimeoutError(

+ 1 - 1
tests/integration/test_call_script.py

@@ -511,7 +511,7 @@ def test_call_script_w_var(
 
     inline_return_button.click()
     call_with_var_f_string_button.click()
-    assert call_script.poll_for_value(last_result, exp_not_equal="") == "1"
+    assert call_script.poll_for_value(last_result, exp_not_equal=("", "0")) == "1"
 
     inline_return_button.click()
     call_with_var_str_cast_button.click()