Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit c3b5ece

Browse files
committed
add failing test
this test demonstrates the issue found in plotly/dash#133 (comment)
1 parent 0dca300 commit c3b5ece

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/test_render.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,3 +1501,35 @@ def dynamic_output(*args):
15011501
)
15021502

15031503
self.assertEqual(call_count.value, 1)
1504+
1505+
def test_callbacks_called_multiple_times_and_out_of_order(self):
1506+
app = Dash(__name__)
1507+
app.layout = html.Div([
1508+
html.Button(id='input', n_clicks=0),
1509+
html.Div(id='output')
1510+
])
1511+
1512+
call_count = Value('i', 0)
1513+
1514+
@app.callback(
1515+
Output('output', 'children'),
1516+
[Input('input', 'n_clicks')])
1517+
def update_output(n_clicks):
1518+
call_count.value = call_count.value + 1
1519+
if n_clicks == 1:
1520+
time.sleep(4)
1521+
return n_clicks
1522+
1523+
self.startServer(app)
1524+
button = self.wait_for_element_by_id('input')
1525+
button.click()
1526+
button.click()
1527+
time.sleep(8)
1528+
self.percy_snapshot(
1529+
name='test_callbacks_called_multiple_times_and_out_of_order'
1530+
)
1531+
self.assertEqual(call_count.value, 3)
1532+
self.assertEqual(
1533+
self.driver.find_element_by_id('output').text,
1534+
'2'
1535+
)

0 commit comments

Comments
 (0)