mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add a test for private validation
Currently failing.
This commit is contained in:
@@ -413,3 +413,25 @@ async def test_public_and_private_watch() -> None:
|
||||
pilot.app.counter += 1
|
||||
assert calls["private"] is True
|
||||
assert calls["public"] is True
|
||||
|
||||
|
||||
async def test_public_and_private_validate() -> None:
|
||||
"""If a reactive/var has public and private validate both should get called."""
|
||||
|
||||
calls: dict[str, bool] = {"private": False, "public": False}
|
||||
|
||||
class PrivateValidateTest(App):
|
||||
counter = var(0, init=False)
|
||||
|
||||
def validate_counter(self, _: int) -> None:
|
||||
calls["public"] = True
|
||||
|
||||
def _validate_counter(self, _: int) -> None:
|
||||
calls["private"] = True
|
||||
|
||||
async with PrivateValidateTest().run_test() as pilot:
|
||||
assert calls["private"] is False
|
||||
assert calls["public"] is False
|
||||
pilot.app.counter += 1
|
||||
assert calls["private"] is True
|
||||
assert calls["public"] is True
|
||||
|
||||
Reference in New Issue
Block a user