mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Ensure watcher isn't called on first_set when init is False and value doesn't change (#1367)
* Ensure watcher not called when value doesnt change, even on first set * Update CHANGELOG.md
This commit is contained in:
@@ -88,8 +88,6 @@ async def test_watch_async_init_true():
|
||||
assert app.watcher_new_value == OLD_VALUE # The value wasn't changed
|
||||
|
||||
|
||||
@pytest.mark.xfail(
|
||||
reason="Reactive watcher is incorrectly always called the first time it is set, even if value is same [issue#1230]")
|
||||
async def test_watch_init_false_always_update_false():
|
||||
class WatcherInitFalse(App):
|
||||
count = reactive(0, init=False)
|
||||
@@ -102,6 +100,10 @@ async def test_watch_init_false_always_update_false():
|
||||
async with app.run_test():
|
||||
app.count = 0 # Value hasn't changed, and always_update=False, so watch_count shouldn't run
|
||||
assert app.watcher_call_count == 0
|
||||
app.count = 0
|
||||
assert app.watcher_call_count == 0
|
||||
app.count = 1
|
||||
assert app.watcher_call_count == 1
|
||||
|
||||
|
||||
async def test_watch_init_true():
|
||||
|
||||
Reference in New Issue
Block a user