Change private watcher support call public and private if available

See https://github.com/Textualize/textual/pull/2442#issuecomment-1529512891

This changes the original PR so that, rather than calling a private watcher
instead of a public, as originally issued, we now call public and private,
if they're both there.

If they are both there private is called first.
This commit is contained in:
Dave Pearson
2023-05-01 10:28:55 +01:00
parent 847fd6e69e
commit 54db445dd7
2 changed files with 10 additions and 8 deletions

View File

@@ -390,8 +390,8 @@ async def test_watch_compute():
assert watch_called == [True, True, False, False, True, True, False, False]
async def test_private_watch() -> None:
"""A private watch method should win over a public watch method."""
async def test_public_and_private_watch() -> None:
"""If a reactive/var has public and private watches both should get called."""
calls: dict[str, bool] = {"private": False, "public": False}
@@ -409,4 +409,4 @@ async def test_private_watch() -> None:
assert calls["public"] is False
pilot.app.counter += 1
assert calls["private"] is True
assert calls["public"] is False
assert calls["public"] is True