|
@@ -106,6 +106,7 @@ class TestState(BaseState):
|
|
fig: Figure = Figure()
|
|
fig: Figure = Figure()
|
|
dt: datetime.datetime = datetime.datetime.fromisoformat("1989-11-09T18:53:00+01:00")
|
|
dt: datetime.datetime = datetime.datetime.fromisoformat("1989-11-09T18:53:00+01:00")
|
|
_backend: int = 0
|
|
_backend: int = 0
|
|
|
|
+ asynctest: int = 0
|
|
|
|
|
|
@ComputedVar
|
|
@ComputedVar
|
|
def sum(self) -> float:
|
|
def sum(self) -> float:
|
|
@@ -129,6 +130,14 @@ class TestState(BaseState):
|
|
"""Do something."""
|
|
"""Do something."""
|
|
pass
|
|
pass
|
|
|
|
|
|
|
|
+ async def set_asynctest(self, value: int):
|
|
|
|
+ """Set the asynctest value. Intentionally overwrite the default setter with an async one.
|
|
|
|
+
|
|
|
|
+ Args:
|
|
|
|
+ value: The new value.
|
|
|
|
+ """
|
|
|
|
+ self.asynctest = value
|
|
|
|
+
|
|
|
|
|
|
class ChildState(TestState):
|
|
class ChildState(TestState):
|
|
"""A child state fixture."""
|
|
"""A child state fixture."""
|
|
@@ -313,6 +322,7 @@ def test_class_vars(test_state):
|
|
"upper",
|
|
"upper",
|
|
"fig",
|
|
"fig",
|
|
"dt",
|
|
"dt",
|
|
|
|
+ "asynctest",
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -733,6 +743,7 @@ def test_reset(test_state, child_state):
|
|
"mapping",
|
|
"mapping",
|
|
"dt",
|
|
"dt",
|
|
"_backend",
|
|
"_backend",
|
|
|
|
+ "asynctest",
|
|
}
|
|
}
|
|
|
|
|
|
# The dirty vars should be reset.
|
|
# The dirty vars should be reset.
|
|
@@ -3179,6 +3190,13 @@ async def test_setvar(mock_app: rx.App, token: str):
|
|
TestState.setvar(42, 42)
|
|
TestState.setvar(42, 42)
|
|
|
|
|
|
|
|
|
|
|
|
+@pytest.mark.asyncio
|
|
|
|
+async def test_setvar_async_setter():
|
|
|
|
+ """Test that overridden async setters raise Exception when used with setvar."""
|
|
|
|
+ with pytest.raises(NotImplementedError):
|
|
|
|
+ TestState.setvar("asynctest", 42)
|
|
|
|
+
|
|
|
|
+
|
|
@pytest.mark.skipif("REDIS_URL" not in os.environ, reason="Test requires redis")
|
|
@pytest.mark.skipif("REDIS_URL" not in os.environ, reason="Test requires redis")
|
|
@pytest.mark.parametrize(
|
|
@pytest.mark.parametrize(
|
|
"expiration_kwargs, expected_values",
|
|
"expiration_kwargs, expected_values",
|