Skip to content

Commit 014bec7

Browse files
Added test to check for error messages when using non-existent running components and not suppressing callback exceptions
1 parent 7c172b4 commit 014bec7

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

tests/integration/callbacks/test_basic_callback.py

+58-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ def on_click(_):
827827

828828
def test_cbsc020_callback_running_non_existing_component(dash_duo):
829829
lock = Lock()
830-
app = Dash(__name__)
830+
app = Dash(__name__, suppress_callback_exceptions=True)
831831

832832
app.layout = html.Div(
833833
[
@@ -858,3 +858,60 @@ def on_click(_):
858858
dash_duo.find_element("#start").click()
859859

860860
dash_duo.wait_for_text_to_equal("#output", "done")
861+
862+
863+
def test_cbsc021_callback_running_non_existing_component(dash_duo):
864+
lock = Lock()
865+
app = Dash(__name__)
866+
867+
app.layout = html.Div(
868+
[
869+
html.Button("start", id="start"),
870+
html.Div(id="output"),
871+
]
872+
)
873+
874+
@app.callback(
875+
Output("output", "children"),
876+
Input("start", "n_clicks"),
877+
running=[
878+
[
879+
Output("non_existent_component", "children"),
880+
html.B("on", id="content"),
881+
"off",
882+
]
883+
],
884+
prevent_initial_call=True,
885+
)
886+
def on_click(_):
887+
with lock:
888+
pass
889+
return "done"
890+
891+
dash_duo.start_server(
892+
app,
893+
debug=True,
894+
use_reloader=False,
895+
use_debugger=True,
896+
dev_tools_hot_reload=False,
897+
)
898+
with lock:
899+
dash_duo.find_element("#start").click()
900+
901+
dash_duo.wait_for_text_to_equal("#output", "done")
902+
error_title = "ID running component not found in layout"
903+
error_message = [
904+
"Component defined in running keyword not found in layout.",
905+
'Component id: "non_existent_component"',
906+
"This ID was used in the callback(s) for Output(s):",
907+
"output.children",
908+
"You can suppress this exception by setting",
909+
"`suppress_callback_exceptions=True`.",
910+
]
911+
# The error should show twice, once for trying to set running on and once for
912+
# turning it off.
913+
dash_duo.wait_for_text_to_equal(dash_duo.devtools_error_count_locator, "2")
914+
for error in dash_duo.find_elements(".dash-fe-error__title"):
915+
assert error.text == error_title
916+
for error_text in dash_duo.find_elements(".dash-backend-error"):
917+
assert all(line in error_text for line in error_message)

0 commit comments

Comments
 (0)