Skip to content

Commit a1e461f

Browse files
committed
Add no output counter test
1 parent 2b29699 commit a1e461f

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

tests/integration/callbacks/test_arbitrary_callbacks.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import time
2+
from multiprocessing import Value
3+
14
from dash import Dash, Input, Output, html, set_props, register_page
25

36

@@ -30,28 +33,39 @@ def on_click(n_clicks):
3033
def test_arb002_no_output_callbacks(dash_duo):
3134
app = Dash()
3235

36+
counter = Value("i", 0)
37+
3338
app.layout = html.Div(
3439
[
3540
html.Div(id="secondary-output"),
3641
html.Button("no-output", id="no-output"),
3742
html.Button("no-output2", id="no-output2"),
43+
html.Button("no-output3", id="no-output3"),
3844
]
3945
)
4046

4147
@app.callback(
4248
Input("no-output", "n_clicks"),
4349
prevent_initial_call=True,
4450
)
45-
def no_output(_):
51+
def no_output1(_):
4652
set_props("secondary-output", {"children": "no-output"})
4753

4854
@app.callback(
4955
Input("no-output2", "n_clicks"),
5056
prevent_initial_call=True,
5157
)
52-
def no_output(_):
58+
def no_output2(_):
5359
set_props("secondary-output", {"children": "no-output2"})
5460

61+
@app.callback(
62+
Input("no-output3", "n_clicks"),
63+
prevent_initial_call=True,
64+
)
65+
def no_output3(_):
66+
with counter.get_lock():
67+
counter.value += 1
68+
5569
dash_duo.start_server(app)
5670

5771
dash_duo.wait_for_element("#no-output").click()
@@ -60,6 +74,12 @@ def no_output(_):
6074
dash_duo.wait_for_element("#no-output2").click()
6175
dash_duo.wait_for_text_to_equal("#secondary-output", "no-output2")
6276

77+
dash_duo.wait_for_element("#no-output3").click()
78+
79+
time.sleep(1)
80+
with counter.get_lock():
81+
assert counter.value == 1
82+
6383

6484
def test_arb003_arbitrary_pages(dash_duo):
6585
app = Dash(use_pages=True, pages_folder="")

0 commit comments

Comments
 (0)