From 29544f580acdec5d8df9a795cb9b2a9e34862eda Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Tue, 3 Dec 2019 22:34:54 -0500 Subject: [PATCH 1/2] fix #1014 - test for no_update by type rather than identity --- dash/dash.py | 4 ++-- tests/integration/test_integration.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dash/dash.py b/dash/dash.py index d509ea987c..d21371bbbb 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -1357,7 +1357,7 @@ def add_context(*args, **kwargs): has_update = False for i, o in enumerate(output): val = output_value[i] - if val is not no_update: + if not isinstance(val, _NoUpdate): has_update = True o_id, o_prop = o.component_id, o.component_property component_ids[o_id][o_prop] = val @@ -1367,7 +1367,7 @@ def add_context(*args, **kwargs): response = {"response": component_ids, "multi": True} else: - if output_value is no_update: + if isinstance(output_value, _NoUpdate): raise exceptions.PreventUpdate response = { diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index 770738a39b..35fe3ad9af 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -2,6 +2,7 @@ import datetime import time import pytest +from copy import copy from bs4 import BeautifulSoup from selenium.webdriver.common.keys import Keys @@ -527,7 +528,8 @@ def show_clicks(n): return [ no_update if n and n > 4 else n, no_update if n and n > 2 else n, - no_update, + # make a new instance, to mock up caching and restoring no_update + copy(no_update), ] dash_duo.start_server(app) From f98a58741cf11d13973a27b478f65694f14ab913 Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Tue, 3 Dec 2019 22:40:33 -0500 Subject: [PATCH 2/2] changelog for no_update cache fix --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2edf7aa879..43200fd91a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Changed - [#1035](https://github.com/plotly/dash/pull/1035) Simplify our build process. +### Fixed +- [#1037](https://github.com/plotly/dash/pull/1037) Fix no_update test to allow copies, such as those stored and retrieved from a cache. + ## [1.7.0] - 2019-11-27 ### Added - [#967](https://github.com/plotly/dash/pull/967) Add support for defining